dwpage.php: add an option to get metadata
This adds an option to ./bin/dwpage.php, to display metadata about a page. This is useful in maintenance shell scripts, and debugging plugins. There is no ability to write metadata, only read them. ./bin/dwpage.php -u <user> gmeta [page] <meta tag> where <meta tag> can be "date modified" (in quotes) or "last_change date" an empty <meta tag> returns all metadata. Signed-off-by: Robin Getz <robin.getz@analog.com>
This commit is contained in:
parent
7347c7c107
commit
2c23659d6e
|
@ -118,6 +118,28 @@ class PageCLI extends CLI {
|
|||
true,
|
||||
'unlock'
|
||||
);
|
||||
|
||||
/* gmeta command */
|
||||
$options->registerCommand(
|
||||
'gmeta',
|
||||
'Prints metadata value for a page to stdout.'
|
||||
);
|
||||
$options->registerArgument(
|
||||
'wikipage',
|
||||
'The wiki page to get the metadata for',
|
||||
true,
|
||||
'gmeta'
|
||||
);
|
||||
$options->registerArgument(
|
||||
'key',
|
||||
'The name of the metadata item to be retrieved.' . "\n" .
|
||||
'If empty, an array of all the metadata items is returned.' ."\n" .
|
||||
'For retrieving items that are stored in sub-arrays, separate the ' .
|
||||
'keys of the different levels by spaces, in quotes, eg "date modified".',
|
||||
false,
|
||||
'gmeta'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,6 +182,14 @@ class PageCLI extends CLI {
|
|||
$this->clearLock($wiki_id);
|
||||
$this->success("$wiki_id unlocked");
|
||||
break;
|
||||
case 'gmeta':
|
||||
$wiki_id = array_shift($args);
|
||||
$key = trim(array_shift($args));
|
||||
$meta=print_r(p_get_metadata($wiki_id, $key), true);
|
||||
print($meta);
|
||||
if (strcmp(substr($meta, -1), "\n"))
|
||||
print("\n");
|
||||
break;
|
||||
default:
|
||||
echo $options->help();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue