Open Monograph Press  3.3.0
importExport.php
1 <?php
2 
18 require(dirname(__FILE__) . '/bootstrap.inc.php');
19 
21 
22  var $command;
23  var $plugin;
25 
30  function __construct($argv = array()) {
31  parent::__construct($argv);
32  $this->command = array_shift($this->argv);
33  $this->parameters = $this->argv;
34  }
35 
39  function usage() {
40  echo "Command-line tool for import/export tasks\n"
41  . "Usage:\n"
42  . "\t{$this->scriptName} list: List available plugins\n"
43  . "\t{$this->scriptName} [pluginName] usage: Display usage information for a plugin\n"
44  . "\t{$this->scriptName} [pluginName] [params...]: Invoke a plugin\n";
45  }
46 
50  function execute() {
51  $plugins = PluginRegistry::loadCategory('importexport');
52  if ($this->command === 'list') {
53  echo "Available plugins:\n";
54  if (empty($plugins)) echo "\t(None)\n";
55  else foreach ($plugins as $plugin) {
56  echo "\t" . $plugin->getName() . "\n";
57  }
58  return;
59  }
60  if ($this->command == 'usage' || $this->command == 'help' || $this->command == '' || ($plugin = PluginRegistry::getPlugin('importexport', $this->command))===null) {
61  $this->usage();
62  return;
63  }
64 
65  return $plugin->executeCLI($this->scriptName, $this->parameters);
66  }
67 
68 }
69 
70 $tool = new importExport(isset($argv) ? $argv : array());
71 $tool->execute();
72 
73 
CommandLineTool
Initialization code for command-line scripts.
Definition: CliTool.inc.php:44
$tool
$tool
Definition: mergeCoverageReportTool.php:120
importExport\execute
execute()
Definition: importExport.php:50
importExport\$command
$command
Definition: importExport.php:22
importExport
CLI tool to perform import/export tasks.
Definition: importExport.php:20
PluginRegistry\loadCategory
static loadCategory($category, $enabledOnly=false, $mainContextId=null)
Definition: PluginRegistry.inc.php:103
importExport\$plugin
$plugin
Definition: importExport.php:23
PluginRegistry\getPlugin
static getPlugin($category, $name)
Definition: PluginRegistry.inc.php:85
importExport\$parameters
$parameters
Definition: importExport.php:24
importExport\__construct
__construct($argv=array())
Definition: importExport.php:30
importExport\usage
usage()
Definition: importExport.php:39
CommandLineTool\$argv
$argv
Definition: CliTool.inc.php:53