Open Monograph Press
3.3.0
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
44
class
CommandLineTool
{
45
47
var
$scriptName
;
48
50
var
$argv
;
51
52
function
__construct
(
$argv
= array()) {
53
// Initialize the request object with a page router
54
$application
=
Application::get
();
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);
65
PluginRegistry::loadCategory
(
'generic'
);
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
}
AppLocale\initialize
static initialize($request)
Definition:
env1/MockAppLocale.inc.php:31
$application
$application
Definition:
index.php:61
CommandLineTool
Initialization code for command-line scripts.
Definition:
CliTool.inc.php:44
CommandLineTool\$scriptName
$scriptName
Definition:
CliTool.inc.php:50
INDEX_FILE_LOCATION
const INDEX_FILE_LOCATION
Definition:
index.php:60
PluginRegistry\loadCategory
static loadCategory($category, $enabledOnly=false, $mainContextId=null)
Definition:
PluginRegistry.inc.php:103
CommandLineTool\usage
usage()
Definition:
CliTool.inc.php:84
CommandLineTool\__construct
__construct($argv=array())
Definition:
CliTool.inc.php:55
PageRouter
Class providing OMP-specific page routing.
Definition:
PageRouter.inc.php:19
PKPApplication\get
static get()
Definition:
PKPApplication.inc.php:235
CommandLineTool\$argv
$argv
Definition:
CliTool.inc.php:53
lib
pkp
classes
cliTool
CliTool.inc.php
Generated on Fri Aug 28 2020 14:51:44 for Open Monograph Press by
1.8.17