/** * Compiles arguments for getopt. * * @param string $command command to get optstring for * @param string $short_args (reference) short getopt format * @param array $long_args (reference) long getopt format * * @return void * * @access public * @static */ function getGetoptArgs($command, &$short_args, &$long_args) { if (empty($GLOBALS['_PEAR_Command_commandlist'])) { PEAR_Command::registerCommands(); } if (isset($GLOBALS['_PEAR_Command_shortcuts'][$command])) { $command = $GLOBALS['_PEAR_Command_shortcuts'][$command]; } if (!isset($GLOBALS['_PEAR_Command_commandlist'][$command])) { return null; } $obj =& PEAR_Command::getObject($command); return $obj->getGetoptArgs($command, $short_args, $long_args); }
/** * Compiles arguments for getopt. * * @param string $command command to get optstring for * @param string $short_args (reference) short getopt format * @param array $long_args (reference) long getopt format * * @return void * * @access public * @static */ function getGetoptArgs($command, &$short_args, &$long_args) { if (empty($GLOBALS['_PEAR_Command_commandlist'])) { PEAR_Command::registerCommands(); } if (!isset($GLOBALS['_PEAR_Command_commandlist'][$command])) { return null; } $class = $GLOBALS['_PEAR_Command_commandlist'][$command]; $obj =& $GLOBALS['_PEAR_Command_objects'][$class]; return $obj->getGetoptArgs($command, $short_args, $long_args); }
public function getConfig() { if (!$this->_config) { $pear_dir = $this->getPearDir(); $config = PEAR_Config::singleton($pear_dir . DS . 'pear.ini', '-'); $config->set('auto_discover', 1); $config->set('cache_ttl', 60); #$config->set('preferred_state', 'beta'); $config->set('bin_dir', $pear_dir); $config->set('php_dir', $pear_dir . DS . 'php'); $config->set('download_dir', $pear_dir . DS . 'download'); $config->set('temp_dir', $pear_dir . DS . 'temp'); $config->set('data_dir', $pear_dir . DS . 'data'); $config->set('cache_dir', $pear_dir . DS . 'cache'); $config->set('test_dir', $pear_dir . DS . 'tests'); $config->set('doc_dir', $pear_dir . DS . 'docs'); $mageDir = $config->get('mage_dir'); foreach ($config->getKeys() as $key) { if (!(substr($key, 0, 5) === 'mage_' && substr($key, -4) === '_dir')) { continue; } $config->set($key, preg_replace('#^' . preg_quote($mageDir) . '#', $this->getBaseDir(), $config->get($key))); #echo $key.' : '.$config->get($key).'<br>'; } $reg = $this->getRegistry(); $config->setRegistry($reg); PEAR_DependencyDB::singleton($config, $pear_dir . DS . 'php' . DS . '.depdb'); PEAR_Frontend::setFrontendObject($this->getFrontend()); PEAR_Command::registerCommands(false, $pear_dir . DS . 'php' . DS . 'PEAR' . DS . 'Command' . DS); $this->_config = $config; } return $this->_config; }
/** * Private constructor to initialize the instance * with the necessary data. * * @param string $baseDir The Magento base directory * @return void */ public function __construct($baseDir) { // check if the passed Magento base directory exists if (!is_dir($baseDir)) { throw new Exception('Magento base directory ' . $baseDir . ' doesn\'t exists'); } // load the PEAR directory for the Magento channel $pearDir = $baseDir . DS . 'downloader' . DS . 'pearlib'; // check if the Magento PEAR directory exists if (!is_dir($pearDir)) { throw new Exception('Magento PEAR base directory ' . $pearDir . ' doesn\'t exists'); } // load the registry $this->_registry = new PEAR_Registry($pearDir . DS . 'php'); // initialize the configuration with the channels configuration file $this->_config = PEAR_Config::singleton($pearDir . DS . 'pear.ini', '-'); // overwrite the configuration values $this->_config->set('auto_discover', 1); $this->_config->set('cache_ttl', 60); $this->_config->set('preferred_state', 'alpha'); $this->_config->set('bin_dir', $pearDir); $this->_config->set('php_dir', $pearDir . DS . 'php'); $this->_config->set('download_dir', $pearDir . DS . 'download'); $this->_config->set('temp_dir', $pearDir . DS . 'temp'); $this->_config->set('data_dir', $pearDir . DS . 'data'); $this->_config->set('cache_dir', $pearDir . DS . 'cache'); $this->_config->set('test_dir', $pearDir . DS . 'tests'); $this->_config->set('doc_dir', $pearDir . DS . 'docs'); // initialize the Magento specific settings foreach ($this->_config->getKeys() as $key) { if (!(substr($key, 0, 5) === 'mage_' && substr($key, -4) === '_dir')) { continue; } $this->_config->set($key, preg_replace('#^\\.#', addslashes(Mage::getBaseDir()), $this->_config->get($key))); } // set the registry $this->_config->setRegistry($this->_registry); // initialize the dependeny database PEAR_DependencyDB::singleton($this->_config, $pearDir . DS . 'php' . DS . '.depdb'); // register the commands, including the one for Magento PEAR_Command::registerCommands(true, $pearDir . DS . 'php' . DS . 'PEAR' . DS . 'Command' . DS); // initialize the PEAR frontend PEAR_Frontend::setFrontendClass('Faett_Core_Frontend_PEAR'); $this->_ui = PEAR_Command::getFrontendObject(); $this->_ui->setConfig($this->_config); // set the callback for rendering the messages PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this->_ui, "log")); }