コード例 #1
0
 /**
  * Main Entry Point
  * */
 public function run()
 {
     //deal with command line argument
     try {
         $opts = new Zend_Console_Getopt(array('discover|d' => 'special Twitter search for PHP around Ottawa (not saved)'));
         $opts->parse();
     } catch (Zend_Console_Getopt_Exception $e) {
         echo $e->getUsageMessage();
         exit;
     }
     // if special argument is received
     if (isset($opts->d)) {
         $this->fetchTwitterSpecial($opts->getRemainingArgs());
     } else {
         $this->fetchBlogs();
         $this->fetchTwitter();
         // clear all cache
         $cacheConfig = $this->application->getBootstrap()->getOption('cache');
         if ($cacheConfig['enabled']) {
             $cache = Zend_Cache::factory('Page', 'File', array(), $cacheConfig['backend']);
             echo PHP_EOL . '->clearing cache' . PHP_EOL;
             $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
         }
     }
 }
コード例 #2
0
 public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     try {
         $opts = new Zend_Console_Getopt(array('controller|c=s' => 'Name of the controller to open', 'action|a=s' => 'The command line action to execute', 'cityId|ci=i' => 'City id to get trend data for', 'startDate|sd=s' => 'Start date for the price trends', 'endDate|ed=s' => 'End date for the price trends', 'hours|h=i' => 'How many hours to simulate for'));
         $opts->parse();
         $args = $opts->getRemainingArgs();
         if (!isset($opts->action)) {
             throw new Zend_Console_Getopt_Exception('Action parameter missing');
         }
         $cliAction = $opts->action;
         $cliController = $opts->controller;
         $paramters = array();
         $optArray = $opts->toArray();
         for ($i = 0; $i < count($optArray); $i += 2) {
             $paramters[$optArray[$i]] = $optArray[$i + 1];
         }
     } catch (Zend_Console_Getopt_Exception $e) {
         echo $opts->getUsageMessage();
         exit;
     }
     // set the request as a CLI request
     $request = new Zend_Controller_Request_Simple($cliAction, $cliController, 'cli');
     foreach ($paramters as $key => $paramVal) {
         $request->setParam($key, $paramVal);
     }
     foreach ($args as $argument) {
         $request->setParam($argument, true);
     }
     $response = new Zend_Controller_Response_Cli();
     $front = Zend_Controller_Front::getInstance();
     $front->setRequest($request)->setResponse($response);
 }
コード例 #3
0
ファイル: Cron.php プロジェクト: fredcido/simuweb
 /**
  *
  * @param Zend_Controller_Request_Abstract $dispatcher
  * @return Zend_Controller_Request_Abstract 
  */
 public function route(Zend_Controller_Request_Abstract $dispatcher)
 {
     $getopt = new Zend_Console_Getopt(array());
     $arguments = $getopt->getRemainingArgs();
     $controller = null;
     $action = null;
     $params = array();
     if ($arguments) {
         foreach ($arguments as $index => $command) {
             if (preg_match('/([a-z0-9]+)=([a-z0-9]+)/i', trim($command), $match)) {
                 switch ($match[1]) {
                     case 'controller':
                         $controller = $match[2];
                         break;
                     case 'action':
                         $action = $match[2];
                         break;
                     default:
                         $params[$match[1]] = $match[2];
                 }
             }
         }
         $action = empty($action) ? 'index' : $action;
         $controller = empty($controller) ? 'index' : $controller;
         $dispatcher->setControllerName($controller);
         $dispatcher->setActionName($action);
         $dispatcher->setParams($params);
         return $dispatcher;
     }
     echo "Invalid command.\n";
     echo "No command given.\n", exit;
 }
コード例 #4
0
 /**
  * import employee data from csv file
  * 
  * @param Zend_Console_Getopt $opts
  * @return integer
  */
 public function importEmployee($opts)
 {
     $args = $opts->getRemainingArgs();
     array_push($args, 'definition=' . 'hr_employee_import_csv');
     if ($opts->d) {
         array_push($args, '--dry');
     }
     if ($opts->v) {
         array_push($args, '--verbose');
     }
     $opts->setArguments($args);
     $result = $this->_import($opts);
     if (empty($result)) {
         return 2;
     }
     foreach ($result as $filename => $importResult) {
         $importedEmployee = $this->_getImportedEmployees($importResult);
         foreach ($importedEmployee as $employee) {
             $this->_sanitizeEmployee($opts, $employee);
             $currentEmployee = $this->_getCurrentEmployee($employee);
             if ($currentEmployee) {
                 $employee = $this->_updateImportedEmployee($opts, $employee, $currentEmployee);
             } else {
                 $employee = $this->_createImportedEmployee($opts, $employee);
             }
             if ($opts->v) {
                 print_r($employee->toArray());
             }
             if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
                 Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($employee->toArray(), TRUE));
             }
         }
     }
     return 0;
 }
コード例 #5
0
 public function route(Zend_Controller_Request_Abstract $dispatcher)
 {
     $getopt = new Zend_Console_Getopt(array());
     $arguments = $getopt->getRemainingArgs();
     $controller = "";
     $action = "";
     $params = array();
     if ($arguments) {
         foreach ($arguments as $index => $command) {
             $details = explode("=", $command);
             if ($details[0] == "controller") {
                 $controller = $details[1];
             } else {
                 if ($details[0] == "action") {
                     $action = $details[1];
                 } else {
                     $params[$details[0]] = $details[1];
                 }
             }
         }
         if ($action == "" || $controller == "") {
             die("\n\t\t\t\t\t\tMissing Controller and Action Arguments\n\t\t\t\t\t\t==\n\t\t\t\t\t\tYou should have:\n\t\t\t\t\t\tphp script.php controller=[controllername] action=[action] token=[token]\n\t\t\t\t\t\t");
         }
         $dispatcher->setModuleName('cronjob');
         $dispatcher->setControllerName($controller);
         $dispatcher->setActionName($action);
         $dispatcher->setParams($params);
         return $dispatcher;
     }
     echo "Invalid command.\n", exit;
     echo "No command given.\n", exit;
 }
コード例 #6
0
ファイル: Cli.php プロジェクト: quincia/zf-cli
 public function route(Zend_Controller_Request_Abstract $dispatcher)
 {
     $getopt = new Zend_Console_Getopt(array());
     $arguments = $getopt->getRemainingArgs();
     $controller = 'index';
     $action = 'index';
     if ($arguments) {
         $controller = array_shift($arguments);
         if ($arguments) {
             $action = array_shift($arguments);
             $pattern_valid_action = '~^\\w+[\\-\\w\\d]+$~';
             if (false == preg_match($pattern_valid_action, $action)) {
                 echo "Invalid action {$action}.\n", exit;
             }
             if ($arguments) {
                 foreach ($arguments as $arg) {
                     $parameter = explode('=', $arg, 2);
                     if (false == isset($parameter[1])) {
                         $parameter[1] = true;
                     }
                     $dispatcher->setParam($parameter[0], $parameter[1]);
                     unset($parameter);
                 }
             }
         }
     }
     $dispatcher->setControllerName($controller)->setActionName($action);
     return $dispatcher;
 }
コード例 #7
0
 public function route(Zend_Controller_Request_Abstract $dispatcher)
 {
     try {
         $getopt = new Zend_Console_Getopt(array('verbose|v' => 'Print verbose output', 'file|f=s' => 'File to upload'));
         $getopt->parse;
         $arguments = $getopt->getRemainingArgs();
     } catch (Zend_Console_Getopt_Exception $e) {
         echo $e->getUsageMessage();
         exit;
     }
     if ($arguments) {
         $command = array_shift($arguments);
         $action = array_shift($arguments);
         if (!preg_match('~\\W~', $command)) {
             $dispatcher->setControllerName($command);
             $dispatcher->setActionName($action);
             $dispatcher->setParams($arguments);
             if (isset($getopt->v)) {
                 $dispatcher->setParam('verbose', true);
             }
             if (isset($getopt->f)) {
                 $dispatcher->setParam('file', $getopt->f);
             }
             return $dispatcher;
         }
         echo "Invalid command.\n", exit;
     }
     echo "No command given.\n", exit;
 }
コード例 #8
0
ファイル: Cli.php プロジェクト: rodrigofns/ExpressoLivre3
 /**
  * import from egroupware
  *
  * @param Zend_Console_Getopt $_opts
  */
 public function importegw14($_opts)
 {
     //$args = $_opts->getRemainingArgs();
     list($host, $username, $password, $dbname, $charset) = $_opts->getRemainingArgs();
     $egwDb = Zend_Db::factory('PDO_MYSQL', array('host' => $host, 'username' => $username, 'password' => $password, 'dbname' => $dbname));
     $egwDb->query("SET NAMES {$charset}");
     $writer = new Zend_Log_Writer_Stream('php://output');
     $logger = new Zend_Log($writer);
     $config = new Zend_Config(array('egwServerTimezone' => 'UTC', 'setPersonalCalendarGrants' => TRUE, 'forcePersonalCalendarGrants' => FALSE));
     $importer = new Calendar_Setup_Import_Egw14($egwDb, $config, $logger);
     $importer->import();
 }
コード例 #9
0
 public function route(Zend_Controller_Request_Abstract $dispatcher)
 {
     $getopt = new Zend_Console_Getopt(array());
     $getopt->addRules(array('controller|c=s' => 'Controller Name', 'action|a=s' => 'Controller Action', 'from|f=s' => 'From yyyy-mm-dd', 'to|t=s' => 'To yyyy-mm-dd'));
     $arguments = $getopt->getRemainingArgs();
     if ($getopt->getOption('controller') && $getopt->getOption('action')) {
         $dispatcher->setControllerName($getopt->getOption('controller'));
         $dispatcher->setActionName($getopt->getOption('action'));
         $dispatcher->setParams(array('from' => $getopt->getOption('from'), 'to' => $getopt->getOption('to')));
         return $dispatcher;
     }
 }
コード例 #10
0
ファイル: Action.php プロジェクト: jorgenils/zend-framework
 public function parse()
 {
     // get actionname from arguments
     if (count($this->_arguments) == 0) {
         return;
     }
     // action name will be a free floating string
     $actionName = array_shift($this->_arguments);
     // check to make sure that the action exists
     if (!($actionContext = $this->_buildManifest->getContext('action', $actionName)) instanceof Zend_Build_Manifest_Context) {
         require_once 'Zend/Tool/Cli/Context/Exception.php';
         throw new Zend_Tool_Cli_Context_Exception('No action context by name ' . $actionName . ' was found in the manifest.');
     }
     $getoptRules = array();
     // get the attributes from this action context
     $actionContextAttrs = $actionContext->getAttributes();
     foreach ($actionContextAttrs as $actionContextAttr) {
         if (isset($actionContextAttr['attributes']['getopt'])) {
             $getoptRules[$actionContextAttr['attributes']['getopt']] = $actionContextAttr['usage'];
         }
     }
     // parse those options out of the arguments array
     $getopt = new Zend_Console_Getopt($getoptRules, $this->_arguments, array('parseAll' => false));
     $getopt->parse();
     // put remaining args into local property
     $this->_arguments = $getopt->getRemainingArgs();
     // get class name
     $actionClassName = $actionContext->getClassName();
     // load appropriate file
     try {
         Zend_Loader::loadClass($actionClassName);
     } catch (Zend_Loader_Exception $e) {
         echo 'couldnt load ' . $actionClassName . PHP_EOL;
     }
     // get actual object for class name
     $this->_action = new $actionClassName();
     // make sure its somewhat sane (implements proper interface)
     if (!$this->_action instanceof Zend_Build_Action_Abstract) {
         echo 'does not implement Zend_Build_Action_Abstract ' . PHP_EOL;
     }
     $parameters = array();
     foreach ($getopt->getOptions() as $getoptParsedOption) {
         $parameters[$getoptParsedOption] = $getopt->getOption($getoptParsedOption);
     }
     $this->_action->setParameters($parameters);
     $this->_action->validate();
     $this->setExecutable();
     return;
     // everything succeeded
 }
コード例 #11
0
 /**
  * exports calendars as ICS
  *
  * @param Zend_Console_Getopt $_opts
  */
 public function exportICS($_opts)
 {
     Tinebase_Core::set('HOSTNAME', 'localhost');
     $opts = $_opts->getRemainingArgs();
     $container_id = $opts[0];
     $filter = new Calendar_Model_EventFilter(array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $container_id)));
     $result = Calendar_Controller_MSEventFacade::getInstance()->search($filter, null, false, false, 'get');
     if ($result->count() == 0) {
         throw new Tinebase_Exception('this calendar does not contain any records.');
     }
     $converter = Calendar_Convert_Event_VCalendar_Factory::factory("generic");
     $result = $converter->fromTine20RecordSet($result);
     print $result->serialize();
 }
コード例 #12
0
ファイル: Application.php プロジェクト: r3wald/trac-cli
 public function parseCommandLine()
 {
     try {
         $opts = new Zend_Console_Getopt(array('development|d' => 'development mode', 'verbose|v' => 'verbose output', 'json|j' => 'JSON output'));
         $opts->parse();
     } catch (Zend_Console_Getopt_Exception $e) {
         echo $e->getUsageMessage();
         exit;
     }
     if ($opts->getOption('d')) {
         $this->_environment = 'development';
     }
     $args = $opts->getRemainingArgs();
     if (count($args) < 1) {
         $args = array('help');
     }
     $this->_controller = array_shift($args);
     if (count($args) < 1) {
         $args = array('help');
     }
     $this->_action = array_shift($args);
     $this->_arguments = $args;
     return $this;
 }
コード例 #13
0
 public function testRemainingArgs()
 {
     $opts = new Zend_Console_Getopt('abp:', array('-a', '--', 'file1', 'file2'));
     $this->assertEquals(implode(',', $opts->getRemainingArgs()), 'file1,file2');
     $opts = new Zend_Console_Getopt('abp:', array('-a', 'file1', 'file2'));
     $this->assertEquals(implode(',', $opts->getRemainingArgs()), 'file1,file2');
 }
コード例 #14
0
 public function parse()
 {
     $endpointRequest = $this->_endpoint->getRequest();
     if ($this->_workingArguments[0] == $_SERVER["SCRIPT_NAME"]) {
         array_shift($this->_workingArguments);
     }
     if (!$this->_parseGlobalPart() || count($this->_workingArguments) == 0) {
         // @todo process global options?
         return;
     }
     $actionName = array_shift($this->_workingArguments);
     // is the action name valid?
     $cliActionNameMetadatas = Zend_Tool_Rpc_Manifest_Registry::getInstance()->getMetadatas(array('type' => 'Action', 'name' => 'cliActionName'));
     foreach ($cliActionNameMetadatas as $cliActionNameMetadata) {
         if ($actionName == $cliActionNameMetadata->getValue()) {
             $action = $cliActionNameMetadata->getReference();
             break;
         }
     }
     $endpointRequest->setActionName($action->getName());
     /* @TODO Action Parameter Requirements */
     if (count($this->_workingArguments) == 0) {
         return;
     }
     if (!$this->_parseActionPart() || count($this->_workingArguments) == 0) {
         return;
     }
     $cliProviderName = array_shift($this->_workingArguments);
     $cliSpecialtyName = '_global';
     if (strstr($cliProviderName, '.')) {
         list($cliProviderName, $cliSpecialtyName) = explode('.', $cliProviderName);
     }
     $cliProviderNameMetadatas = Zend_Tool_Rpc_Manifest_Registry::getInstance()->getMetadatas(array('type' => 'Provider', 'name' => 'cliProviderName'));
     foreach ($cliProviderNameMetadatas as $cliProviderNameMetadata) {
         if ($cliProviderName == $cliProviderNameMetadata->getValue()) {
             $provider = $cliProviderNameMetadata->getReference();
             break;
         }
     }
     $endpointRequest->setProviderName($provider->getName());
     $cliSpecialtyNameMetadatas = Zend_Tool_Rpc_Manifest_Registry::getInstance()->getMetadatas(array('type' => 'Provider', 'providerName' => $provider->getName(), 'name' => 'cliSpecialtyNames'));
     foreach ($cliSpecialtyNameMetadatas as $cliSpecialtyNameMetadata) {
         if ($cliSpecialtyName == $cliSpecialtyNameMetadata->getValue()) {
             $specialtyName = $cliSpecialtyNameMetadata->getSpecialtyName();
             break;
         }
     }
     $endpointRequest->setSpecialtyName($specialtyName);
     $cliActionableMethodLongParameterMetadata = Zend_Tool_Rpc_Manifest_Registry::getInstance()->getMetadata(array('type' => 'Provider', 'providerName' => $provider->getName(), 'actionName' => $action->getName(), 'specialtyName' => $specialtyName, 'name' => 'cliActionableMethodLongParameters'));
     $cliActionableMethodShortParameterMetadata = Zend_Tool_Rpc_Manifest_Registry::getInstance()->getMetadata(array('type' => 'Provider', 'providerName' => $provider->getName(), 'actionName' => $action->getName(), 'specialtyName' => $specialtyName, 'name' => 'cliActionableMethodShortParameters'));
     $cliParameterNameShortValues = $cliActionableMethodShortParameterMetadata->getValue();
     $getoptOptions = array();
     foreach ($cliActionableMethodLongParameterMetadata->getValue() as $parameterNameLong => $cliParameterNameLong) {
         $optionConfig = $cliParameterNameLong . '|';
         $cliActionableMethodReferenceData = $cliActionableMethodLongParameterMetadata->getReference();
         if ($cliActionableMethodReferenceData['type'] == 'string' || $cliActionableMethodReferenceData['type'] == 'bool') {
             $optionConfig .= $cliParameterNameShortValues[$parameterNameLong] . ($cliActionableMethodReferenceData['optional'] ? '-' : '=') . 's';
         } elseif (in_array($cliActionableMethodReferenceData['type'], array('int', 'integer', 'float'))) {
             $optionConfig .= $cliParameterNameShortValues[$parameterNameLong] . ($cliActionableMethodReferenceData['optional'] ? '-' : '=') . 'i';
         } else {
             $optionConfig .= $cliParameterNameShortValues[$parameterNameLong] . '-s';
         }
         $getoptOptions[$optionConfig] = $cliActionableMethodReferenceData['description'] != '' ? $cliActionableMethodReferenceData['description'] : 'No description available.';
     }
     $getoptParser = new Zend_Console_Getopt($getoptOptions, $this->_workingArguments, array('parseAll' => false));
     $getoptParser->parse();
     foreach ($getoptParser->getOptions() as $option) {
         $value = $getoptParser->getOption($option);
         $endpointRequest->setProviderParameter($option, $value);
     }
     /*
     Zend_Debug::dump($getoptParser); 
     Zend_Debug::dump($endpointRequest);
     die();
     */
     $this->_workingArguments = $getoptParser->getRemainingArgs();
     return;
 }
コード例 #15
0
ファイル: GetoptTest.php プロジェクト: travisj/zf
 /**
  * @group ZF-5345
  */
 public function testUsingDashWithoutOptionNameAsLastArgumentIsRecognizedAsRemainingArgument()
 {
     $opts = new Zend_Console_Getopt("abp:", array("-"));
     $opts->parse();
     $this->assertEquals(1, count($opts->getRemainingArgs()));
     $this->assertEquals(array("-"), $opts->getRemainingArgs());
 }
コード例 #16
0
 /**
  * Internal routine for parsing the provider options from the command line
  *
  * @return null
  */
 protected function _parseProviderOptionsPart()
 {
     if (current($this->_argumentsWorking) == '?') {
         $this->_help = true;
         return;
     }
     $searchParams = array('type' => 'Tool', 'providerName' => $this->_request->getProviderName(), 'actionName' => $this->_request->getActionName(), 'specialtyName' => $this->_request->getSpecialtyName(), 'clientName' => 'console');
     $actionableMethodLongParamsMetadata = $this->_manifestRepository->getMetadata(array_merge($searchParams, array('name' => 'actionableMethodLongParams')));
     $actionableMethodShortParamsMetadata = $this->_manifestRepository->getMetadata(array_merge($searchParams, array('name' => 'actionableMethodShortParams')));
     $paramNameShortValues = $actionableMethodShortParamsMetadata->getValue();
     $getoptOptions = array();
     $wordArguments = array();
     $longParamCanonicalNames = array();
     $actionableMethodLongParamsMetadataReference = $actionableMethodLongParamsMetadata->getReference();
     foreach ($actionableMethodLongParamsMetadata->getValue() as $parameterNameLong => $consoleParameterNameLong) {
         $optionConfig = $consoleParameterNameLong . '|';
         $parameterInfo = $actionableMethodLongParamsMetadataReference['parameterInfo'][$parameterNameLong];
         // process ParameterInfo into array for command line option matching
         if ($parameterInfo['type'] == 'string' || $parameterInfo['type'] == 'bool') {
             $optionConfig .= $paramNameShortValues[$parameterNameLong] . ($parameterInfo['optional'] ? '-' : '=') . 's';
         } elseif (in_array($parameterInfo['type'], array('int', 'integer', 'float'))) {
             $optionConfig .= $paramNameShortValues[$parameterNameLong] . ($parameterInfo['optional'] ? '-' : '=') . 'i';
         } else {
             $optionConfig .= $paramNameShortValues[$parameterNameLong] . '-s';
         }
         $getoptOptions[$optionConfig] = $parameterInfo['description'] != '' ? $parameterInfo['description'] : 'No description available.';
         // process ParameterInfo into array for command line WORD (argument) matching
         $wordArguments[$parameterInfo['position']]['parameterName'] = $parameterInfo['name'];
         $wordArguments[$parameterInfo['position']]['optional'] = $parameterInfo['optional'];
         $wordArguments[$parameterInfo['position']]['type'] = $parameterInfo['type'];
         // keep a translation of console to canonical names
         $longParamCanonicalNames[$consoleParameterNameLong] = $parameterNameLong;
     }
     if (!$getoptOptions) {
         // no options to parse here, return
         return;
     }
     // if non-option arguments exist, attempt to process them before processing options
     $wordStack = array();
     while ($wordOnTop = array_shift($this->_argumentsWorking)) {
         if (substr($wordOnTop, 0, 1) != '-') {
             array_push($wordStack, $wordOnTop);
         } else {
             // put word back on stack and move on
             array_unshift($this->_argumentsWorking, $wordOnTop);
             break;
         }
         if (count($wordStack) == count($wordArguments)) {
             // when we get at most the number of arguments we are expecting
             // then break out.
             break;
         }
     }
     if ($wordStack && $wordArguments) {
         for ($wordIndex = 1; $wordIndex <= count($wordArguments); $wordIndex++) {
             if (!array_key_exists($wordIndex - 1, $wordStack) || !array_key_exists($wordIndex, $wordArguments)) {
                 break;
             }
             $this->_request->setProviderParameter($wordArguments[$wordIndex]['parameterName'], $wordStack[$wordIndex - 1]);
             unset($wordStack[$wordIndex - 1]);
         }
     }
     $getoptParser = new Zend_Console_Getopt($getoptOptions, $this->_argumentsWorking, array('parseAll' => false));
     $getoptParser->parse();
     foreach ($getoptParser->getOptions() as $option) {
         $value = $getoptParser->getOption($option);
         $providerParamOption = $longParamCanonicalNames[$option];
         $this->_request->setProviderParameter($providerParamOption, $value);
     }
     $this->_argumentsWorking = $getoptParser->getRemainingArgs();
     return;
 }
コード例 #17
0
ファイル: tenant.php プロジェクト: rubensworks/OpenSKOS
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   OpenSKOS
 * @package    OpenSKOS
 * @copyright  Copyright (c) 2011 Pictura Database Publishing. (http://www.pictura-dp.nl)
 * @author     Mark Lindeman
 * @license    http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
 */
require_once 'Zend/Console/Getopt.php';
$opts = array('help|?' => 'Print this usage message', 'env|e=s' => 'The environment to use (defaults to "production")', 'code=s' => 'Tenant code (required)', 'name=s' => 'Tenant name (required when creating a tenant)', 'email=s' => 'Admin email (required when creating a tenant)', 'password=s' => 'Password for the Admin account');
$OPTS = new Zend_Console_Getopt($opts);
if ($OPTS->help) {
    echo str_replace('[ options ]', '[ options ] action', $OPTS->getUsageMessage());
    exit(0);
}
$args = $OPTS->getRemainingArgs();
if (!$args || count($args) != 1) {
    echo str_replace('[ options ]', '[ options ] action', $OPTS->getUsageMessage());
    fwrite(STDERR, "Expected an actions (create|delete)\n");
    exit(1);
}
$action = $args[0];
$query = $OPTS->query;
if (null === $OPTS->code) {
    fwrite(STDERR, "missing required `code` argument\n");
    exit(1);
}
include 'bootstrap.inc.php';
$model = new OpenSKOS_Db_Table_Tenants();
switch ($action) {
    case 'create':
コード例 #18
0
ファイル: ArgumentParser.php プロジェクト: H38uS/Impulsion
 /**
  * Internal routine for parsing global options from the command line
  *
  * @return null
  */
 protected function _parseGlobalPart()
 {
     $getoptOptions = array();
     $getoptOptions['help|h'] = 'HELP';
     $getoptOptions['verbose|v'] = 'VERBOSE';
     $getoptOptions['pretend|p'] = 'PRETEND';
     $getoptOptions['debug|d'] = 'DEBUG';
     $getoptParser = new Zend_Console_Getopt($getoptOptions, $this->_argumentsWorking, array('parseAll' => false));
     // @todo catch any exceptions here
     $getoptParser->parse();
     foreach ($getoptParser->getOptions() as $option) {
         if ($option == 'pretend') {
             $this->_request->setPretend(true);
         } elseif ($option == 'debug') {
             $this->_request->setDebug(true);
         } elseif ($option == 'verbose') {
             $this->_request->setVerbose(true);
         } else {
             $property = '_' . $option;
             $this->{$property} = true;
         }
     }
     $this->_argumentsWorking = $getoptParser->getRemainingArgs();
     return;
 }
コード例 #19
0
ファイル: runner.php プロジェクト: sasezaki/spizer
    $config = Spizer_Config::load($opts->i, Spizer_Config::INI, $section);
} elseif ($opts->x) {
    if ($opts->i || $opts->y || $opts->p) {
        die_single_configfile();
    }
    $config = Spizer_Config::load($opts->x, Spizer_Config::XML, $section);
} elseif ($opts->p) {
    if ($opts->x || $opts->y || $opts->i) {
        die_single_configfile();
    }
    $config = Spizer_Config::load($opts->p, Spizer_Config::PHP, $section);
} else {
    die_single_configfile();
}
// Make sure we have a URL
$args = $opts->getRemainingArgs();
$url = isset($args[0]) ? $args[0] : $config->url;
if (!$url) {
    spizer_usage();
    exit(1);
}
// Set up engine
$engine = new Spizer_Engine((array) $config->engine);
/**
 * set up next-link
 */
Diggin_Scraper_Helper_Simplexml_Pagerize::setCache($cache = Zend_Cache::factory($config->pagerize->cache->frontend, $config->pagerize->cache->backend, $config->pagerize->cache->frontendOptions->toArray(), $config->pagerize->cache->backendOptions->toArray()));
//siteinfo配列をセットします
Diggin_Scraper_Helper_Simplexml_Pagerize::appendSiteInfo('mysiteinfo', $config->siteinfo->toArray());
//request wedata
if (!($siteinfo = Diggin_Scraper_Helper_Simplexml_Pagerize::loadSiteinfo('wedata'))) {
コード例 #20
0
 /**
  * parses arguments (key1=value1 key2=value2 key3=subvalue1,subvalue2 ...)
  * 
  * @param Zend_Console_Getopt $_opts
  * @param array $_requiredKeys
  * @param string $_otherKey use this key for arguments without '='
  * @throws Tinebase_Exception_InvalidArgument
  * @return array
  */
 protected function _parseArgs(Zend_Console_Getopt $_opts, $_requiredKeys = array(), $_otherKey = 'other')
 {
     $args = $_opts->getRemainingArgs();
     $result = array();
     foreach ($args as $idx => $arg) {
         if (strpos($arg, '=') !== false) {
             list($key, $value) = explode('=', $arg);
             if (strpos($value, ',') !== false) {
                 $value = explode(',', $value);
             }
             $value = str_replace('"', '', $value);
             $result[$key] = $value;
         } else {
             $result[$_otherKey][] = $arg;
         }
     }
     if (!empty($_requiredKeys)) {
         foreach ($_requiredKeys as $requiredKey) {
             if (!array_key_exists($requiredKey, $result)) {
                 throw new Tinebase_Exception_InvalidArgument('Required parameter not found: ' . $requiredKey);
             }
         }
     }
     return $result;
 }
コード例 #21
0
}
if ($opts->getOption('environment') === null) {
    // environment variable not set, falling back to production
    define('APPLICATION_ENV', 'production');
} else {
    define('APPLICATION_ENV', $opts->getOption('environment'));
}
// Create registry object, as read-only object to store there config, settings, and database
$registry = new Zend_Registry(array(), ArrayObject::ARRAY_AS_PROPS);
Zend_Registry::setInstance($registry);
$registry->startTime = $startTime;
// Load configuration settings from application.ini file and store it in registry
$config = new Zend_Config_Ini(CONFIGURATION_PATH . '/application.ini', APPLICATION_ENV);
$registry->configuration = $config;
// Create  connection to database, as singleton , and store it in registry
$db = Zend_Db::factory('Pdo_Mysql', $config->database->params->toArray());
$registry->database = $db;
// Load specific configuration settings from database, and store it in registry
$settings = Dot_Settings::getSettings();
$registry->settings = $settings;
$registry->option = array();
// Set PHP configuration settings from application.ini file
Dot_Settings::setPhpSettings($config->phpSettings->toArray());
// Get the action and the other command line arguments
$registry->action = $opts->getOption('action');
$registry->arguments = $opts->getRemainingArgs();
if ($registry->action === null) {
    echo $opts->getUsageMessage();
    exit;
}
include 'Controller.php';
コード例 #22
0
 /**
  * import from egroupware
  *
  * @param Zend_Console_Getopt $_opts
  */
 public function importegw14($_opts)
 {
     $args = $_opts->getRemainingArgs();
     if (count($args) < 1 || !is_readable($args[0])) {
         echo "can not open config file \n";
         echo "see tine20.org/wiki/EGW_Migration_Howto for details \n\n";
         echo "usage: ./tine20.php --method=Appname.importegw14 /path/to/config.ini  (see Tinebase/Setup/Import/Egw14/config.ini)\n\n";
         exit(1);
     }
     try {
         $config = new Zend_Config_Ini($args[0]);
         if ($config->{strtolower($this->_applicationName)}) {
             $config = $config->{strtolower($this->_applicationName)};
         }
     } catch (Zend_Config_Exception $e) {
         fwrite(STDERR, "Error while parsing config file({$args['0']}) " . $e->getMessage() . PHP_EOL);
         exit(1);
     }
     $writer = new Zend_Log_Writer_Stream('php://output');
     $logger = new Zend_Log($writer);
     $filter = new Zend_Log_Filter_Priority((int) $config->loglevel);
     $logger->addFilter($filter);
     $class_name = $this->_applicationName . '_Setup_Import_Egw14';
     if (!class_exists($class_name)) {
         $logger->ERR(__METHOD__ . '::' . __LINE__ . " no import for {$this->_applicationName} available");
         exit(1);
     }
     try {
         $importer = new $class_name($config, $logger);
         $importer->import();
     } catch (Exception $e) {
         $logger->ERR(__METHOD__ . '::' . __LINE__ . " import for {$this->_applicationName} failed " . $e->getMessage());
     }
 }
コード例 #23
0
ファイル: Cli.php プロジェクト: rodrigofns/ExpressoLivre3
 /**
  * set config
  *
  * @return array
  */
 protected function _setConfig(Zend_Console_Getopt $_opts)
 {
     $options = $this->_parseRemainingArgs($_opts->getRemainingArgs());
     $errors = array();
     if (empty($options['configkey'])) {
         $errors[] = 'Missing argument: configkey';
     }
     if (empty($options['configvalue'])) {
         $errors[] = 'Missing argument: configvalue';
     }
     $configKey = (string) $options['configkey'];
     $configValue = self::parseConfigValue($options['configvalue']);
     if (empty($errors)) {
         Setup_Controller::setConfigOption($configKey, $configValue);
         echo "OK - Updated configuration option {$configKey}\n";
     } else {
         echo "ERRORS - The following errors occured: \n";
         foreach ($errors as $error) {
             echo "- " . $error . "\n";
         }
     }
 }
コード例 #24
0
 /**
  * add new customfield config
  * 
  * needs args like this:
  * application="Addressbook" name="datefield" label="Date" model="Addressbook_Model_Contact" type="datefield"
  * @see Tinebase_Model_CustomField_Config for full list 
  * 
  * @param $_opts
  * @return boolean success
  */
 public function addCustomfield(Zend_Console_Getopt $_opts)
 {
     if (!$this->_checkAdminRight()) {
         return FALSE;
     }
     // parse args
     $args = $_opts->getRemainingArgs();
     $data = array();
     foreach ($args as $idx => $arg) {
         list($key, $value) = explode('=', $arg);
         if ($key == 'application') {
             $key = 'application_id';
             $value = Tinebase_Application::getInstance()->getApplicationByName($value)->getId();
         }
         $data[$key] = $value;
     }
     $customfieldConfig = new Tinebase_Model_CustomField_Config($data);
     $cf = Tinebase_CustomField::getInstance()->addCustomField($customfieldConfig);
     echo "\nCreated customfield: ";
     print_r($cf->toArray());
     echo "\n";
     return TRUE;
 }
コード例 #25
0
 protected function _restore(Zend_Console_Getopt $_opts)
 {
     $options = $this->_parseRemainingArgs($_opts->getRemainingArgs());
     Setup_Controller::getInstance()->restore($options);
 }