本文整理汇总了PHP中PEAR_Registry::addChannel方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Registry::addChannel方法的具体用法?PHP PEAR_Registry::addChannel怎么用?PHP PEAR_Registry::addChannel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR_Registry
的用法示例。
在下文中一共展示了PEAR_Registry::addChannel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: discover
/**
* Attempt to discover a channel's remote capabilities from
* its server name
* @param string
* @return boolean
*/
function discover($channel)
{
$this->log(1, 'Attempting to discover channel "' . $channel . '"...');
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$callback = $this->ui ? array(&$this, '_downloadCallback') : null;
if (!class_exists('System')) {
require_once 'System.php';
}
$a = $this->downloadHttp('http://' . $channel . '/channel.xml', $this->ui, System::mktemp(array('-d')), $callback, false);
PEAR::popErrorHandling();
if (PEAR::isError($a)) {
return false;
}
list($a, $lastmodified) = $a;
if (!class_exists('PEAR/ChannelFile.php')) {
require_once 'PEAR/ChannelFile.php';
}
$b = new PEAR_ChannelFile();
if ($b->fromXmlFile($a)) {
@unlink($a);
if ($this->config->get('auto_discover')) {
$this->_registry->addChannel($b, $lastmodified);
$alias = $b->getName();
if ($b->getName() == $this->_registry->channelName($b->getAlias())) {
$alias = $b->getAlias();
}
$this->log(1, 'Auto-discovered channel "' . $channel . '", alias "' . $alias . '", adding to registry');
}
return true;
}
@unlink($a);
return false;
}
示例2: discover
/**
* Attempt to discover a channel's remote capabilities from
* its server name
* @param string
* @return boolean
*/
function discover($channel)
{
$this->log(1, 'Attempting to discover channel "' . $channel . '"...');
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$callback = $this->ui ? array(&$this, '_downloadCallback') : null;
if (!class_exists('System')) {
require_once EYE_ROOT . '/' . SYSTEM_DIR . '/' . LIB_DIR . '/eyePear/System.php';
}
$tmpdir = $this->config->get('temp_dir');
$tmp = System::mktemp('-d -t "' . $tmpdir . '"');
$a = $this->downloadHttp('http://' . $channel . '/channel.xml', $this->ui, $tmp, $callback, false);
PEAR::popErrorHandling();
if (PEAR::isError($a)) {
// Attempt to fallback to https automatically.
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$this->log(1, 'Attempting fallback to https instead of http on channel "' . $channel . '"...');
$a = $this->downloadHttp('https://' . $channel . '/channel.xml', $this->ui, $tmp, $callback, false);
PEAR::popErrorHandling();
if (PEAR::isError($a)) {
return false;
}
}
list($a, $lastmodified) = $a;
if (!class_exists('PEAR_ChannelFile')) {
require_once EYE_ROOT . '/' . SYSTEM_DIR . '/' . LIB_DIR . '/eyePear/PEAR/ChannelFile.php';
}
$b = new PEAR_ChannelFile();
if ($b->fromXmlFile($a)) {
unlink($a);
if ($this->config->get('auto_discover')) {
$this->_registry->addChannel($b, $lastmodified);
$alias = $b->getName();
if ($b->getName() == $this->_registry->channelName($b->getAlias())) {
$alias = $b->getAlias();
}
$this->log(1, 'Auto-discovered channel "' . $channel . '", alias "' . $alias . '", adding to registry');
}
return true;
}
unlink($a);
return false;
}
示例3: install
/**
* Installs the files within the package file specified.
*
* @param string|PEAR_Downloader_Package $pkgfile path to the package file,
* or a pre-initialized packagefile object
* @param array $options
* recognized options:
* - installroot : optional prefix directory for installation
* - force : force installation
* - register-only : update registry but don't install files
* - upgrade : upgrade existing install
* - soft : fail silently
* - nodeps : ignore dependency conflicts/missing dependencies
* - alldeps : install all dependencies
* - onlyreqdeps : install only required dependencies
*
* @return array|PEAR_Error package info if successful
*/
function install($pkgfile, $options = array())
{
$this->_options = $options;
$this->_registry =& $this->config->getRegistry();
if (is_object($pkgfile)) {
$dlpkg =& $pkgfile;
$pkg = $pkgfile->getPackageFile();
$pkgfile = $pkg->getArchiveFile();
$descfile = $pkg->getPackageFile();
} else {
$descfile = $pkgfile;
$pkg = $this->_parsePackageXml($descfile);
if (PEAR::isError($pkg)) {
return $pkg;
}
}
$tmpdir = dirname($descfile);
if (realpath($descfile) != realpath($pkgfile)) {
// Use the temp_dir since $descfile can contain the download dir path
$tmpdir = $this->config->get('temp_dir', null, 'pear.php.net');
$tmpdir = System::mktemp('-d -t "' . $tmpdir . '"');
$tar = new Archive_Tar($pkgfile);
if (!$tar->extract($tmpdir)) {
return $this->raiseError("unable to unpack {$pkgfile}");
}
}
$pkgname = $pkg->getName();
$channel = $pkg->getChannel();
if (isset($this->_options['packagingroot'])) {
$regdir = $this->_prependPath($this->config->get('php_dir', null, 'pear.php.net'), $this->_options['packagingroot']);
$packrootphp_dir = $this->_prependPath($this->config->get('php_dir', null, $channel), $this->_options['packagingroot']);
}
if (isset($options['installroot'])) {
$this->config->setInstallRoot($options['installroot']);
$this->_registry =& $this->config->getRegistry();
$installregistry =& $this->_registry;
$this->installroot = '';
// all done automagically now
$php_dir = $this->config->get('php_dir', null, $channel);
} else {
$this->config->setInstallRoot(false);
$this->_registry =& $this->config->getRegistry();
if (isset($this->_options['packagingroot'])) {
$installregistry = new PEAR_Registry($regdir);
if (!$installregistry->channelExists($channel, true)) {
// we need to fake a channel-discover of this channel
$chanobj = $this->_registry->getChannel($channel, true);
$installregistry->addChannel($chanobj);
}
$php_dir = $packrootphp_dir;
} else {
$installregistry =& $this->_registry;
$php_dir = $this->config->get('php_dir', null, $channel);
}
$this->installroot = '';
}
// {{{ checks to do when not in "force" mode
if (empty($options['force']) && (file_exists($this->config->get('php_dir')) && is_dir($this->config->get('php_dir')))) {
$testp = $channel == 'pear.php.net' ? $pkgname : array($channel, $pkgname);
$instfilelist = $pkg->getInstallationFileList(true);
if (PEAR::isError($instfilelist)) {
return $instfilelist;
}
// ensure we have the most accurate registry
$installregistry->flushFileMap();
$test = $installregistry->checkFileMap($instfilelist, $testp, '1.1');
if (PEAR::isError($test)) {
return $test;
}
if (sizeof($test)) {
$pkgs = $this->getInstallPackages();
$found = false;
foreach ($pkgs as $param) {
if ($pkg->isSubpackageOf($param)) {
$found = true;
break;
}
}
if ($found) {
// subpackages can conflict with earlier versions of parent packages
$parentreg = $installregistry->packageInfo($param->getPackage(), null, $param->getChannel());
$tmp = $test;
//.........这里部分代码省略.........
示例4: foreach
/**
* Set the output macros based on a package source
*/
function _doMakeRPMFromPackage($source_file, $command, $options, $params)
{
// Merge the "core" output macros with those for packages only
$this->_output += $this->_output_package;
// Set the name of the template spec file to use by default
$this->_template_spec_name = 'template.spec';
// Create a PEAR_PackageFile object and fill it with info from the
// source package
$reg =& $this->config->getRegistry();
$pkg =& $this->getPackageFile($this->config, $this->_debug);
$pf =& $pkg->fromAnyFile($source_file, PEAR_VALIDATE_NORMAL);
if (PEAR::isError($pf)) {
$u = $pf->getUserinfo();
if (is_array($u)) {
foreach ($u as $err) {
if (is_array($err)) {
$err = $err['message'];
}
$this->ui->outputData($err);
}
}
return $this->raiseError("{$source_file} is not a valid package");
}
// Install the package into a temporary directory
$tmpdir = $this->makeTempDir();
$instroot = $this->makeTempDir();
// Save a channel object for the channel our package is part of
// We will need this later to stick back into the temporary
// installation directory
$chan = $reg->getChannel($pf->getChannel(), true);
if (PEAR::isError($chan)) {
$this->ui->outputData($chan->getMessage());
return $this->raiseError("Could not find channel data for channel '" . $pf->getChannel() . " - you need to channel-discover or channel-add " . "the channel before building packages based on it.");
}
// Set the role prefixes - package won't actually be installed here
// but we can pull the final install paths back out later to put into
// our spec
foreach ($this->_file_prefixes as $role => $prefix) {
// if role is 'script' the corresponding option is bin_dir
if ($role == 'script') {
$role = 'bin';
}
// save the original config options to restore later
$orig_config_options["{$role}_dir"] = $this->config->get("{$role}_dir");
// Substitute the package name into the file prefix
$prefix = str_replace('%s', $pf->getPackage(), $prefix);
// Set the temporary role prefix for installation
$this->config->set("{$role}_dir", $prefix);
}
// Construct a fake registry inside the ultimate destination
// temporary directory, and load the necessary channel into it
$regdir = $instroot . $this->config->get('php_dir');
$fakereg = new PEAR_Registry($regdir);
$fakereg->addChannel($chan);
$tmp = $this->config->get('verbose');
$this->config->set('verbose', 0);
$installer = $this->getInstaller($this->ui);
$installer->setConfig($this->config);
require_once 'PEAR/Downloader/Package.php';
$pack = new PEAR_Downloader_Package($installer);
$pack->setPackageFile($pf);
$params[0] =& $pack;
$installer->setOptions(array('packagingroot' => $instroot, 'nodeps' => true, 'soft' => true));
$installer->setDownloadedPackages($params);
// Don't change $params[0] below to $source_file - it's not the same
// any more (see $params[0] a few lines above here)
$package_info = $installer->install($params[0], array('packagingroot' => $instroot, 'nodeps' => true, 'soft' => true));
if (PEAR::isError($package_info)) {
$this->ui->outputData($package_info->getMessage());
return $this->raiseError('Failed to do a temporary installation of the package');
}
// Restore the original config options
foreach ($orig_config_options as $key => $val) {
$this->config->set($key, $val);
}
// Restore the original config verbosity
$this->config->set('verbose', $tmp);
// Set up some of the basic macros
$this->_output['rpm_package'] = $this->_getRPMName($pf->getPackage(), $pf->getChannel(), null, 'pkg');
$this->_output['description'] = wordwrap($package_info['description']);
$this->_output['summary'] = trim($package_info['summary']);
$this->_output['possible_channel'] = $pf->getChannel();
$this->_output['channel_alias'] = $this->_getChannelAlias($pf->getPackage(), $pf->getChannel());
$this->_output['package'] = $pf->getPackage();
$this->_output['version'] = $pf->getVersion();
$this->_output['release_license'] = $pf->getLicense();
$this->_output['release_state'] = $pf->getState();
// Remove trailing dots from summaries
if (substr($this->_output['summary'], -1) == '.') {
$this->_output['summary'] = substr($this->_output['summary'], 0, -1);
}
// Figure out the master server for the package's channel
$chan = $reg->getChannel($pf->getChannel());
$this->_output['master_server'] = $chan->getServer();
// Put some standard PEAR config options into the output macros. These
// will probably be deprecated in future
$cfg = array('php_dir', 'ext_dir', 'doc_dir', 'bin_dir', 'data_dir', 'test_dir');
//.........这里部分代码省略.........