本文整理汇总了PHP中PEAR_Frontend类的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Frontend类的具体用法?PHP PEAR_Frontend怎么用?PHP PEAR_Frontend使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PEAR_Frontend类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getConfig
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');
foreach ($config->getKeys() as $key) {
if (!(substr($key, 0, 5) === 'mage_' && substr($key, -4) === '_dir')) {
continue;
}
$config->set($key, preg_replace('#^\\.#', $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;
}
示例2: str_replace
function &setFrontendClass($uiclass)
{
if (is_object($GLOBALS['_PEAR_FRONTEND_SINGLETON']) && is_a($GLOBALS['_PEAR_FRONTEND_SINGLETON'], $uiclass)) {
return $GLOBALS['_PEAR_FRONTEND_SINGLETON'];
}
if (!class_exists($uiclass)) {
$file = str_replace('_', '/', $uiclass) . '.php';
if (PEAR_Frontend::isIncludeable($file)) {
include_once $file;
}
}
if (class_exists($uiclass)) {
$obj =& new $uiclass();
// quick test to see if this class implements a few of the most
// important frontend methods
if (method_exists($obj, 'userConfirm')) {
$GLOBALS['_PEAR_FRONTEND_SINGLETON'] =& $obj;
$GLOBALS['_PEAR_FRONTEND_CLASS'] = $uiclass;
return $obj;
} else {
$err = PEAR::raiseError("not a frontend class: {$uiclass}");
return $err;
}
}
$err = PEAR::raiseError("no such class: {$uiclass}");
return $err;
}
示例3: setUI
function setUI($ui = null)
{
if (!$ui) {
$this->_ui = PEAR_Frontend::singleton();
} else {
$this->_ui = $ui;
}
}
示例4: __construct
/**
* 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"));
}
示例5: PEAR_Frontend_CLI
function PEAR_Frontend_CLI()
{
parent::PEAR();
$term = getenv('TERM');
//(cox) $_ENV is empty for me in 4.1.1
if (function_exists('posix_isatty') && !posix_isatty(1)) {
// output is being redirected to a file or through a pipe
} elseif ($term) {
if (preg_match('/^(xterm|vt220|linux)/', $term)) {
$this->term['bold'] = sprintf("%c%c%c%c", 27, 91, 49, 109);
$this->term['normal'] = sprintf("%c%c%c", 27, 91, 109);
} elseif (preg_match('/^vt100/', $term)) {
$this->term['bold'] = sprintf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0);
$this->term['normal'] = sprintf("%c%c%c%c%c", 27, 91, 109, 0, 0);
}
} elseif (OS_WINDOWS) {
// XXX add ANSI codes here
}
}
示例6: init
function init(&$config, &$pkg, $lastversion)
{
$this->_config =& $config;
$this->_registry =& $config->getRegistry();
$this->_ui =& PEAR_Frontend::singleton();
$this->_pkg =& $pkg;
$this->_lastversion = $lastversion;
$this->_wwwDirectory = $this->_config->get('www_dir');
if ($this->_wwwDirectory === false || !file_exists($this->_wwwDirectory)) {
$this->_ui->log("Failed to find a web directory {$this->_wwwDirectory}");
return false;
}
$sfile = $this->_wwwDirectory . DIRECTORY_SEPARATOR . 'LocalSettings.php.sample';
$this->contents = file_get_contents($sfile, true);
if ($this->contents === false) {
$this->_ui->log("Failed to load '{$sfile}'");
return false;
}
$this->_ui->log("Loaded '{$sfile}'");
return true;
}
示例7: listAll
function listAll($base, $dostable, $basic = true, $searchpackage = false, $searchsummary = false)
{
$packagelist = $this->_rest->retrieveData($base . 'p/packages.xml');
if (PEAR::isError($packagelist)) {
return $packagelist;
}
if ($this->_rest->config->get('verbose') > 0) {
$ui =& PEAR_Frontend::singleton();
$ui->log('Retrieving data...0%', false);
}
$ret = array();
if (!is_array($packagelist) || !isset($packagelist['p'])) {
return $ret;
}
if (!is_array($packagelist['p'])) {
$packagelist['p'] = array($packagelist['p']);
}
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$next = 0.1;
foreach ($packagelist['p'] as $progress => $package) {
if ($this->_rest->config->get('verbose') > 0) {
if ($progress / count($packagelist['p']) >= $next) {
if ($next == 0.5) {
$ui->log('50%', false);
} else {
$ui->log('.', false);
}
$next += 0.1;
}
}
if ($basic) {
// remote-list command
if ($dostable) {
$latest = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . '/stable.txt');
} else {
$latest = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . '/latest.txt');
}
if (PEAR::isError($latest)) {
$latest = false;
}
$info = array('stable' => $latest);
} else {
// list-all command
$inf = $this->_rest->retrieveData($base . 'p/' . strtolower($package) . '/info.xml');
if (PEAR::isError($inf)) {
PEAR::popErrorHandling();
return $inf;
}
if ($searchpackage) {
$found = !empty($searchpackage) && stristr($package, $searchpackage) !== false;
if (!$found && !(isset($searchsummary) && !empty($searchsummary) && (stristr($inf['s'], $searchsummary) !== false || stristr($inf['d'], $searchsummary) !== false))) {
continue;
}
}
$releases = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . '/allreleases.xml');
if (PEAR::isError($releases)) {
continue;
}
if (!isset($releases['r'][0])) {
$releases['r'] = array($releases['r']);
}
unset($latest);
unset($unstable);
unset($stable);
unset($state);
foreach ($releases['r'] as $release) {
if (!isset($latest)) {
if ($dostable && $release['s'] == 'stable') {
$latest = $release['v'];
$state = 'stable';
}
if (!$dostable) {
$latest = $release['v'];
$state = $release['s'];
}
}
if (!isset($stable) && $release['s'] == 'stable') {
$stable = $release['v'];
if (!isset($unstable)) {
$unstable = $stable;
}
}
if (!isset($unstable) && $release['s'] != 'stable') {
$latest = $unstable = $release['v'];
$state = $release['s'];
}
if (isset($latest) && !isset($state)) {
$state = $release['s'];
}
if (isset($latest) && isset($stable) && isset($unstable)) {
break;
}
}
$deps = array();
if (!isset($unstable)) {
$unstable = false;
$state = 'stable';
if (isset($stable)) {
$latest = $unstable = $stable;
}
//.........这里部分代码省略.........
示例8: runPostinstallScripts
function runPostinstallScripts()
{
if ($this->initPostinstallScripts()) {
$ui =& PEAR_Frontend::singleton();
if ($ui) {
$ui->runPostinstallScripts($this->_scripts, $this);
}
}
}
示例9: array
// extreme debugging
exit;
}
}
// end print
$php_dir = $config->get('php_dir');
$options = array();
$options['upgrade'] = true;
$install_root = getenv('INSTALL_ROOT');
if (!empty($install_root)) {
$options['packagingroot'] = $install_root;
$reg =& new PEAR_Registry($options['packagingroot'], false, false, $metadata_dir);
} else {
$reg = $config->getRegistry('default');
}
$ui = PEAR_Frontend::singleton('PEAR_Frontend_CLI');
if (PEAR::isError($ui)) {
die($ui->getMessage());
}
$installer = new PEAR_Installer($ui);
$pkg = new PEAR_PackageFile($config, $debug);
foreach ($install_files as $package => $instfile) {
$info = $pkg->fromAnyFile($instfile, PEAR_VALIDATE_INSTALLING);
if (PEAR::isError($info)) {
if (is_array($info->getUserInfo())) {
foreach ($info->getUserInfo() as $err) {
$ui->outputData(sprintf("[PEAR] %s: %s", $package, $err['message']));
}
}
$ui->outputData(sprintf("[PEAR] %s: %s", $package, $info->getMessage()));
continue;
示例10: initializeFrontend
/**
* Initializes the PEAR Frontend instance.
*/
protected function initializeFrontend()
{
$this->frontend = PEAR_Frontend::singleton('sfPearFrontendPlugin');
if (PEAR::isError($this->frontend)) {
throw new sfPluginException(sprintf('Unable to initialize PEAR Frontend object: %s', $this->frontend->getMessage()));
}
$this->frontend->setEventDispatcher($this->dispatcher);
}
示例11: log
/**
* Logging method.
*
* @param int $level log level (0 is quiet, higher is noisier)
* @param string $msg message to write to the log
*
* @return void
*
* @access public
* @static
*/
function log($level, $msg, $append_crlf = true)
{
if ($this->debug >= $level) {
$ui =& PEAR_Frontend::singleton();
if (is_a($ui, 'PEAR_Frontend')) {
$ui->log($msg, $append_crlf);
} else {
print "{$msg}\n";
}
}
}
示例12:
/**
* 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;
}
示例13: _addPackage2
/**
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
* @return bool
* @access private
*/
function _addPackage2($info)
{
if (!is_a($info, 'PEAR_PackageFile_v1') && !is_a($info, 'PEAR_PackageFile_v2')) {
return false;
}
if (!$info->validate()) {
if (class_exists('PEAR_Common')) {
$ui = PEAR_Frontend::singleton();
if ($ui) {
foreach ($info->getValidationWarnings() as $err) {
$ui->log($err['message'], true);
}
}
}
return false;
}
$channel = $info->getChannel();
$package = $info->getPackage();
$save = $info;
if ($this->_packageExists($package, $channel)) {
return false;
}
if (!$this->_channelExists($channel, true)) {
return false;
}
$info = $info->toArray(true);
if (!$info) {
return false;
}
$fp = $this->_openPackageFile($package, 'wb', $channel);
if ($fp === null) {
return false;
}
$info['_lastmodified'] = time();
fwrite($fp, serialize($info));
$this->_closePackageFile($fp);
$this->_rebuildFileMap();
return true;
}
示例14: main
/**
* Main entry point for d51pearpkg2 task
*/
public function main()
{
PEAR_Frontend::setFrontendObject(new d51PearPkg2Task_Frontend($this));
$package = new PEAR_PackageFileManager2();
$this->_initOptions();
$a = $package->setOptions($this->_options);
if (PEAR::isError($a)) {
$this->log($a->getMessage(), Project::MSG_ERR);
exit(-1);
}
$package->setPackage((string) $this->_name);
$package->setSummary((string) $this->_summary);
$desc = preg_replace("/^({$this->_description->indention_type}{{$this->_description->indentions_to_remove}}|\t)+/m", '', (string) $this->_description);
$package->setDescription($desc);
$package->setChannel((string) $this->_channel);
$package->setAPIVersion($this->_version->api);
$package->setReleaseVersion($this->_version->release);
$package->setAPIStability($this->_stability->api);
$package->setReleaseStability($this->_stability->release);
// TODO: allow different types
$package->setPackageType($this->_type);
$package->addRelease();
if (!is_null($this->_dependencies->php)) {
$this->log('Using explicit PHP minimum version: ' . $this->_dependencies->php->minimum_version);
$package->setPhpDep($this->_dependencies->php->minimum_version);
} else {
$this->log('Using current PHP version as minimum: ' . phpversion());
$package->setPhpDep(phpversion());
}
if (!is_null($this->_dependencies->pear)) {
$this->log('setting minimum PEAR version: ' . $this->_dependencies->pear->minimum_version);
$package->setPearinstallerDep($this->_dependencies->pear->minimum_version, $this->_dependencies->pear->maximum_version, $this->_dependencies->pear->recommended_version, $this->_dependencies->pear->exclude_version);
} else {
$this->log('setting minimum PEAR version to currently installed version');
$pear_version = PEAR_Config::singleton()->getRegistry()->packageInfo('PEAR', 'version');
$this->log('minimum PEAR version: ' . $pear_version);
$package->setPearinstallerDep(PEAR_Config::singleton()->getRegistry()->packageInfo('PEAR', 'version'));
}
foreach ($this->_maintainers as $maintainer) {
$this->log("adding maintainer [{$maintainer->user}/{$maintainer->name}] with role [{$maintainer->role}]");
$package->addMaintainer($maintainer->role, $maintainer->user, $maintainer->name, $maintainer->email, $maintainer->active);
}
// handle dependencies
if (!empty($this->_dependencies)) {
$this->log('adding dependencies');
if (count($this->_dependencies->groups) > 0) {
$this->log('found dependency groups');
foreach ($this->_dependencies->groups as $group) {
$this->log("adding [{$group->name}] :: [{$group->hint}]");
$package->addDependencyGroup($group->name, $group->hint);
foreach ($group->packages as $sub_package) {
$package->addGroupPackageDepWithChannel('subpackage', $group->name, $sub_package->name, $sub_package->channel, '0.0.1');
}
}
}
if (count($this->_dependencies->packages) > 0) {
$this->log('found dependencies');
foreach ($this->_dependencies->packages as $dependency) {
$this->log("adding following dependency: {$dependency->channel}/{$dependency->name}");
$package->addPackageDepWithChannel($dependency->type, $dependency->name, $dependency->channel, $dependency->minimum_version, $dependency->maximum_version, $dependency->recommended_version, $dependency->exclude_version, $dependency->providesextension, $dependency->nodefault);
}
}
if (count($this->_dependencies->extensions) > 0) {
$this->log('adding extension dependencies');
foreach ($this->_dependencies->extensions as $extension) {
$this->log("adding ext dependency for: {$extension->name}");
$package->addExtensionDep($extension->type, $extension->name, $extension->minimum_version, $extension->maximum_version, $extension->recommended_version, $extension->extension);
}
}
}
foreach ($this->_changelogs as $changelog) {
$this->log("adding changelog for prior release [{$changelog->version}]");
$changelog->package = $package;
$package->setChangelogEntry($changelog->version, $changelog->toArray());
if (is_null($this->_notes) && $package->getVersion() == $changelog->version) {
$this->log("no package notes specified, using changelog entry");
$this->_notes = $changelog->contents;
}
}
foreach ($this->_replacements as $replacement) {
$replacement->isValid();
$this->log("adding replace from [{$replacement->from}] to [{$replacement->to}]");
$package->addReplacement($replacement->path, $replacement->type, $replacement->from, $replacement->to);
}
foreach ($this->_releases as $release) {
$this->log('adding new release');
$package->addRelease();
foreach ($release->install as $install) {
$this->log("installing [{$install->name}] as [{$install->as}]");
$package->addInstallAs($install->name, $install->as);
}
}
$notes = preg_replace("/^( {4}|\t)+/m", '', (string) $this->_notes);
$package->setNotes($notes);
$package->setLicense($this->_license->license, $this->_license->uri);
$package->generateContents();
$e = $package->writePackageFile();
//.........这里部分代码省略.........
示例15: nativePearInstall
private function nativePearInstall($package, $channel)
{
if (!class_exists('PEAR_Command')) {
@(include 'PEAR/command.php');
// loads frontend, among other things
if (!class_exists('PEAR_Command')) {
throw new pakeException('PEAR subsystem is unavailable (not in include_path?)');
}
}
$front = PEAR_Frontend::singleton('PEAR_Frontend_CLI');
$cfg = PEAR_Config::singleton();
$cmd = PEAR_Command::factory('install', $cfg);
ob_start();
$result = $cmd->doInstall('install', array(), array($channel . '/' . $package));
ob_end_clean();
// we don't need output
if ($result instanceof PEAR_Error) {
throw new pakeException($result->getMessage());
}
}