Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
importExport.php
1 <?php
2 
18 require(dirname(__FILE__) . '/bootstrap.inc.php');
19 
21 
22  var $command;
23  var $plugin;
24  var $parameters;
25 
30  function importExport($argv = array()) {
31  parent::CommandLineTool($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 ?>
Initialization code for command-line scripts.
Definition: CliTool.inc.php:44
static & loadCategory($category, $enabledOnly=false, $mainContextId=null)
CLI tool to perform import/export tasks.
static & getPlugin($category, $name)
importExport($argv=array())