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