4,18 → 4,11 |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: ChannelFile.php,v 1.78 2006/10/31 02:54:40 cellog Exp $ |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a1 |
*/ |
72,11 → 65,11 |
*/ |
define('PEAR_CHANNELFILE_ERROR_MULTILINE_SUMMARY', 9); |
/** |
* Error code when channel server is missing for xmlrpc or soap protocol |
* Error code when channel server is missing for protocol |
*/ |
define('PEAR_CHANNELFILE_ERROR_NO_HOST', 10); |
/** |
* Error code when channel server is invalid for xmlrpc or soap protocol |
* Error code when channel server is invalid for protocol |
*/ |
define('PEAR_CHANNELFILE_ERROR_INVALID_HOST', 11); |
/** |
128,11 → 121,11 |
* Error code when <baseurl> contains no type attribute in a <rest> protocol definition |
*/ |
define('PEAR_CHANNELFILE_ERROR_NOBASEURLTYPE', 35); |
/** |
/** |
* Error code when a mirror is defined and the channel.xml represents the __uri pseudo-channel |
*/ |
define('PEAR_CHANNELFILE_URI_CANT_MIRROR', 36); |
/** |
/** |
* Error code when ssl attribute is present and is not "yes" |
*/ |
define('PEAR_CHANNELFILE_ERROR_INVALID_SSL', 37); |
150,13 → 143,14 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.0a1 |
*/ |
class PEAR_ChannelFile { |
class PEAR_ChannelFile |
{ |
/** |
* @access private |
* @var PEAR_ErrorStack |
163,7 → 157,7 |
* @access private |
*/ |
var $_stack; |
|
|
/** |
* Supported channel.xml versions, for parsing |
* @var array |
191,7 → 185,7 |
* @access private |
*/ |
var $_mirrorIndex; |
|
|
/** |
* Flag used to determine the validity of parsed content |
* @var boolean |
199,13 → 193,13 |
*/ |
var $_isValid = false; |
|
function PEAR_ChannelFile() |
function __construct() |
{ |
$this->_stack = &new PEAR_ErrorStack('PEAR_ChannelFile'); |
$this->_stack = new PEAR_ErrorStack('PEAR_ChannelFile'); |
$this->_stack->setErrorMessageTemplate($this->_getErrorMessage()); |
$this->_isValid = false; |
} |
|
|
/** |
* @return array |
* @access protected |
284,7 → 278,7 |
if ($result !== true) { |
if ($result->getCode() == 1) { |
$this->_stack->push(PEAR_CHANNELFILE_ERROR_NO_XML_EXT, 'error', |
array('error' => $error)); |
array('error' => $result->getMessage())); |
} else { |
$this->_stack->push(PEAR_CHANNELFILE_ERROR_CANT_MAKE_PARSER, 'error'); |
} |
297,7 → 291,7 |
return false; |
} |
} |
|
|
/** |
* @return array |
*/ |
308,14 → 302,15 |
} |
return $this->_channelInfo; |
} |
|
|
/** |
* @param array |
* @static |
* |
* @return PEAR_ChannelFile|false false if invalid |
*/ |
function &fromArray($data, $compatibility = false, $stackClass = 'PEAR_ErrorStack') |
{ |
public static function &fromArray( |
$data, $compatibility = false, $stackClass = 'PEAR_ErrorStack' |
) { |
$a = new PEAR_ChannelFile($compatibility, $stackClass); |
$a->_fromArray($data); |
if (!$a->validate()) { |
327,18 → 322,19 |
|
/** |
* Unlike {@link fromArray()} this does not do any validation |
* |
* @param array |
* @static |
* |
* @return PEAR_ChannelFile |
*/ |
function &fromArrayWithErrors($data, $compatibility = false, |
$stackClass = 'PEAR_ErrorStack') |
{ |
public static function &fromArrayWithErrors( |
$data, $compatibility = false, $stackClass = 'PEAR_ErrorStack' |
) { |
$a = new PEAR_ChannelFile($compatibility, $stackClass); |
$a->_fromArray($data); |
return $a; |
} |
|
|
/** |
* @param array |
* @access private |
347,7 → 343,7 |
{ |
$this->_channelInfo = $data; |
} |
|
|
/** |
* Wrapper to {@link PEAR_ErrorStack::getErrors()} |
* @param boolean determines whether to purge the error stack after retrieving |
484,15 → 480,9 |
$ret .= ' port="' . $channelInfo['servers']['primary']['attribs']['port'] . '"'; |
} |
$ret .= ">\n"; |
if (isset($channelInfo['servers']['primary']['xmlrpc'])) { |
$ret .= $this->_makeXmlrpcXml($channelInfo['servers']['primary']['xmlrpc'], ' '); |
} |
if (isset($channelInfo['servers']['primary']['rest'])) { |
$ret .= $this->_makeRestXml($channelInfo['servers']['primary']['rest'], ' '); |
} |
if (isset($channelInfo['servers']['primary']['soap'])) { |
$ret .= $this->_makeSoapXml($channelInfo['servers']['primary']['soap'], ' '); |
} |
$ret .= " </primary>\n"; |
if (isset($channelInfo['servers']['mirror'])) { |
$ret .= $this->_makeMirrorsXml($channelInfo); |
503,38 → 493,6 |
} |
|
/** |
* Generate the <xmlrpc> tag |
* @access private |
*/ |
function _makeXmlrpcXml($info, $indent) |
{ |
$ret = $indent . "<xmlrpc"; |
if (isset($info['attribs']['path'])) { |
$ret .= ' path="' . htmlspecialchars($info['attribs']['path']) . '"'; |
} |
$ret .= ">\n"; |
$ret .= $this->_makeFunctionsXml($info['function'], "$indent "); |
$ret .= $indent . "</xmlrpc>\n"; |
return $ret; |
} |
|
/** |
* Generate the <soap> tag |
* @access private |
*/ |
function _makeSoapXml($info, $indent) |
{ |
$ret = $indent . "<soap"; |
if (isset($info['attribs']['path'])) { |
$ret .= ' path="' . htmlspecialchars($info['attribs']['path']) . '"'; |
} |
$ret .= ">\n"; |
$ret .= $this->_makeFunctionsXml($info['function'], "$indent "); |
$ret .= $indent . "</soap>\n"; |
return $ret; |
} |
|
/** |
* Generate the <rest> tag |
* @access private |
*/ |
541,12 → 499,15 |
function _makeRestXml($info, $indent) |
{ |
$ret = $indent . "<rest>\n"; |
if (!isset($info['baseurl'][0])) { |
if (isset($info['baseurl']) && !isset($info['baseurl'][0])) { |
$info['baseurl'] = array($info['baseurl']); |
} |
foreach ($info['baseurl'] as $url) { |
$ret .= "$indent <baseurl type=\"" . $url['attribs']['type'] . "\""; |
$ret .= ">" . $url['_content'] . "</baseurl>\n"; |
|
if (isset($info['baseurl'])) { |
foreach ($info['baseurl'] as $url) { |
$ret .= "$indent <baseurl type=\"" . $url['attribs']['type'] . "\""; |
$ret .= ">" . $url['_content'] . "</baseurl>\n"; |
} |
} |
$ret .= $indent . "</rest>\n"; |
return $ret; |
571,16 → 532,10 |
$ret .= ' ssl="' . $mirror['attribs']['ssl'] . '"'; |
} |
$ret .= ">\n"; |
if (isset($mirror['xmlrpc']) || isset($mirror['soap'])) { |
if (isset($mirror['xmlrpc'])) { |
$ret .= $this->_makeXmlrpcXml($mirror['xmlrpc'], ' '); |
} |
if (isset($mirror['rest'])) { |
if (isset($mirror['rest'])) { |
$ret .= $this->_makeRestXml($mirror['rest'], ' '); |
} |
if (isset($mirror['soap'])) { |
$ret .= $this->_makeSoapXml($mirror['soap'], ' '); |
} |
$ret .= " </mirror>\n"; |
} else { |
$ret .= "/>\n"; |
680,12 → 635,14 |
array('package' => $content)); |
} |
} |
if (isset($info['servers']['primary']['attribs']['port']) && |
|
if (isset($info['servers']['primary']['attribs'], $info['servers']['primary']['attribs']['port']) && |
!is_numeric($info['servers']['primary']['attribs']['port'])) { |
$this->_validateError(PEAR_CHANNELFILE_ERROR_INVALID_PORT, |
array('port' => $info['servers']['primary']['attribs']['port'])); |
} |
if (isset($info['servers']['primary']['attribs']['ssl']) && |
|
if (isset($info['servers']['primary']['attribs'], $info['servers']['primary']['attribs']['ssl']) && |
$info['servers']['primary']['attribs']['ssl'] != 'yes') { |
$this->_validateError(PEAR_CHANNELFILE_ERROR_INVALID_SSL, |
array('ssl' => $info['servers']['primary']['attribs']['ssl'], |
692,14 → 649,6 |
'server' => $info['name'])); |
} |
|
if (isset($info['servers']['primary']['xmlrpc']) && |
isset($info['servers']['primary']['xmlrpc']['function'])) { |
$this->_validateFunctions('xmlrpc', $info['servers']['primary']['xmlrpc']['function']); |
} |
if (isset($info['servers']['primary']['soap']) && |
isset($info['servers']['primary']['soap']['function'])) { |
$this->_validateFunctions('soap', $info['servers']['primary']['soap']['function']); |
} |
if (isset($info['servers']['primary']['rest']) && |
isset($info['servers']['primary']['rest']['baseurl'])) { |
$this->_validateFunctions('rest', $info['servers']['primary']['rest']['baseurl']); |
711,7 → 660,6 |
if (!isset($info['servers']['mirror'][0])) { |
$info['servers']['mirror'] = array($info['servers']['mirror']); |
} |
$i = 0; |
foreach ($info['servers']['mirror'] as $mirror) { |
if (!isset($mirror['attribs']['host'])) { |
$this->_validateError(PEAR_CHANNELFILE_ERROR_NO_HOST, |
724,14 → 672,6 |
$this->_validateError(PEAR_CHANNELFILE_ERROR_INVALID_SSL, |
array('ssl' => $info['ssl'], 'server' => $mirror['attribs']['host'])); |
} |
if (isset($mirror['xmlrpc'])) { |
$this->_validateFunctions('xmlrpc', |
$mirror['xmlrpc']['function'], $mirror['attribs']['host']); |
} |
if (isset($mirror['soap'])) { |
$this->_validateFunctions('soap', $mirror['soap']['function'], |
$mirror['attribs']['host']); |
} |
if (isset($mirror['rest'])) { |
$this->_validateFunctions('rest', $mirror['rest']['baseurl'], |
$mirror['attribs']['host']); |
742,7 → 682,7 |
} |
|
/** |
* @param string xmlrpc or soap - protocol name this function applies to |
* @param string rest - protocol name this function applies to |
* @param array the functions |
* @param string the name of the parent element (mirror name, for instance) |
*/ |
751,15 → 691,17 |
if (!isset($functions[0])) { |
$functions = array($functions); |
} |
|
foreach ($functions as $function) { |
if (!isset($function['_content']) || empty($function['_content'])) { |
$this->_validateError(PEAR_CHANNELFILE_ERROR_NO_FUNCTIONNAME, |
array('parent' => $parent, 'protocol' => $protocol)); |
} |
|
if ($protocol == 'rest') { |
if (!isset($function['attribs']['type']) || |
empty($function['attribs']['type'])) { |
$this->_validateError(PEAR_CHANNELFILE_ERROR_NO_BASEURLTYPE, |
$this->_validateError(PEAR_CHANNELFILE_ERROR_NOBASEURLTYPE, |
array('parent' => $parent, 'protocol' => $protocol)); |
} |
} else { |
792,9 → 734,9 |
{ |
if (isset($this->_channelInfo['name'])) { |
return $this->_channelInfo['name']; |
} else { |
return false; |
} |
|
return false; |
} |
|
/** |
804,9 → 746,9 |
{ |
if (isset($this->_channelInfo['name'])) { |
return $this->_channelInfo['name']; |
} else { |
return false; |
} |
|
return false; |
} |
|
/** |
818,21 → 760,26 |
if ($mir = $this->getMirror($mirror)) { |
if (isset($mir['attribs']['port'])) { |
return $mir['attribs']['port']; |
} else { |
if ($this->getSSL($mirror)) { |
return 443; |
} |
return 80; |
} |
|
if ($this->getSSL($mirror)) { |
return 443; |
} |
|
return 80; |
} |
|
return false; |
} |
|
if (isset($this->_channelInfo['servers']['primary']['attribs']['port'])) { |
return $this->_channelInfo['servers']['primary']['attribs']['port']; |
} |
|
if ($this->getSSL()) { |
return 443; |
} |
|
return 80; |
} |
|
845,15 → 792,18 |
if ($mir = $this->getMirror($mirror)) { |
if (isset($mir['attribs']['ssl'])) { |
return true; |
} else { |
return false; |
} |
|
return false; |
} |
|
return false; |
} |
|
if (isset($this->_channelInfo['servers']['primary']['attribs']['ssl'])) { |
return true; |
} |
|
return false; |
} |
|
864,37 → 814,13 |
{ |
if (isset($this->_channelInfo['summary'])) { |
return $this->_channelInfo['summary']; |
} else { |
return false; |
} |
} |
|
/** |
* @param string xmlrpc or soap |
* @param string|false mirror name or false for primary server |
*/ |
function getPath($protocol, $mirror = false) |
{ |
if (!in_array($protocol, array('xmlrpc', 'soap'))) { |
return false; |
} |
if ($mirror) { |
if (!($mir = $this->getMirror($mirror))) { |
return false; |
} |
if (isset($mir[$protocol]['attribs']['path'])) { |
return $mir[$protocol]['attribs']['path']; |
} else { |
return $protocol . '.php'; |
} |
} elseif (isset($this->_channelInfo['servers']['primary'][$protocol]['attribs']['path'])) { |
return $this->_channelInfo['servers']['primary'][$protocol]['attribs']['path']; |
} |
return $protocol . '.php'; |
return false; |
} |
|
/** |
* @param string protocol type (xmlrpc, soap) |
* @param string protocol type |
* @param string Mirror name |
* @return array|false |
*/ |
903,11 → 829,8 |
if ($this->getName() == '__uri') { |
return false; |
} |
if ($protocol == 'rest') { |
$function = 'baseurl'; |
} else { |
$function = 'function'; |
} |
|
$function = $protocol == 'rest' ? 'baseurl' : 'function'; |
if ($mirror) { |
if ($mir = $this->getMirror($mirror)) { |
if (isset($mir[$protocol][$function])) { |
914,13 → 837,15 |
return $mir[$protocol][$function]; |
} |
} |
|
return false; |
} |
|
if (isset($this->_channelInfo['servers']['primary'][$protocol][$function])) { |
return $this->_channelInfo['servers']['primary'][$protocol][$function]; |
} else { |
return false; |
} |
|
return false; |
} |
|
/** |
936,15 → 861,19 |
if (!$protocols) { |
return false; |
} |
|
foreach ($protocols as $protocol) { |
if ($name === null) { |
return $protocol; |
} |
|
if ($protocol['_content'] != $name) { |
continue; |
} |
|
return $protocol; |
} |
|
return false; |
} |
|
961,18 → 890,23 |
if (!$protocols) { |
return false; |
} |
|
foreach ($protocols as $protocol) { |
if ($protocol['attribs']['version'] != $version) { |
continue; |
} |
|
if ($name === null) { |
return true; |
} |
|
if ($protocol['_content'] != $name) { |
continue; |
} |
|
return true; |
} |
|
return false; |
} |
|
987,12 → 921,15 |
if ($mirror == $this->_channelInfo['name']) { |
$mirror = false; |
} |
|
if ($mirror) { |
if ($mir = $this->getMirror($mirror)) { |
return isset($mir['rest']); |
} |
|
return false; |
} |
|
return isset($this->_channelInfo['servers']['primary']['rest']); |
} |
|
1008,25 → 945,28 |
if ($mirror == $this->_channelInfo['name']) { |
$mirror = false; |
} |
|
if ($mirror) { |
if ($mir = $this->getMirror($mirror)) { |
$rest = $mir['rest']; |
} else { |
$mir = $this->getMirror($mirror); |
if (!$mir) { |
return false; |
} |
$server = $mirror; |
|
$rest = $mir['rest']; |
} else { |
$rest = $this->_channelInfo['servers']['primary']['rest']; |
$server = $this->getServer(); |
} |
|
if (!isset($rest['baseurl'][0])) { |
$rest['baseurl'] = array($rest['baseurl']); |
} |
|
foreach ($rest['baseurl'] as $baseurl) { |
if (strtolower($baseurl['attribs']['type']) == strtolower($resourceType)) { |
return $baseurl['_content']; |
} |
} |
|
return false; |
} |
|
1042,7 → 982,7 |
|
/** |
* Empty all protocol definitions |
* @param string protocol type (xmlrpc, soap) |
* @param string protocol type |
* @param string|false mirror name, if any |
*/ |
function resetFunctions($type, $mirror = false) |
1053,24 → 993,28 |
if (!isset($mirrors[0])) { |
$mirrors = array($mirrors); |
} |
|
foreach ($mirrors as $i => $mir) { |
if ($mir['attribs']['host'] == $mirror) { |
if (isset($this->_channelInfo['servers']['mirror'][$i][$type])) { |
unset($this->_channelInfo['servers']['mirror'][$i][$type]); |
} |
|
return true; |
} |
} |
|
return false; |
} else { |
return false; |
} |
} else { |
if (isset($this->_channelInfo['servers']['primary'][$type])) { |
unset($this->_channelInfo['servers']['primary'][$type]); |
} |
return true; |
|
return false; |
} |
|
if (isset($this->_channelInfo['servers']['primary'][$type])) { |
unset($this->_channelInfo['servers']['primary'][$type]); |
} |
|
return true; |
} |
|
/** |
1080,19 → 1024,15 |
{ |
switch ($version) { |
case '1.0' : |
$this->resetFunctions('xmlrpc', $mirror); |
$this->resetFunctions('soap', $mirror); |
$this->resetREST($mirror); |
$this->addFunction('xmlrpc', '1.0', 'logintest', $mirror); |
$this->addFunction('xmlrpc', '1.0', 'package.listLatestReleases', $mirror); |
$this->addFunction('xmlrpc', '1.0', 'package.listAll', $mirror); |
$this->addFunction('xmlrpc', '1.0', 'package.info', $mirror); |
$this->addFunction('xmlrpc', '1.0', 'package.getDownloadURL', $mirror); |
$this->addFunction('xmlrpc', '1.1', 'package.getDownloadURL', $mirror); |
$this->addFunction('xmlrpc', '1.0', 'package.getDepDownloadURL', $mirror); |
$this->addFunction('xmlrpc', '1.1', 'package.getDepDownloadURL', $mirror); |
$this->addFunction('xmlrpc', '1.0', 'package.search', $mirror); |
$this->addFunction('xmlrpc', '1.0', 'channel.listAll', $mirror); |
|
if (!isset($this->_channelInfo['servers'])) { |
$this->_channelInfo['servers'] = array('primary' => |
array('rest' => array())); |
} elseif (!isset($this->_channelInfo['servers']['primary'])) { |
$this->_channelInfo['servers']['primary'] = array('rest' => array()); |
} |
|
return true; |
break; |
default : |
1100,7 → 1040,7 |
break; |
} |
} |
|
|
/** |
* @return array |
*/ |
1111,10 → 1051,11 |
if (!isset($mirrors[0])) { |
$mirrors = array($mirrors); |
} |
|
return $mirrors; |
} else { |
return array(); |
} |
|
return array(); |
} |
|
/** |
1128,6 → 1069,7 |
return $mirror; |
} |
} |
|
return false; |
} |
|
1155,7 → 1097,7 |
array('mirror' => $mirror)); |
return false; |
} |
$setmirror = false; |
|
if (isset($this->_channelInfo['servers']['mirror'][0])) { |
foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) { |
if ($mirror == $mir['attribs']['host']) { |
1163,6 → 1105,7 |
return true; |
} |
} |
|
return false; |
} elseif ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) { |
$this->_channelInfo['servers']['mirror']['attribs']['port'] = $port; |
1170,6 → 1113,7 |
return true; |
} |
} |
|
$this->_channelInfo['servers']['primary']['attribs']['port'] = $port; |
$this->_isValid = false; |
return true; |
1188,7 → 1132,7 |
array('mirror' => $mirror)); |
return false; |
} |
$setmirror = false; |
|
if (isset($this->_channelInfo['servers']['mirror'][0])) { |
foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) { |
if ($mirror == $mir['attribs']['host']) { |
1200,9 → 1144,11 |
} else { |
$this->_channelInfo['servers']['mirror'][$i]['attribs']['ssl'] = 'yes'; |
} |
|
return true; |
} |
} |
|
return false; |
} elseif ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) { |
if (!$ssl) { |
1212,10 → 1158,12 |
} else { |
$this->_channelInfo['servers']['mirror']['attribs']['ssl'] = 'yes'; |
} |
|
$this->_isValid = false; |
return true; |
} |
} |
|
if ($ssl) { |
$this->_channelInfo['servers']['primary']['attribs']['ssl'] = 'yes'; |
} else { |
1223,45 → 1171,7 |
unset($this->_channelInfo['servers']['primary']['attribs']['ssl']); |
} |
} |
$this->_isValid = false; |
return true; |
} |
|
/** |
* Set the socket number (port) that is used to connect to this channel |
* @param integer |
* @param string|false name of the mirror server, or false for the primary |
*/ |
function setPath($protocol, $path, $mirror = false) |
{ |
if (!in_array($protocol, array('xmlrpc', 'soap'))) { |
return false; |
} |
if ($mirror) { |
if (!isset($this->_channelInfo['servers']['mirror'])) { |
$this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND, |
array('mirror' => $mirror)); |
return false; |
} |
$setmirror = false; |
if (isset($this->_channelInfo['servers']['mirror'][0])) { |
foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) { |
if ($mirror == $mir['attribs']['host']) { |
$this->_channelInfo['servers']['mirror'][$i][$protocol]['attribs']['path'] = |
$path; |
return true; |
} |
} |
$this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND, |
array('mirror' => $mirror)); |
return false; |
} elseif ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) { |
$this->_channelInfo['servers']['mirror'][$protocol]['attribs']['path'] = $path; |
$this->_isValid = false; |
return true; |
} |
} |
$this->_channelInfo['servers']['primary'][$protocol]['attribs']['path'] = $path; |
$this->_isValid = false; |
return true; |
} |
1282,6 → 1192,7 |
array('tag' => 'name', 'name' => $server)); |
return false; |
} |
|
if ($mirror) { |
$found = false; |
foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) { |
1290,14 → 1201,17 |
break; |
} |
} |
|
if (!$found) { |
$this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND, |
array('mirror' => $mirror)); |
return false; |
} |
|
$this->_channelInfo['mirror'][$i]['attribs']['host'] = $server; |
return true; |
} |
|
$this->_channelInfo['name'] = $server; |
return true; |
} |
1317,6 → 1231,7 |
$this->_validateWarning(PEAR_CHANNELFILE_ERROR_MULTILINE_SUMMARY, |
array('summary' => $summary)); |
} |
|
$this->_channelInfo['summary'] = $summary; |
return true; |
} |
1333,11 → 1248,13 |
array('tag' => 'suggestedalias', 'name' => $alias)); |
return false; |
} |
|
if ($local) { |
$this->_channelInfo['localalias'] = $alias; |
} else { |
$this->_channelInfo['suggestedalias'] = $alias; |
} |
|
return true; |
} |
|
1355,6 → 1272,7 |
if (isset($this->_channelInfo['name'])) { |
return $this->_channelInfo['name']; |
} |
return ''; |
} |
|
/** |
1386,6 → 1304,7 |
if ($mirror) { |
return $this->addMirrorFunction($mirror, $type, $version, $name); |
} |
|
$set = array('attribs' => array('version' => $version), '_content' => $name); |
if (!isset($this->_channelInfo['servers']['primary'][$type]['function'])) { |
if (!isset($this->_channelInfo['servers'])) { |
1394,6 → 1313,7 |
} elseif (!isset($this->_channelInfo['servers']['primary'])) { |
$this->_channelInfo['servers']['primary'] = array($type => array()); |
} |
|
$this->_channelInfo['servers']['primary'][$type]['function'] = $set; |
$this->_isValid = false; |
return true; |
1401,6 → 1321,7 |
$this->_channelInfo['servers']['primary'][$type]['function'] = array( |
$this->_channelInfo['servers']['primary'][$type]['function']); |
} |
|
$this->_channelInfo['servers']['primary'][$type]['function'][] = $set; |
return true; |
} |
1413,12 → 1334,12 |
*/ |
function addMirrorFunction($mirror, $type, $version, $name = '') |
{ |
$found = false; |
if (!isset($this->_channelInfo['servers']['mirror'])) { |
$this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND, |
array('mirror' => $mirror)); |
return false; |
} |
|
$setmirror = false; |
if (isset($this->_channelInfo['servers']['mirror'][0])) { |
foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) { |
1432,11 → 1353,13 |
$setmirror = &$this->_channelInfo['servers']['mirror']; |
} |
} |
|
if (!$setmirror) { |
$this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND, |
array('mirror' => $mirror)); |
return false; |
} |
|
$set = array('attribs' => array('version' => $version), '_content' => $name); |
if (!isset($setmirror[$type]['function'])) { |
$setmirror[$type]['function'] = $set; |
1445,6 → 1368,7 |
} elseif (!isset($setmirror[$type]['function'][0])) { |
$setmirror[$type]['function'] = array($setmirror[$type]['function']); |
} |
|
$setmirror[$type]['function'][] = $set; |
$this->_isValid = false; |
return true; |
1458,12 → 1382,12 |
function setBaseURL($resourceType, $url, $mirror = false) |
{ |
if ($mirror) { |
$found = false; |
if (!isset($this->_channelInfo['servers']['mirror'])) { |
$this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND, |
array('mirror' => $mirror)); |
return false; |
} |
|
$setmirror = false; |
if (isset($this->_channelInfo['servers']['mirror'][0])) { |
foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) { |
1480,10 → 1404,12 |
} else { |
$setmirror = &$this->_channelInfo['servers']['primary']; |
} |
|
$set = array('attribs' => array('type' => $resourceType), '_content' => $url); |
if (!isset($setmirror['rest'])) { |
$setmirror['rest'] = array(); |
} |
|
if (!isset($setmirror['rest']['baseurl'])) { |
$setmirror['rest']['baseurl'] = $set; |
$this->_isValid = false; |
1491,6 → 1417,7 |
} elseif (!isset($setmirror['rest']['baseurl'][0])) { |
$setmirror['rest']['baseurl'] = array($setmirror['rest']['baseurl']); |
} |
|
foreach ($setmirror['rest']['baseurl'] as $i => $url) { |
if ($url['attribs']['type'] == $resourceType) { |
$this->_isValid = false; |
1498,6 → 1425,7 |
return true; |
} |
} |
|
$setmirror['rest']['baseurl'][] = $set; |
$this->_isValid = false; |
return true; |
1513,19 → 1441,22 |
if ($this->_channelInfo['name'] == '__uri') { |
return false; // the __uri channel cannot have mirrors by definition |
} |
|
$set = array('attribs' => array('host' => $server)); |
if (is_numeric($port)) { |
$set['attribs']['port'] = $port; |
} |
|
if (!isset($this->_channelInfo['servers']['mirror'])) { |
$this->_channelInfo['servers']['mirror'] = $set; |
return true; |
} else { |
if (!isset($this->_channelInfo['servers']['mirror'][0])) { |
$this->_channelInfo['servers']['mirror'] = |
array($this->_channelInfo['servers']['mirror']); |
} |
} |
|
if (!isset($this->_channelInfo['servers']['mirror'][0])) { |
$this->_channelInfo['servers']['mirror'] = |
array($this->_channelInfo['servers']['mirror']); |
} |
|
$this->_channelInfo['servers']['mirror'][] = $set; |
return true; |
} |
1539,10 → 1470,12 |
if (!$this->_isValid && !$this->validate()) { |
return false; |
} |
|
if (!isset($this->_channelInfo['validatepackage'])) { |
return array('attribs' => array('version' => 'default'), |
'_content' => 'PEAR_Validate'); |
} |
|
return $this->_channelInfo['validatepackage']; |
} |
|
1558,6 → 1491,7 |
if (!class_exists('PEAR_Validate')) { |
require_once 'PEAR/Validate.php'; |
} |
|
if (!$this->_isValid) { |
if (!$this->validate()) { |
$a = false; |
1564,12 → 1498,14 |
return $a; |
} |
} |
|
if (isset($this->_channelInfo['validatepackage'])) { |
if ($package == $this->_channelInfo['validatepackage']) { |
// channel validation packages are always validated by PEAR_Validate |
$val = &new PEAR_Validate; |
$val = new PEAR_Validate; |
return $val; |
} |
|
if (!class_exists(str_replace('.', '_', |
$this->_channelInfo['validatepackage']['_content']))) { |
if ($this->isIncludeable(str_replace('_', '/', |
1578,7 → 1514,7 |
$this->_channelInfo['validatepackage']['_content']) . '.php'; |
$vclass = str_replace('.', '_', |
$this->_channelInfo['validatepackage']['_content']); |
$val = &new $vclass; |
$val = new $vclass; |
} else { |
$a = false; |
return $a; |
1586,11 → 1522,12 |
} else { |
$vclass = str_replace('.', '_', |
$this->_channelInfo['validatepackage']['_content']); |
$val = &new $vclass; |
$val = new $vclass; |
} |
} else { |
$val = &new PEAR_Validate; |
$val = new PEAR_Validate; |
} |
|
return $val; |
} |
|
1603,6 → 1540,7 |
return true; |
} |
} |
|
return false; |
} |
|
1616,7 → 1554,7 |
if (isset($this->_channelInfo['_lastmodified'])) { |
return $this->_channelInfo['_lastmodified']; |
} |
|
return time(); |
} |
} |
?> |