Esempio n. 1
0
 function localeCheck($args)
 {
     parent::CommandLineTool($args);
     array_shift($args);
     // Knock the tool name off the list
     $this->locales = $args;
 }
Esempio n. 2
0
 /**
  * Constructor.
  * @param $argv array command-line arguments
  * 	If specified, the first argument should be the file to parse
  */
 function XmlToSqlTool($argv = array())
 {
     parent::CommandLineTool($argv);
     if (isset($this->argv[0]) && in_array($this->argv[0], array('-schema', '-data'))) {
         $this->type = substr($this->argv[0], 1);
         $argOffset = 1;
     } else {
         $this->type = 'schema';
         $argOffset = 0;
     }
     if (!isset($this->argv[$argOffset]) || !in_array($this->argv[$argOffset], array('print', 'save', 'print_upgrade', 'save_upgrade', 'execute'))) {
         $this->usage();
         exit(1);
     }
     $this->command = $this->argv[$argOffset];
     $file = isset($this->argv[$argOffset + 1]) ? $this->argv[$argOffset + 1] : DATABASE_XML_FILE;
     if (!file_exists($file) && !file_exists($file2 = PWD . '/' . $file)) {
         printf("Input file \"%s\" does not exist!\n", $file);
         exit(1);
     }
     $this->inputFile = isset($file2) ? $file2 : $file;
     $this->outputFile = isset($this->argv[$argOffset + 2]) ? PWD . '/' . $this->argv[$argOffset + 2] : null;
     if (in_array($this->command, array('save', 'save_upgrade')) && ($this->outputFile == null || file_exists($this->outputFile) && (is_dir($this->outputFile) || !is_writeable($this->outputFile)) || !is_writable(dirname($this->outputFile)))) {
         printf("Invalid output file \"%s\"!\n", $this->outputFile);
         exit(1);
     }
 }
Esempio n. 3
0
 /**
  * Constructor.
  * @param $argv array command-line arguments
  */
 function preCompile($argv = array())
 {
     parent::CommandLineTool($argv);
     if (isset($this->argv[0]) && $this->argv[0] == '-h') {
         $this->usage();
         exit(0);
     }
 }
Esempio n. 4
0
 /**
  * Constructor.
  * @param $argv array command-line arguments
  */
 function __construct($argv = array())
 {
     parent::__construct($argv);
     if (!sizeof($this->argv)) {
         $this->usage();
         exit(1);
     }
     $this->parameters = $this->argv;
 }
 /**
  * Constructor.
  * @param $argv array command-line arguments
  */
 function SubmissionDeletionTool($argv = array())
 {
     parent::CommandLineTool($argv);
     if (!sizeof($this->argv)) {
         $this->usage();
         exit(1);
     }
     $this->parameters = $this->argv;
 }
 /**
  * Constructor.
  * @param $argv array command-line arguments
  */
 function upgradeTool($argv = array())
 {
     parent::CommandLineTool($argv);
     if (!isset($this->argv[0]) || !in_array($this->argv[0], array('check', 'latest', 'upgrade', 'patch', 'download'))) {
         $this->usage();
         exit(1);
     }
     $this->command = $this->argv[0];
 }
Esempio n. 7
0
 /**
  * Constructor.
  * @param $argv array command-line arguments
  */
 function upgradeTool($argv = array())
 {
     parent::CommandLineTool($argv);
     if (!isset($this->argv[0]) || !in_array($this->argv[0], array('check', 'latest', 'upgrade', 'patch', 'download'))) {
         $this->usage();
         exit(1);
     }
     $this->command = $this->argv[0];
     AppLocale::requireComponents(LOCALE_COMPONENT_PKP_INSTALLER);
 }
Esempio n. 8
0
 /**
  * Constructor.
  * @param $argv array command-line arguments
  * 	If specified, the first argument should be the file to parse
  */
 function __construct($argv = array())
 {
     parent::__construct($argv);
     if (count($argv) != 3) {
         $this->usage();
         exit(1);
     }
     $this->oldTag = $argv[1];
     $this->newTag = $argv[2];
 }
Esempio n. 9
0
 /**
  * Constructor.
  * @param $argv array command-line arguments
  */
 function __construct($argv = array())
 {
     parent::__construct($argv);
     if (!isset($this->argv[0]) || !isset($this->argv[1])) {
         $this->usage();
         exit(1);
     }
     $this->username1 = $this->argv[0];
     $this->username2 = $this->argv[1];
 }
Esempio n. 10
0
 /**
  * Constructor.
  * @param $argv array command-line arguments
  */
 function mergeUsers($argv = array())
 {
     parent::CommandLineTool($argv);
     if (!isset($this->argv[0]) || !isset($this->argv[1])) {
         $this->usage();
         exit(1);
     }
     $this->username1 = $this->argv[0];
     $this->username2 = $this->argv[1];
 }
Esempio n. 11
0
 /**
  * Constructor.
  * @param $argv array command-line arguments
  * 	If specified, the first argument should be the file to parse
  */
 function genEmailUpdates($argv = array())
 {
     parent::CommandLineTool($argv);
     if (count($argv) != 3) {
         $this->usage();
         exit(1);
     }
     $this->oldTag = $argv[1];
     $this->newTag = $argv[2];
 }
Esempio n. 12
0
 /**
  * Constructor.
  * @param $argv array command-line arguments
  */
 function CopyAccessLogFileTool($argv = array())
 {
     parent::CommandLineTool($argv);
     if (sizeof($this->argv) !== 1) {
         $this->usage();
         exit(1);
     }
     $plugin =& PluginRegistry::getPlugin('generic', 'usagestatsplugin');
     /* @var $plugin UsageStatsPlugin */
     $this->_usageStatsDir = $plugin->getFilesPath();
     $this->_tmpDir = $this->_usageStatsDir . DIRECTORY_SEPARATOR . 'tmp';
     AppLocale::requireComponents(LOCALE_COMPONENT_PKP_ADMIN);
     // This tool needs egrep and gunzip path configured.
     $this->_egrepPath = escapeshellarg(Config::getVar('cli', 'egrep'));
     if ($this->_egrepPath == "''") {
         printf(__('admin.copyAccessLogFileTool.error.noEgrep') . "\n");
         exit(1);
     }
     $this->_gunzipPath = escapeshellarg(Config::getVar('cli', 'gunzip'));
     if ($this->_gunzipPath == "''") {
         printf(__('admin.copyAccessLogFileTool.error.noGunzip') . "\n");
         exit(1);
     }
     // Get a list of files currently inside the usage stats dir.
     $fileLoaderDirs = array(FILE_LOADER_PATH_STAGING, FILE_LOADER_PATH_PROCESSING, FILE_LOADER_PATH_ARCHIVE, FILE_LOADER_PATH_REJECT);
     $usageStatsFiles = array();
     foreach ($fileLoaderDirs as $dir) {
         $dirFiles = glob($this->_usageStatsDir . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . '*');
         if (is_array($dirFiles) && count($dirFiles) > 0) {
             foreach ($dirFiles as $file) {
                 if (!is_file($file)) {
                     continue;
                 }
                 $fileBasename = pathinfo($file, PATHINFO_BASENAME);
                 if (pathinfo($file, PATHINFO_EXTENSION) == 'gz') {
                     // Always save the filename without compression extension.
                     $fileBasename = substr($fileBasename, 0, -3);
                 }
                 $usageStatsFiles[] = $fileBasename;
             }
         }
     }
     $this->_usageStatsFiles = $usageStatsFiles;
     // Get a list of context paths.
     $contextDao =& Application::getContextDAO();
     /* @var $contextDao ContextDAO */
     $contextFactory = $contextDao->getAll();
     $contextPaths = array();
     while ($context =& $contextFactory->next()) {
         /* @var $context Context */
         $contextPaths[] = escapeshellarg($context->getPath());
     }
     $contextPaths = implode('/|/', $contextPaths);
     $this->_contextPaths = $contextPaths;
 }
Esempio n. 13
0
 /**
  * Constructor
  */
 function poToCountries($argv = array())
 {
     parent::CommandLineTool($argv);
     $toolName = array_shift($argv);
     $this->locale = array_shift($argv);
     $this->translationFile = array_shift($argv);
     if (!preg_match('/^[a-z]{2}_[A-Z]{2}$/', $this->locale) || empty($this->translationFile) || !file_exists($this->translationFile)) {
         $this->usage();
         exit(1);
     }
 }
Esempio n. 14
0
 /**
  * Constructor.
  * @param $argv array command-line arguments
  */
 function migrate($argv = array())
 {
     parent::CommandLineTool($argv);
     if (!isset($this->argv[0]) || !isset($this->argv[1])) {
         $this->usage();
         exit(1);
     }
     $this->journalPath = $this->argv[0];
     $this->importPath = $this->argv[1];
     $this->options = array_slice($this->argv, 2);
 }
Esempio n. 15
0
 /**
  * Constructor
  */
 function __construct($argv = array())
 {
     parent::__construct($argv);
     $toolName = array_shift($argv);
     $this->locale = array_shift($argv);
     $this->translationFile = array_shift($argv);
     if (!preg_match('/^[a-z]{2}_[A-Z]{2}$/', $this->locale) || empty($this->translationFile) || !file_exists($this->translationFile)) {
         $this->usage();
         exit(1);
     }
 }
Esempio n. 16
0
 /**
  * Constructor.
  * @param $argv array command-line arguments
  * 		If specified, the first parameter should be the input locale (default "en_US")
  * 		and the second parameter the output locale (default "te_ST")
  */
 function genTestLocale($argv = array())
 {
     parent::CommandLineTool($argv);
     if (count($this->argv) == 2) {
         $this->inLocale = $this->argv[0];
         $this->outLocale = $this->argv[1];
     } else {
         $this->inLocale = DEFAULT_IN_LOCALE;
         $this->outLocale = DEFAULT_OUT_LOCALE;
     }
     $this->replaceMap = array('a' => "å", 'A' => "Æ", 'c' => "ç", 'C' => "Ç", 'd' => "ð", 'D' => "Ð", 'e' => "è", 'E' => "É", 'i' => "î", 'I' => "Î", 'n' => "ñ", 'N' => "Ñ", 'o' => "ó", 'O' => "Ò", 's' => "þ", 'S' => "ß", 'u' => "ü", 'U' => "Ü", 'y' => "ý", 'Y' => "Ý", '&' => "&");
 }
Esempio n. 17
0
 /**
  * Constructor.
  * @param $argv array command-line arguments
  */
 function fixFilenames($argv = array())
 {
     parent::CommandLineTool($argv);
     if (($arg = array_pop($this->argv)) == '--dry-run') {
         $this->dryrun = true;
     } elseif ($arg == '') {
         $this->dryrun = false;
     } else {
         $this->usage();
         exit;
     }
 }
Esempio n. 18
0
 /**
  * Constructor.
  * @param $argv array command-line arguments
  */
 function __construct($argv = array())
 {
     parent::__construct($argv);
     if (($arg = array_pop($this->argv)) == '--dry-run') {
         $this->dryrun = true;
     } elseif ($arg == '') {
         $this->dryrun = false;
     } else {
         $this->usage();
         exit;
     }
 }
Esempio n. 19
0
 function harvest($argv = array())
 {
     parent::CommandLineTool($argv);
     array_shift($argv);
     // Clear the tool name from argv
     $this->firstParam = array_shift($argv);
     $archiveDao =& DAORegistry::getDAO('ArchiveDAO');
     if ($this->firstParam === 'all') {
         $this->archives =& $archiveDao->getArchives();
     } else {
         $archive = $archiveDao->getArchive((int) $this->firstParam, false);
         if ($archive) {
             $archives = array($archive);
             import('lib.pkp.classes.core.ArrayItemIterator');
             $this->archives = new ArrayItemIterator($archives);
         } else {
             $this->archives = null;
             // Invalid ID specified
         }
     }
     // Set the various flags for the parser, if supported.
     $this->params = array();
     foreach ($argv as $arg) {
         switch ($arg) {
             case 'verbose':
                 $this->params['callback'] = array(&$this, 'statusCallback');
                 break;
             case 'parallel':
                 $this->params['parallel'] = true;
                 break;
             default:
                 if (($i = strpos($arg, '=')) !== false) {
                     // Treat the parameter like a name=value pair
                     $paramName = substr($arg, 0, $i);
                     $paramValue = substr($arg, $i + 1);
                     if (!isset($this->params[$paramName])) {
                         $this->params[$paramName] = $paramValue;
                     } else {
                         if (is_array($this->params[$paramName])) {
                             $this->params[$paramName][] = $paramValue;
                         } else {
                             $this->params[$paramName] = array($this->params[$paramName], $paramValue);
                         }
                     }
                 } else {
                     // Treat the parameter like a boolean.
                     $this->params[$arg] = true;
                 }
                 break;
         }
     }
 }
 /**
  * Constructor.
  * @param $argv array command-line arguments
  * 		If specified, the first parameter should be the path to
  *		a tasks XML descriptor file (other than the default)
  */
 function ScheduledTaskTool($argv = array())
 {
     parent::CommandLineTool($argv);
     if (isset($this->argv[0])) {
         $this->file = $this->argv[0];
     } else {
         $this->file = TASKS_REGISTRY_FILE;
     }
     if (!file_exists($this->file) || !is_readable($this->file)) {
         printf("Tasks file \"%s\" does not exist or is not readable!\n", $this->file);
         exit(1);
     }
     $this->taskDao =& DAORegistry::getDAO('ScheduledTaskDAO');
 }
Esempio n. 21
0
 /**
  * Constructor.
  * @param $argv array command-line arguments
  */
 function buildCss($argv = array())
 {
     parent::CommandLineTool($argv);
     array_shift($argv);
     // Flush the tool name from the argv list
     $this->force = false;
     while ($option = array_shift($argv)) {
         switch ($option) {
             case 'force':
                 $this->force = true;
                 break;
             default:
                 $this->usage();
                 exit(-1);
         }
     }
 }
Esempio n. 22
0
 /**
  * Constructor.
  * @param $argv array command-line arguments
  */
 function CopyAccessLogFileTool($argv = array())
 {
     parent::CommandLineTool($argv);
     AppLocale::requireComponents(LOCALE_COMPONENT_OJS_ADMIN);
     if (count($this->argv) < 1 || count($this->argv) > 2) {
         $this->usage();
         exit(1);
     }
     $plugin =& PluginRegistry::getPlugin('generic', 'usagestatsplugin');
     /* @var $plugin UsageStatsPlugin */
     $this->_usageStatsDir = $plugin->getFilesPath();
     $this->_tmpDir = $this->_usageStatsDir . DIRECTORY_SEPARATOR . 'tmp';
     // Get a list of files currently inside the usage stats dir.
     $fileLoaderDirs = array(FILE_LOADER_PATH_STAGING, FILE_LOADER_PATH_PROCESSING, FILE_LOADER_PATH_ARCHIVE, FILE_LOADER_PATH_REJECT);
     $usageStatsFiles = array();
     foreach ($fileLoaderDirs as $dir) {
         $dirFiles = glob($this->_usageStatsDir . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . '*');
         if (is_array($dirFiles) && count($dirFiles) > 0) {
             foreach ($dirFiles as $file) {
                 if (!is_file($file)) {
                     continue;
                 }
                 $fileBasename = pathinfo($file, PATHINFO_BASENAME);
                 if (pathinfo($file, PATHINFO_EXTENSION) == 'gz') {
                     // Always save the filename without compression extension.
                     $fileBasename = substr($fileBasename, 0, -3);
                 }
                 $usageStatsFiles[] = $fileBasename;
             }
         }
     }
     $this->_usageStatsFiles = $usageStatsFiles;
     // Get a list of journal paths.
     $journalDao =& DAORegistry::getDAO('JournalDAO');
     /* @var $journalDao JournalDAO */
     $journalFactory = $journalDao->getJournals();
     $journalPaths = array();
     while ($journal =& $journalFactory->next()) {
         /* @var $journal Journal */
         $journalPaths[] = escapeshellarg($journal->getPath());
     }
     $journalPaths = implode('/|/', $journalPaths);
     $this->_journalPaths = $journalPaths;
 }
 /**
  * Constructor.
  * @param $argv array command-line arguments
  *  The first argument must be the file to check
  */
 function MergeCoverageReportTool($argv = array())
 {
     parent::CommandLineTool($argv);
     // Show the usage screen if explicitly requested or wrong
     // number of command line arguments.
     $wrongArgCount = count($this->argv) < 2 ? true : false;
     if ($wrongArgCount || $argv[0] == '-h') {
         $this->usage();
         if ($wrongArgCount) {
             printf(PHP_EOL . 'Wrong number of arguments!' . PHP_EOL);
             exit(1);
         } else {
             exit(0);
         }
     }
     // Parse the command line arguments
     $this->script = array_shift($argv);
     $this->target = array_shift($argv);
     if (!is_dir($this->target)) {
         echo "Target directory {$this->target} dosn't exist" . PHP_EOL;
         exit(1);
     }
     if (!is_writable($this->target)) {
         echo "Target directory {$this->target} is not writable" . PHP_EOL;
         exit(1);
     }
     $this->coverageFiles = $argv;
     foreach ($this->coverageFiles as $file) {
         if (!is_readable($file)) {
             echo "Coverage file {$file} is not readable" . PHP_EOL;
             exit(1);
         }
     }
     // Verify that $phpunit is a file
     if (!($this->phpunit = exec('which phpunit') and is_readable($this->phpunit))) {
         echo 'Couldn\'t find phpunit in $PATH' . PHP_EOL;
         exit(1);
     }
 }
Esempio n. 24
0
 /**
  * Constructor.
  * @param $argv array command-line arguments
  *  The first argument must be the file to check
  */
 function PhpCompat($argv = array())
 {
     parent::CommandLineTool($argv);
     // Show the usage screen if explicitly requested or wrong
     // number of command line arguments.
     $wrongArgCount = count($this->argv) != 1 ? true : false;
     if ($wrongArgCount || $argv[0] == '-h') {
         $this->usage();
         if ($wrongArgCount) {
             printf("\nWrong number of arguments!", $this->input_file);
             exit(1);
         } else {
             exit(0);
         }
     }
     // Set the source file or directory to be parsed
     $this->input_file = $this->argv[0];
     // Check whether the source exists
     if (!file_exists($this->input_file)) {
         printf("Invalid source \"%s\"!\n", $this->input_file);
         exit(1);
     }
 }
Esempio n. 25
0
 /**
  * Constructor.
  * @param $argv array command-line arguments (see usage)
  */
 function importExport($argv = array())
 {
     parent::CommandLineTool($argv);
     $this->command = array_shift($this->argv);
     $this->parameters = $this->argv;
 }
Esempio n. 26
0
 /**
  * Constructor
  * @param $argv array
  */
 function __construct($argv)
 {
     parent::__construct($argv);
 }
Esempio n. 27
0
 /**
  * Constructor
  * @param $argv array
  */
 function rebuildSearchIndex($argv)
 {
     parent::CommandLineTool($argv);
 }
Esempio n. 28
0
 /**
  * Constructor.
  * @param $argv array command-line arguments (see usage)
  */
 function __construct($argv = array())
 {
     parent::__construct($argv);
     $this->command = array_shift($this->argv);
     $this->parameters = $this->argv;
 }
Esempio n. 29
0
 /**
  * Constructor.
  * @param $argv array command-line arguments
  */
 function installTool($argv = array())
 {
     parent::CommandLineTool($argv);
 }
 /**
  * Constructor.
  * @param $argv array command-line arguments
  */
 function __construct($argv = array())
 {
     parent::__construct($argv);
 }