本文整理汇总了PHP中PEAR_ChannelFile类的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_ChannelFile类的具体用法?PHP PEAR_ChannelFile怎么用?PHP PEAR_ChannelFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PEAR_ChannelFile类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preExecute
public function preExecute()
{
error_reporting(error_reporting() & ~(E_STRICT | E_DEPRECATED));
foreach (array('channel_name', 'summary', 'suggestedalias') as $v) {
$this->{$v} = Doctrine::getTable('SnsConfig')->get(opPluginChannelServerPluginConfiguration::CONFIG_KEY_PREFIX . $v, str_replace(':80', '', $this->getRequest()->getHost()));
}
require_once 'PEAR.php';
require_once 'PEAR/Common.php';
require_once 'PEAR/ChannelFile.php';
$baseUrl = 'http://' . $this->channel_name . 'pluginRest/';
$channel = new PEAR_ChannelFile();
$channel->setName($this->channel_name);
$channel->setSummary($this->summary);
$channel->setAlias($this->suggestedalias);
$channel->setBaseURL('REST1.0', $baseUrl);
$channel->setBaseURL('REST1.1', $baseUrl);
$channel->setBaseURL('REST1.2', $baseUrl);
$channel->setBaseURL('REST1.3', $baseUrl);
$registry = new PEAR_Registry(sfConfig::get('sf_cache_dir'), $channel);
$this->pear = new PEAR_Common();
$this->pear->config->setRegistry($registry);
if (!$registry->channelExists($channel->getName())) {
$registry->addChannel($channel);
} else {
$registry->updateChannel($channel);
}
}
示例2: getChannel
protected function getChannel()
{
$host = sfContext::getInstance()->getRequest()->getHost();
$serverName = opPluginChannelServerToolkit::getConfig('server_name', str_replace(':80', '', $host));
$browser = new opBrowser($serverName);
$browser->get('/channel.xml');
$channel = new PEAR_ChannelFile();
$channel->fromXmlString($browser->getResponse()->getContent());
$channel->setName($serverName);
return $channel;
}
示例3: generatePearChannelFile
public static function generatePearChannelFile($channelName, $summary, $alias, $baseUrl)
{
error_reporting(error_reporting() & ~(E_STRICT | E_DEPRECATED));
require_once 'PEAR.php';
require_once 'PEAR/Common.php';
require_once 'PEAR/ChannelFile.php';
$channel = new PEAR_ChannelFile();
$channel->setName($channelName);
$channel->setSummary($summary);
$channel->setAlias($alias);
$channel->setBaseURL('REST1.0', $baseUrl);
$channel->setBaseURL('REST1.1', $baseUrl);
$channel->setBaseURL('REST1.2', $baseUrl);
$channel->setBaseURL('REST1.3', $baseUrl);
return $channel;
}
示例4: parse
function parse($data, $file)
{
if (PEAR::isError($err = parent::parse($data, $file))) {
return $err;
}
$ret = new PEAR_ChannelFile();
$ret->setConfig($this->_config);
if (isset($this->_logger)) {
$ret->setLogger($this->_logger);
}
$ret->fromArray($this->_unserializedData);
// make sure the filelist is in the easy to read format needed
$ret->flattenFilelist();
$ret->setPackagefile($file, $archive);
return $ret;
}
示例5: 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';
}
$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 '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;
}
示例6: foreach
/**
* @param string channel name
* @param bool whether to strictly retrieve channel names
* @return PEAR_ChannelFile|PEAR_Error
* @access private
*/
function &_getChannel($channel, $noaliases = false)
{
$ch = false;
if ($this->_channelExists($channel, $noaliases)) {
$chinfo = $this->_channelInfo($channel, $noaliases);
if ($chinfo) {
if (!class_exists('PEAR_ChannelFile')) {
require_once 'PEAR/ChannelFile.php';
}
$ch =& PEAR_ChannelFile::fromArrayWithErrors($chinfo);
}
}
if ($ch) {
if ($ch->validate()) {
return $ch;
}
foreach ($ch->getErrors(true) as $err) {
$message = $err['message'] . "\n";
}
$ch = PEAR::raiseError($message);
return $ch;
}
if ($this->_getChannelFromAlias($channel) == 'pear.php.net') {
// the registry is not properly set up, so use defaults
if (!class_exists('PEAR_ChannelFile')) {
require_once 'PEAR/ChannelFile.php';
}
$pear_channel = new PEAR_ChannelFile();
$pear_channel->setServer('pear.php.net');
$pear_channel->setAlias('pear');
$pear_channel->setSummary('PHP Extension and Application Repository');
$pear_channel->setDefaultPEARProtocols();
$pear_channel->setBaseURL('REST1.0', 'http://pear.php.net/rest/');
$pear_channel->setBaseURL('REST1.1', 'http://pear.php.net/rest/');
$pear_channel->setBaseURL('REST1.3', 'http://pear.php.net/rest/');
return $pear_channel;
}
if ($this->_getChannelFromAlias($channel) == 'pecl.php.net') {
// the registry is not properly set up, so use defaults
if (!class_exists('PEAR_ChannelFile')) {
require_once 'PEAR/ChannelFile.php';
}
$pear_channel = new PEAR_ChannelFile();
$pear_channel->setServer('pecl.php.net');
$pear_channel->setAlias('pecl');
$pear_channel->setSummary('PHP Extension Community Library');
$pear_channel->setDefaultPEARProtocols();
$pear_channel->setBaseURL('REST1.0', 'http://pecl.php.net/rest/');
$pear_channel->setBaseURL('REST1.1', 'http://pecl.php.net/rest/');
$pear_channel->setValidationPackage('PEAR_Validator_PECL', '1.0');
return $pear_channel;
}
if ($this->_getChannelFromAlias($channel) == 'doc.php.net') {
// the registry is not properly set up, so use defaults
if (!class_exists('PEAR_ChannelFile')) {
require_once 'PEAR/ChannelFile.php';
}
$doc_channel = new PEAR_ChannelFile();
$doc_channel->setServer('doc.php.net');
$doc_channel->setAlias('phpdocs');
$doc_channel->setSummary('PHP Documentation Team');
$doc_channel->setDefaultPEARProtocols();
$doc_channel->setBaseURL('REST1.0', 'http://doc.php.net/rest/');
$doc_channel->setBaseURL('REST1.1', 'http://doc.php.net/rest/');
$doc_channel->setBaseURL('REST1.3', 'http://doc.php.net/rest/');
return $doc_channel;
}
if ($this->_getChannelFromAlias($channel) == '__uri') {
// the registry is not properly set up, so use defaults
if (!class_exists('PEAR_ChannelFile')) {
require_once 'PEAR/ChannelFile.php';
}
$private = new PEAR_ChannelFile();
$private->setName('__uri');
$private->setDefaultPEARProtocols();
$private->setBaseURL('REST1.0', '****');
$private->setSummary('Pseudo-channel for static packages');
return $private;
}
return $ch;
}
示例7: PEAR_ChannelFile
/**
* @param string channel name
* @param bool whether to strictly retrieve channel names
* @return PEAR_ChannelFile|false
* @access private
*/
function &_getChannel($channel, $noaliases = false)
{
$ch = false;
if ($this->_channelExists($channel, $noaliases)) {
if (!class_exists('PEAR_ChannelFile')) {
require_once 'PEAR/ChannelFile.php';
}
$ch =& PEAR_ChannelFile::fromArray($this->_channelInfo($channel, $noaliases));
}
if ($ch) {
return $ch;
}
if ($this->_getChannelFromAlias($channel) == 'pear.php.net') {
// the registry is not properly set up, so use defaults
if (!class_exists('PEAR_ChannelFile')) {
require_once 'PEAR/ChannelFile.php';
}
$pear_channel = new PEAR_ChannelFile();
$pear_channel->setName('pear.php.net');
$pear_channel->setAlias('pear');
$pear_channel->setSummary('PHP Extension and Application Repository');
$pear_channel->setDefaultPEARProtocols();
$pear_channel->setBaseURL('REST1.0', 'http://pear.php.net/rest/');
$pear_channel->setBaseURL('REST1.1', 'http://pear.php.net/rest/');
return $pear_channel;
}
if ($this->_getChannelFromAlias($channel) == 'pecl.php.net') {
// the registry is not properly set up, so use defaults
if (!class_exists('PEAR_ChannelFile')) {
require_once 'PEAR/ChannelFile.php';
}
$pear_channel = new PEAR_ChannelFile();
$pear_channel->setName('pecl.php.net');
$pear_channel->setAlias('pecl');
$pear_channel->setSummary('PHP Extension Community Library');
$pear_channel->setDefaultPEARProtocols();
$pear_channel->setBaseURL('REST1.0', 'http://pecl.php.net/rest/');
$pear_channel->setBaseURL('REST1.1', 'http://pecl.php.net/rest/');
$pear_channel->setValidationPackage('PEAR_Validator_PECL', '1.0');
return $pear_channel;
}
if ($this->_getChannelFromAlias($channel) == '__uri') {
// the registry is not properly set up, so use defaults
if (!class_exists('PEAR_ChannelFile')) {
require_once 'PEAR/ChannelFile.php';
}
$private = new PEAR_ChannelFile();
$private->setName('__uri');
$private->addFunction('xmlrpc', '1.0', '****');
$private->setSummary('Pseudo-channel for static packages');
return $private;
}
return $ch;
}
示例8: PEAR_ChannelFile
/**
* Unlike {@link fromArray()} this does not do any validation
* @param array
* @static
* @return PEAR_ChannelFile
*/
function &fromArrayWithErrors($data, $compatibility = false, $stackClass = 'PEAR_ErrorStack')
{
$a = new PEAR_ChannelFile($compatibility, $stackClass);
$a->_fromArray($data);
return $a;
}
示例9: doUpdate
function doUpdate($command, $options, $params)
{
$tmpdir = $this->config->get('temp_dir');
if (!file_exists($tmpdir)) {
require_once 'System.php';
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$err = System::mkdir(array('-p', $tmpdir));
PEAR::staticPopErrorHandling();
if (PEAR::isError($err)) {
return $this->raiseError('channel-add: temp_dir does not exist: "' . $tmpdir . '" - You can change this location with "pear config-set temp_dir"');
}
}
if (!is_writable($tmpdir)) {
return $this->raiseError('channel-add: temp_dir is not writable: "' . $tmpdir . '" - You can change this location with "pear config-set temp_dir"');
}
$reg =& $this->config->getRegistry();
if (sizeof($params) != 1) {
return $this->raiseError("No channel file specified");
}
$lastmodified = false;
if ((!file_exists($params[0]) || is_dir($params[0])) && $reg->channelExists(strtolower($params[0]))) {
$c = $reg->getChannel(strtolower($params[0]));
if (PEAR::isError($c)) {
return $this->raiseError($c);
}
$this->ui->outputData("Updating channel \"{$params['0']}\"", $command);
$dl =& $this->getDownloader(array());
// if force is specified, use a timestamp of "1" to force retrieval
$lastmodified = isset($options['force']) ? false : $c->lastModified();
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$contents = $dl->downloadHttp('http://' . $c->getName() . '/channel.xml', $this->ui, $tmpdir, null, $lastmodified);
PEAR::staticPopErrorHandling();
if (PEAR::isError($contents)) {
return $this->raiseError('Cannot retrieve channel.xml for channel "' . $c->getName() . '" (' . $contents->getMessage() . ')');
}
list($contents, $lastmodified) = $contents;
if (!$contents) {
$this->ui->outputData("Channel \"{$params['0']}\" is up to date");
return;
}
$contents = implode('', file($contents));
if (!class_exists('PEAR_ChannelFile')) {
require_once 'PEAR/ChannelFile.php';
}
$channel = new PEAR_ChannelFile();
$channel->fromXmlString($contents);
if (!$channel->getErrors()) {
// security check: is the downloaded file for the channel we got it from?
if (strtolower($channel->getName()) != strtolower($c->getName())) {
if (isset($options['force'])) {
$this->ui->log(0, 'WARNING: downloaded channel definition file' . ' for channel "' . $channel->getName() . '" from channel "' . strtolower($c->getName()) . '"');
} else {
return $this->raiseError('ERROR: downloaded channel definition file' . ' for channel "' . $channel->getName() . '" from channel "' . strtolower($c->getName()) . '"');
}
}
}
} else {
if (strpos($params[0], '://')) {
$dl =& $this->getDownloader();
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$loc = $dl->downloadHttp($params[0], $this->ui, $tmpdir, null, $lastmodified);
PEAR::staticPopErrorHandling();
if (PEAR::isError($loc)) {
return $this->raiseError("Cannot open " . $params[0] . ' (' . $loc->getMessage() . ')');
} else {
list($loc, $lastmodified) = $loc;
$contents = implode('', file($loc));
}
} else {
$fp = false;
if (file_exists($params[0])) {
$fp = fopen($params[0], 'r');
}
if (!$fp) {
return $this->raiseError("Cannot open " . $params[0]);
}
$contents = '';
while (!feof($fp)) {
$contents .= fread($fp, 1024);
}
fclose($fp);
}
if (!class_exists('PEAR_ChannelFile')) {
require_once 'PEAR/ChannelFile.php';
}
$channel = new PEAR_ChannelFile();
$channel->fromXmlString($contents);
}
$exit = false;
if (count($errors = $channel->getErrors(true))) {
foreach ($errors as $error) {
$this->ui->outputData(ucfirst($error['level'] . ': ' . $error['message']));
if (!$exit) {
$exit = $error['level'] == 'error' ? true : false;
}
}
if ($exit) {
return $this->raiseError('Invalid channel.xml file');
}
}
//.........这里部分代码省略.........
示例10: fromArray
/**
* @param array
* @static
* @return PEAR_ChannelFile|false false if invalid
*/
function fromArray($data, $compatibility = false, $stackClass = 'PEAR_ErrorStack')
{
$a = new PEAR_ChannelFile($compatibility, $stackClass);
$a->_fromArray($data);
if (!$a->validate()) {
return false;
}
return $a;
}
示例11: 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;
$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;
$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;
}
示例12: validate
/** A method to validate a channel */
static function validate(HTTP_Request2 $req, PEAR_ChannelFile $chan)
{
$response = $req->send();
if ($response->getStatus() != 200) {
throw new Exception("Invalid channel site");
}
if (!$response->getBody()) {
throw new Exception("Empty channel.xml");
}
if (strlen($response->getBody()) > 100000) {
throw new Exception("Channel.xml too large");
}
if (!$chan->fromXmlString($response->getBody())) {
throw new Exception("Invalid xml");
}
if (!$chan->validate()) {
throw new Exception("Invalid channel file");
}
return true;
}
示例13: _doMakeRPMFromChannel
/**
* Set the output macros based on a channel source
*/
function _doMakeRPMFromChannel($source_file, $options, $params)
{
// Set the name of the template spec file to use by default
$this->_template_spec_name = 'template-channel.spec';
// Create a PEAR_ChannelFile object
if (!class_exists('PEAR_ChannelFile')) {
require_once 'PEAR/ChannelFile.php';
}
$cf = new PEAR_ChannelFile();
// Load in the channel.xml file from the source XML
$cf->fromXmlFile($source_file);
// Set the output macros
$this->_output['channel_alias'] = $cf->getAlias();
$this->_output['master_server'] = $cf->getName();
$this->_output['possible_channel'] = $cf->getName();
$this->_output['rpm_package'] = $this->_getRPMName(null, $cf->getName(), $cf->getAlias(), 'chan');
$rpmdep = $this->_getRPMName(null, $cf->getName(), $cf->getAlias(), 'chandep');
if (!empty($rpmdep) && $rpmdep != $this->_output['rpm_package']) {
$this->_output['extra_headers'] = $this->_formatRpmHeader('Provides', "{$rpmdep}") . "\n";
}
// Channels don't really have version numbers; this will need to be
// hand-maintained in the spec
$this->_output['version'] = '1.0';
}
示例14: Net_URL2
<?php
require_once "HTTP/Request.php";
require_once "Net/URL2.php";
$url =& new Net_URL2("http://mediawiki.googlecode.com/svn");
echo "url protocol: " . $url->protocol . "\n";
echo "url host: " . $url->host . "\n";
echo "url port: " . $url->port . "\n";
$req =& new HTTP_Request();
$req->setURL($url->protocol . "://" . $url->host . ":" . $url->port . "/channel.xml");
$req->sendRequest();
echo $req->getResponseCode();
require_once 'PEAR/ChannelFile.php';
$chan = new PEAR_ChannelFile();
echo 'XML: ';
if (!$chan->fromXmlString($req->getResponseBody())) {
echo 'channel.xml invalid';
die;
}
echo "OK \n";
echo "CHANNEL SEMANTIC: ";
if (!$chan->validate()) {
echo 'channel.xml invalid';
die;
}
echo "OK \n";
echo "server: " . $chan->getServer();