Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
CliTool.inc.php
1 <?php
2 
26 define('PWD', getcwd());
27 chdir(dirname(INDEX_FILE_LOCATION)); /* Change to base directory */
28 if (!defined('STDIN')) {
29  define('STDIN', fopen('php://stdin','r'));
30 }
31 define('SESSION_DISABLE_INIT', 1);
32 require('./lib/pkp/includes/bootstrap.inc.php');
33 
34 if (!isset($argc)) {
35  // In PHP < 4.3.0 $argc/$argv are not automatically registered
36  if (isset($_SERVER['argc'])) {
37  $argc = $_SERVER['argc'];
38  $argv = $_SERVER['argv'];
39  } else {
40  $argc = $argv = null;
41  }
42 }
43 
45 
47  var $scriptName;
48 
50  var $argv;
51 
52  function CommandLineTool($argv = array()) {
53  // Initialize the request object with a page router
54  $application = PKPApplication::getApplication();
55  $request = $application->getRequest();
56 
57  // FIXME: Write and use a CLIRouter here (see classdoc)
58  import('classes.core.PageRouter');
59  $router = new PageRouter();
60  $router->setApplication($application);
61  $request->setRouter($router);
62 
63  // Initialize the locale and load generic plugins.
64  AppLocale::initialize($request);
66 
67  $this->argv = isset($argv) && is_array($argv) ? $argv : array();
68 
69  if (isset($_SERVER['SERVER_NAME'])) {
70  die('This script can only be executed from the command-line');
71  }
72 
73  $this->scriptName = isset($this->argv[0]) ? array_shift($this->argv) : '';
74 
75  if (isset($this->argv[0]) && $this->argv[0] == '-h') {
76  $this->usage();
77  exit(0);
78  }
79  }
80 
81  function usage() {
82  }
83 
84 }
85 
86 ?>
Initialization code for command-line scripts.
Definition: CliTool.inc.php:44
Class providing OMP-specific page routing.
static & loadCategory($category, $enabledOnly=false, $mainContextId=null)