/** * Retrieve the frontend object * @return PEAR_Frontend_CLI|PEAR_Frontend_Web|PEAR_Frontend_Gtk * @static */ function &singleton($type = null) { if ($type === null) { if (!isset($GLOBALS['_PEAR_FRONTEND_SINGLETON'])) { $a = false; return $a; } return $GLOBALS['_PEAR_FRONTEND_SINGLETON']; } $a = PEAR_Frontend::setFrontendClass($type); return $a; }
/** * Load current frontend class. * * @param string $uiclass Name of class implementing the frontend * * @return object the frontend object, or a PEAR error * @static */ function &setFrontendClass($uiclass) { $a =& PEAR_Frontend::setFrontendClass($uiclass); return $a; }
/** * 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")); }
} else { $conf_name = 'pear.conf'; } $default_config_dirs = array(substr(dirname(__FILE__), 0, -strlen('PEAR/PEAR')), dirname($_SERVER['SCRIPT_FILENAME']), PEAR_CONFIG_SYSCONFDIR); // set the default: __FILE__ without PEAR/PEAR/ $pear_user_config = $default_config_dirs[0] . DIRECTORY_SEPARATOR . $conf_name; foreach ($default_config_dirs as $confdir) { if (file_exists($confdir . DIRECTORY_SEPARATOR . $conf_name)) { $pear_user_config = $confdir . DIRECTORY_SEPARATOR . $conf_name; break; } } unset($conf_name, $default_config_dirs, $confdir); } // moving this here allows startup messages and errors to work properly PEAR_Frontend::setFrontendClass('PEAR_Frontend_Web'); // Init PEAR Installer Code and WebFrontend $GLOBALS['_PEAR_Frontend_Web_config'] =& PEAR_Config::singleton($pear_user_config, ''); $config =& $GLOBALS['_PEAR_Frontend_Web_config']; $ui =& PEAR_Command::getFrontendObject(); $ui->setConfig($config); PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError")); // Cient requests an Image/Stylesheet/Javascript // outputFrontendFile() does exit() if (isset($_GET["css"])) { $ui->outputFrontendFile($_GET["css"], 'css'); } if (isset($_GET["js"])) { $ui->outputFrontendFile($_GET["js"], 'js'); } if (isset($_GET["img"])) {