Bearsampp 2026.9.23
Loading...
Searching...
No Matches
PEAR_ChannelFile Class Reference

Public Member Functions

 __construct ()
 _fromArray ($data)
 _getErrorMessage ()
 _makeFunctionsXml ($functions, $indent, $rest=false)
 _makeMirrorsXml ($channelInfo)
 _makeRestXml ($info, $indent)
 _unIndent ($str)
 _validateError ($code, $params=array())
 _validateFunctions ($protocol, $functions, $parent='')
 _validateWarning ($code, $params=array())
 addFunction ($type, $version, $name='', $mirror=false)
 addMirror ($server, $port=null)
 addMirrorFunction ($mirror, $type, $version, $name='')
 fromAny ($info)
 fromXmlFile ($descfile)
 fromXmlString ($data)
 getAlias ()
 getBaseURL ($resourceType, $mirror=false)
 getErrors ($purge=false)
 getFunction ($type, $name=null, $mirror=false)
 getFunctions ($protocol, $mirror=false)
 getMirror ($server)
 getMirrors ()
 getName ()
 getPort ($mirror=false)
 getServer ()
 getSSL ($mirror=false)
 getSummary ()
& getValidationObject ($package=false)
 getValidationPackage ()
 isIncludeable ($path)
 lastModified ()
 resetFunctions ($type, $mirror=false)
 resetREST ($mirror=false)
 setAlias ($alias, $local=false)
 setBaseURL ($resourceType, $url, $mirror=false)
 setDefaultPEARProtocols ($version='1.0', $mirror=false)
 setName ($name)
 setPort ($port, $mirror=false)
 setServer ($server, $mirror=false)
 setSSL ($ssl=true, $mirror=false)
 setSummary ($summary)
 setValidationPackage ($validateclass, $version)
 supports ($type, $name=null, $mirror=false, $version='1.0')
 supportsREST ($mirror=false)
 toArray ()
 toXml ()
 validate ()
 validChannelServer ($server)

Static Public Member Functions

static & fromArray ( $data, $compatibility=false, $stackClass='PEAR_ErrorStack')
static & fromArrayWithErrors ( $data, $compatibility=false, $stackClass='PEAR_ErrorStack')

Data Fields

 $_channelInfo
 $_isValid = false
 $_mirrorIndex
 $_stack
 $_subchannelIndex
 $_supportedVersions = array('1.0')

Detailed Description

Definition at line 152 of file ChannelFile.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

Definition at line 196 of file ChannelFile.php.

197 {
198 $this->_stack = new PEAR_ErrorStack('PEAR_ChannelFile');
199 $this->_stack->setErrorMessageTemplate($this->_getErrorMessage());
200 $this->_isValid = false;
201 }

References _getErrorMessage().

Here is the call graph for this function:

Member Function Documentation

◆ _fromArray()

_fromArray ( $data)
Parameters
array@access private

Definition at line 342 of file ChannelFile.php.

343 {
344 $this->_channelInfo = $data;
345 }

◆ _getErrorMessage()

_getErrorMessage ( )
Returns
array @access protected

Definition at line 207 of file ChannelFile.php.

208 {
209 return
210 array(
212 'While parsing channel.xml, an invalid version number "%version% was passed in, expecting one of %versions%',
214 'No version number found in <channel> tag',
216 '%error%',
218 'Unable to create XML parser',
220 '%error%',
222 'Missing channel name',
224 'Invalid channel %tag% "%name%"',
226 'Missing channel summary',
228 'Channel summary should be on one line, but is multi-line',
230 'Missing channel server for %type% server',
232 'Server name "%server%" is invalid for %type% server',
234 'Invalid mirror name "%name%", mirror type %type%',
236 'Invalid mirror type "%type%"',
238 'Cannot generate xml, contents are invalid',
240 'packagenameregex cannot be empty',
242 '%parent% %protocol% function has no version',
244 '%parent% %protocol% function has no name',
246 '%parent% rest baseurl has no type',
248 'Validation package has no name in <validatepackage> tag',
250 'Validation package "%package%" has no version',
252 'Mirror "%mirror%" does not exist',
254 'Port "%port%" must be numeric',
256 '<static> tag must contain version attribute',
258 'The __uri pseudo-channel cannot have mirrors',
260 '%server% has invalid ssl attribute "%ssl%" can only be yes or not present',
261 );
262 }
const PEAR_CHANNELFILE_ERROR_INVALID_VERSION
const PEAR_CHANNELFILE_ERROR_CANT_MAKE_PARSER
const PEAR_CHANNELFILE_ERROR_NOVALIDATE_NAME
const PEAR_CHANNELFILE_ERROR_INVALID_SSL
const PEAR_CHANNELFILE_ERROR_INVALID_NAME
const PEAR_CHANNELFILE_ERROR_EMPTY_REGEX
const PEAR_CHANNELFILE_ERROR_MULTILINE_SUMMARY
const PEAR_CHANNELFILE_ERROR_INVALID_MIRRORTYPE
const PEAR_CHANNELFILE_ERROR_NO_FUNCTIONVERSION
const PEAR_CHANNELFILE_ERROR_NOBASEURLTYPE
const PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND
const PEAR_CHANNELFILE_ERROR_NO_STATICVERSION
const PEAR_CHANNELFILE_ERROR_NO_FUNCTIONNAME
const PEAR_CHANNELFILE_ERROR_NO_HOST
const PEAR_CHANNELFILE_ERROR_INVALID_HOST
const PEAR_CHANNELFILE_ERROR_NO_SUMMARY
const PEAR_CHANNELFILE_ERROR_INVALID_MIRROR
const PEAR_CHANNELFILE_ERROR_NOVALIDATE_VERSION
const PEAR_CHANNELFILE_ERROR_INVALID_PORT
const PEAR_CHANNELFILE_ERROR_PARSER_ERROR
const PEAR_CHANNELFILE_ERROR_NO_VERSION
const PEAR_CHANNELFILE_ERROR_NO_NAME
const PEAR_CHANNELFILE_URI_CANT_MIRROR
const PEAR_CHANNELFILE_ERROR_NO_XML_EXT
const PEAR_CHANNELFILE_ERROR_INVALID

References PEAR_CHANNELFILE_ERROR_CANT_MAKE_PARSER, PEAR_CHANNELFILE_ERROR_EMPTY_REGEX, PEAR_CHANNELFILE_ERROR_INVALID, PEAR_CHANNELFILE_ERROR_INVALID_HOST, PEAR_CHANNELFILE_ERROR_INVALID_MIRROR, PEAR_CHANNELFILE_ERROR_INVALID_MIRRORTYPE, PEAR_CHANNELFILE_ERROR_INVALID_NAME, PEAR_CHANNELFILE_ERROR_INVALID_PORT, PEAR_CHANNELFILE_ERROR_INVALID_SSL, PEAR_CHANNELFILE_ERROR_INVALID_VERSION, PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND, PEAR_CHANNELFILE_ERROR_MULTILINE_SUMMARY, PEAR_CHANNELFILE_ERROR_NO_FUNCTIONNAME, PEAR_CHANNELFILE_ERROR_NO_FUNCTIONVERSION, PEAR_CHANNELFILE_ERROR_NO_HOST, PEAR_CHANNELFILE_ERROR_NO_NAME, PEAR_CHANNELFILE_ERROR_NO_STATICVERSION, PEAR_CHANNELFILE_ERROR_NO_SUMMARY, PEAR_CHANNELFILE_ERROR_NO_VERSION, PEAR_CHANNELFILE_ERROR_NO_XML_EXT, PEAR_CHANNELFILE_ERROR_NOBASEURLTYPE, PEAR_CHANNELFILE_ERROR_NOVALIDATE_NAME, PEAR_CHANNELFILE_ERROR_NOVALIDATE_VERSION, PEAR_CHANNELFILE_ERROR_PARSER_ERROR, and PEAR_CHANNELFILE_URI_CANT_MIRROR.

Referenced by __construct().

Here is the caller graph for this function:

◆ _makeFunctionsXml()

_makeFunctionsXml ( $functions,
$indent,
$rest = false )

Generate the <functions> tag @access private

Definition at line 551 of file ChannelFile.php.

552 {
553 $ret = '';
554 if (!isset($functions[0])) {
555 $functions = array($functions);
556 }
557 foreach ($functions as $function) {
558 $ret .= "$indent<function version=\"" . $function['attribs']['version'] . "\"";
559 if ($rest) {
560 $ret .= ' uri="' . $function['attribs']['uri'] . '"';
561 }
562 $ret .= ">" . $function['_content'] . "</function>\n";
563 }
564 return $ret;
565 }

◆ _makeMirrorsXml()

_makeMirrorsXml ( $channelInfo)

Generate the <mirrors> tag @access private

Definition at line 520 of file ChannelFile.php.

521 {
522 $ret = "";
523 if (!isset($channelInfo['servers']['mirror'][0])) {
524 $channelInfo['servers']['mirror'] = array($channelInfo['servers']['mirror']);
525 }
526 foreach ($channelInfo['servers']['mirror'] as $mirror) {
527 $ret .= ' <mirror host="' . $mirror['attribs']['host'] . '"';
528 if (isset($mirror['attribs']['port'])) {
529 $ret .= ' port="' . $mirror['attribs']['port'] . '"';
530 }
531 if (isset($mirror['attribs']['ssl'])) {
532 $ret .= ' ssl="' . $mirror['attribs']['ssl'] . '"';
533 }
534 $ret .= ">\n";
535 if (isset($mirror['rest'])) {
536 if (isset($mirror['rest'])) {
537 $ret .= $this->_makeRestXml($mirror['rest'], ' ');
538 }
539 $ret .= " </mirror>\n";
540 } else {
541 $ret .= "/>\n";
542 }
543 }
544 return $ret;
545 }
_makeRestXml($info, $indent)

References _makeRestXml().

Referenced by toXml().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _makeRestXml()

_makeRestXml ( $info,
$indent )

Generate the <rest> tag @access private

Definition at line 499 of file ChannelFile.php.

500 {
501 $ret = $indent . "<rest>\n";
502 if (isset($info['baseurl']) && !isset($info['baseurl'][0])) {
503 $info['baseurl'] = array($info['baseurl']);
504 }
505
506 if (isset($info['baseurl'])) {
507 foreach ($info['baseurl'] as $url) {
508 $ret .= "$indent <baseurl type=\"" . $url['attribs']['type'] . "\"";
509 $ret .= ">" . $url['_content'] . "</baseurl>\n";
510 }
511 }
512 $ret .= $indent . "</rest>\n";
513 return $ret;
514 }

Referenced by _makeMirrorsXml(), and toXml().

Here is the caller graph for this function:

◆ _unIndent()

_unIndent ( $str)

Unindent given string (?)

Parameters
string$strThe string that has to be unindented.
Returns
string @access private

Definition at line 364 of file ChannelFile.php.

365 {
366 // remove leading newlines
367 $str = preg_replace('/^[\r\n]+/', '', $str);
368 // find whitespace at the beginning of the first line
369 $indent_len = strspn($str, " \t");
370 $indent = substr($str, 0, $indent_len);
371 $data = '';
372 // remove the same amount of whitespace from following lines
373 foreach (explode("\n", $str) as $line) {
374 if (substr($line, 0, $indent_len) == $indent) {
375 $data .= substr($line, $indent_len) . "\n";
376 }
377 }
378 return $data;
379 }

◆ _validateError()

_validateError ( $code,
$params = array() )

Validation error. Also marks the object contents as invalid

Parameters
errorcode
arrayerror information @access private

Definition at line 573 of file ChannelFile.php.

574 {
575 $this->_stack->push($code, 'error', $params);
576 $this->_isValid = false;
577 }

Referenced by _validateFunctions(), addMirrorFunction(), setAlias(), setBaseURL(), setPort(), setServer(), setSSL(), setSummary(), toXml(), and validate().

Here is the caller graph for this function:

◆ _validateFunctions()

_validateFunctions ( $protocol,
$functions,
$parent = '' )
Parameters
stringrest - protocol name this function applies to
arraythe functions
stringthe name of the parent element (mirror name, for instance)

Definition at line 689 of file ChannelFile.php.

690 {
691 if (!isset($functions[0])) {
692 $functions = array($functions);
693 }
694
695 foreach ($functions as $function) {
696 if (!isset($function['_content']) || empty($function['_content'])) {
698 array('parent' => $parent, 'protocol' => $protocol));
699 }
700
701 if ($protocol == 'rest') {
702 if (!isset($function['attribs']['type']) ||
703 empty($function['attribs']['type'])) {
705 array('parent' => $parent, 'protocol' => $protocol));
706 }
707 } else {
708 if (!isset($function['attribs']['version']) ||
709 empty($function['attribs']['version'])) {
711 array('parent' => $parent, 'protocol' => $protocol));
712 }
713 }
714 }
715 }
_validateError($code, $params=array())

References _validateError(), PEAR_CHANNELFILE_ERROR_NO_FUNCTIONNAME, PEAR_CHANNELFILE_ERROR_NO_FUNCTIONVERSION, and PEAR_CHANNELFILE_ERROR_NOBASEURLTYPE.

Referenced by validate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _validateWarning()

_validateWarning ( $code,
$params = array() )

Validation warning. Does not mark the object contents invalid.

Parameters
errorcode
arrayerror information @access private

Definition at line 585 of file ChannelFile.php.

586 {
587 $this->_stack->push($code, 'warning', $params);
588 }

Referenced by setSummary(), and validate().

Here is the caller graph for this function:

◆ addFunction()

addFunction ( $type,
$version,
$name = '',
$mirror = false )

Add a protocol to the provides section

Parameters
stringprotocol type
stringprotocol version
stringprotocol name, if any
stringmirror name, if this is a mirror's protocol
Returns
bool

Definition at line 1302 of file ChannelFile.php.

1303 {
1304 if ($mirror) {
1305 return $this->addMirrorFunction($mirror, $type, $version, $name);
1306 }
1307
1308 $set = array('attribs' => array('version' => $version), '_content' => $name);
1309 if (!isset($this->_channelInfo['servers']['primary'][$type]['function'])) {
1310 if (!isset($this->_channelInfo['servers'])) {
1311 $this->_channelInfo['servers'] = array('primary' =>
1312 array($type => array()));
1313 } elseif (!isset($this->_channelInfo['servers']['primary'])) {
1314 $this->_channelInfo['servers']['primary'] = array($type => array());
1315 }
1316
1317 $this->_channelInfo['servers']['primary'][$type]['function'] = $set;
1318 $this->_isValid = false;
1319 return true;
1320 } elseif (!isset($this->_channelInfo['servers']['primary'][$type]['function'][0])) {
1321 $this->_channelInfo['servers']['primary'][$type]['function'] = array(
1322 $this->_channelInfo['servers']['primary'][$type]['function']);
1323 }
1324
1325 $this->_channelInfo['servers']['primary'][$type]['function'][] = $set;
1326 return true;
1327 }
addMirrorFunction($mirror, $type, $version, $name='')

References addMirrorFunction().

Here is the call graph for this function:

◆ addMirror()

addMirror ( $server,
$port = null )
Parameters
stringmirror server
intmirror http port
Returns
boolean

Definition at line 1439 of file ChannelFile.php.

1440 {
1441 if ($this->_channelInfo['name'] == '__uri') {
1442 return false; // the __uri channel cannot have mirrors by definition
1443 }
1444
1445 $set = array('attribs' => array('host' => $server));
1446 if (is_numeric($port)) {
1447 $set['attribs']['port'] = $port;
1448 }
1449
1450 if (!isset($this->_channelInfo['servers']['mirror'])) {
1451 $this->_channelInfo['servers']['mirror'] = $set;
1452 return true;
1453 }
1454
1455 if (!isset($this->_channelInfo['servers']['mirror'][0])) {
1456 $this->_channelInfo['servers']['mirror'] =
1457 array($this->_channelInfo['servers']['mirror']);
1458 }
1459
1460 $this->_channelInfo['servers']['mirror'][] = $set;
1461 return true;
1462 }
$port

References $port.

◆ addMirrorFunction()

addMirrorFunction ( $mirror,
$type,
$version,
$name = '' )

Add a protocol to a mirror's provides section

Parameters
stringmirror name (server)
stringprotocol type
stringprotocol version
stringprotocol name, if any

Definition at line 1335 of file ChannelFile.php.

1336 {
1337 if (!isset($this->_channelInfo['servers']['mirror'])) {
1339 array('mirror' => $mirror));
1340 return false;
1341 }
1342
1343 $setmirror = false;
1344 if (isset($this->_channelInfo['servers']['mirror'][0])) {
1345 foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {
1346 if ($mirror == $mir['attribs']['host']) {
1347 $setmirror = &$this->_channelInfo['servers']['mirror'][$i];
1348 break;
1349 }
1350 }
1351 } else {
1352 if ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) {
1353 $setmirror = &$this->_channelInfo['servers']['mirror'];
1354 }
1355 }
1356
1357 if (!$setmirror) {
1359 array('mirror' => $mirror));
1360 return false;
1361 }
1362
1363 $set = array('attribs' => array('version' => $version), '_content' => $name);
1364 if (!isset($setmirror[$type]['function'])) {
1365 $setmirror[$type]['function'] = $set;
1366 $this->_isValid = false;
1367 return true;
1368 } elseif (!isset($setmirror[$type]['function'][0])) {
1369 $setmirror[$type]['function'] = array($setmirror[$type]['function']);
1370 }
1371
1372 $setmirror[$type]['function'][] = $set;
1373 $this->_isValid = false;
1374 return true;
1375 }

References _validateError(), and PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND.

Referenced by addFunction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fromAny()

fromAny ( $info)

Parse channel information from different sources

This method is able to extract information about a channel from an .xml file or a string

@access public

Parameters
stringFilename of the source or the source itself
Returns
bool

Definition at line 413 of file ChannelFile.php.

414 {
415 if (is_string($info) && file_exists($info) && strlen($info) < 255) {
416 $tmp = substr($info, -4);
417 if ($tmp == '.xml') {
418 $info = $this->fromXmlFile($info);
419 } else {
420 $fp = fopen($info, "r");
421 $test = fread($fp, 5);
422 fclose($fp);
423 if ($test == "<?xml") {
424 $info = $this->fromXmlFile($info);
425 }
426 }
427 if (PEAR::isError($info)) {
428 require_once 'PEAR.php';
429 return PEAR::raiseError($info);
430 }
431 }
432 if (is_string($info)) {
433 $info = $this->fromXmlString($info);
434 }
435 return $info;
436 }
fromXmlFile($descfile)

References fromXmlFile(), and fromXmlString().

Here is the call graph for this function:

◆ fromArray()

& fromArray ( $data,
$compatibility = false,
$stackClass = 'PEAR_ErrorStack' )
static
Parameters
array
Returns
PEAR_ChannelFile|false false if invalid

Definition at line 311 of file ChannelFile.php.

313 {
314 $a = new PEAR_ChannelFile($compatibility, $stackClass);
315 $a->_fromArray($data);
316 if (!$a->validate()) {
317 $a = false;
318 return $a;
319 }
320 return $a;
321 }

Referenced by PEAR_ChannelFile_Parser\parse().

Here is the caller graph for this function:

◆ fromArrayWithErrors()

& fromArrayWithErrors ( $data,
$compatibility = false,
$stackClass = 'PEAR_ErrorStack' )
static

Unlike fromArray() this does not do any validation

Parameters
array
Returns
PEAR_ChannelFile

Definition at line 330 of file ChannelFile.php.

332 {
333 $a = new PEAR_ChannelFile($compatibility, $stackClass);
334 $a->_fromArray($data);
335 return $a;
336 }

Referenced by PEAR_Registry\_getChannel().

Here is the caller graph for this function:

◆ fromXmlFile()

fromXmlFile ( $descfile)

Parse a channel.xml file. Expects the name of a channel xml file as input.

Parameters
string$descfilename of channel xml file
Returns
bool success of parsing

Definition at line 388 of file ChannelFile.php.

389 {
390 if (!file_exists($descfile) || !is_file($descfile) || !is_readable($descfile) ||
391 (!$fp = fopen($descfile, 'r'))) {
392 require_once 'PEAR.php';
393 return PEAR::raiseError("Unable to open $descfile");
394 }
395
396 // read the whole thing so we only get one cdata callback
397 // for each block of cdata
398 fclose($fp);
399 $data = file_get_contents($descfile);
400 return $this->fromXmlString($data);
401 }

References fromXmlString().

Referenced by fromAny().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fromXmlString()

fromXmlString ( $data)
Parameters
stringcontents of package.xml file
Returns
bool success of parsing

Definition at line 268 of file ChannelFile.php.

269 {
270 if (preg_match('/<channel\s+version="([0-9]+\.[0-9]+)"/', $data, $channelversion)) {
271 if (!in_array($channelversion[1], $this->_supportedVersions)) {
272 $this->_stack->push(PEAR_CHANNELFILE_ERROR_INVALID_VERSION, 'error',
273 array('version' => $channelversion[1]));
274 return false;
275 }
276 $parser = new PEAR_XMLParser;
277 $result = $parser->parse($data);
278 if ($result !== true) {
279 if ($result->getCode() == 1) {
280 $this->_stack->push(PEAR_CHANNELFILE_ERROR_NO_XML_EXT, 'error',
281 array('error' => $result->getMessage()));
282 } else {
283 $this->_stack->push(PEAR_CHANNELFILE_ERROR_CANT_MAKE_PARSER, 'error');
284 }
285 return false;
286 }
287 $this->_channelInfo = $parser->getData();
288 return true;
289 } else {
290 $this->_stack->push(PEAR_CHANNELFILE_ERROR_NO_VERSION, 'error', array('xml' => $data));
291 return false;
292 }
293 }
$result

References $result, PEAR_CHANNELFILE_ERROR_CANT_MAKE_PARSER, PEAR_CHANNELFILE_ERROR_INVALID_VERSION, PEAR_CHANNELFILE_ERROR_NO_VERSION, and PEAR_CHANNELFILE_ERROR_NO_XML_EXT.

Referenced by PEAR_Command_Channels\doInfo(), PEAR_Command_Channels\doUpdate(), fromAny(), and fromXmlFile().

Here is the caller graph for this function:

◆ getAlias()

getAlias ( )
Returns
string

Definition at line 1264 of file ChannelFile.php.

1265 {
1266 if (isset($this->_channelInfo['localalias'])) {
1267 return $this->_channelInfo['localalias'];
1268 }
1269 if (isset($this->_channelInfo['suggestedalias'])) {
1270 return $this->_channelInfo['suggestedalias'];
1271 }
1272 if (isset($this->_channelInfo['name'])) {
1273 return $this->_channelInfo['name'];
1274 }
1275 return '';
1276 }

◆ getBaseURL()

getBaseURL ( $resourceType,
$mirror = false )

Get the URL to access a base resource.

Hyperlinks in the returned xml will be used to retrieve the proper information needed. This allows extreme extensibility and flexibility in implementation

Parameters
stringResource Type to retrieve

Definition at line 943 of file ChannelFile.php.

944 {
945 if ($mirror == $this->_channelInfo['name']) {
946 $mirror = false;
947 }
948
949 if ($mirror) {
950 $mir = $this->getMirror($mirror);
951 if (!$mir) {
952 return false;
953 }
954
955 $rest = $mir['rest'];
956 } else {
957 $rest = $this->_channelInfo['servers']['primary']['rest'];
958 }
959
960 if (!isset($rest['baseurl'][0])) {
961 $rest['baseurl'] = array($rest['baseurl']);
962 }
963
964 foreach ($rest['baseurl'] as $baseurl) {
965 if (strtolower($baseurl['attribs']['type']) == strtolower($resourceType)) {
966 return $baseurl['_content'];
967 }
968 }
969
970 return false;
971 }

References getMirror().

Here is the call graph for this function:

◆ getErrors()

getErrors ( $purge = false)

Wrapper to PEAR_ErrorStack::getErrors()

Parameters
booleandetermines whether to purge the error stack after retrieving
Returns
array

Definition at line 352 of file ChannelFile.php.

353 {
354 return $this->_stack->getErrors($purge);
355 }

◆ getFunction()

getFunction ( $type,
$name = null,
$mirror = false )
Parameters
stringProtocol type
stringFunction name (null to return the first protocol of the type requested)
stringMirror name, if any
Returns
array

Definition at line 858 of file ChannelFile.php.

859 {
860 $protocols = $this->getFunctions($type, $mirror);
861 if (!$protocols) {
862 return false;
863 }
864
865 foreach ($protocols as $protocol) {
866 if ($name === null) {
867 return $protocol;
868 }
869
870 if ($protocol['_content'] != $name) {
871 continue;
872 }
873
874 return $protocol;
875 }
876
877 return false;
878 }
getFunctions($protocol, $mirror=false)

References getFunctions().

Here is the call graph for this function:

◆ getFunctions()

getFunctions ( $protocol,
$mirror = false )
Parameters
stringprotocol type
stringMirror name
Returns
array|false

Definition at line 827 of file ChannelFile.php.

828 {
829 if ($this->getName() == '__uri') {
830 return false;
831 }
832
833 $function = $protocol == 'rest' ? 'baseurl' : 'function';
834 if ($mirror) {
835 if ($mir = $this->getMirror($mirror)) {
836 if (isset($mir[$protocol][$function])) {
837 return $mir[$protocol][$function];
838 }
839 }
840
841 return false;
842 }
843
844 if (isset($this->_channelInfo['servers']['primary'][$protocol][$function])) {
845 return $this->_channelInfo['servers']['primary'][$protocol][$function];
846 }
847
848 return false;
849 }

References getMirror(), and getName().

Referenced by getFunction(), and supports().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMirror()

getMirror ( $server)

Get the unserialized XML representing a mirror

Returns
array|false

Definition at line 1065 of file ChannelFile.php.

1066 {
1067 foreach ($this->getMirrors() as $mirror) {
1068 if ($mirror['attribs']['host'] == $server) {
1069 return $mirror;
1070 }
1071 }
1072
1073 return false;
1074 }

References getMirrors().

Referenced by getBaseURL(), getFunctions(), getPort(), getSSL(), and supportsREST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMirrors()

getMirrors ( )
Returns
array

Definition at line 1047 of file ChannelFile.php.

1048 {
1049 if (isset($this->_channelInfo['servers']['mirror'])) {
1050 $mirrors = $this->_channelInfo['servers']['mirror'];
1051 if (!isset($mirrors[0])) {
1052 $mirrors = array($mirrors);
1053 }
1054
1055 return $mirrors;
1056 }
1057
1058 return array();
1059 }

Referenced by getMirror().

Here is the caller graph for this function:

◆ getName()

getName ( )
Returns
string|false

Definition at line 733 of file ChannelFile.php.

734 {
735 if (isset($this->_channelInfo['name'])) {
736 return $this->_channelInfo['name'];
737 }
738
739 return false;
740 }

Referenced by getFunctions().

Here is the caller graph for this function:

◆ getPort()

getPort ( $mirror = false)
Returns
int|80 port number to connect to

Definition at line 757 of file ChannelFile.php.

758 {
759 if ($mirror) {
760 if ($mir = $this->getMirror($mirror)) {
761 if (isset($mir['attribs']['port'])) {
762 return $mir['attribs']['port'];
763 }
764
765 if ($this->getSSL($mirror)) {
766 return 443;
767 }
768
769 return 80;
770 }
771
772 return false;
773 }
774
775 if (isset($this->_channelInfo['servers']['primary']['attribs']['port'])) {
776 return $this->_channelInfo['servers']['primary']['attribs']['port'];
777 }
778
779 if ($this->getSSL()) {
780 return 443;
781 }
782
783 return 80;
784 }
getSSL($mirror=false)

References getMirror(), and getSSL().

Here is the call graph for this function:

◆ getServer()

getServer ( )
Returns
string|false

Definition at line 745 of file ChannelFile.php.

746 {
747 if (isset($this->_channelInfo['name'])) {
748 return $this->_channelInfo['name'];
749 }
750
751 return false;
752 }

◆ getSSL()

getSSL ( $mirror = false)
Returns
bool Determines whether secure sockets layer (SSL) is used to connect to this channel

Definition at line 789 of file ChannelFile.php.

790 {
791 if ($mirror) {
792 if ($mir = $this->getMirror($mirror)) {
793 if (isset($mir['attribs']['ssl'])) {
794 return true;
795 }
796
797 return false;
798 }
799
800 return false;
801 }
802
803 if (isset($this->_channelInfo['servers']['primary']['attribs']['ssl'])) {
804 return true;
805 }
806
807 return false;
808 }

References getMirror().

Referenced by getPort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSummary()

getSummary ( )
Returns
string|false

Definition at line 813 of file ChannelFile.php.

814 {
815 if (isset($this->_channelInfo['summary'])) {
816 return $this->_channelInfo['summary'];
817 }
818
819 return false;
820 }

◆ getValidationObject()

& getValidationObject ( $package = false)

Retrieve the object that can be used for custom validation

Parameters
string|falsethe name of the package to validate. If the package is the channel validation package, PEAR_Validate is returned
Returns
PEAR_Validate|false false is returned if the validation package cannot be located

Definition at line 1489 of file ChannelFile.php.

1490 {
1491 if (!class_exists('PEAR_Validate')) {
1492 require_once 'PEAR/Validate.php';
1493 }
1494
1495 if (!$this->_isValid) {
1496 if (!$this->validate()) {
1497 $a = false;
1498 return $a;
1499 }
1500 }
1501
1502 if (isset($this->_channelInfo['validatepackage'])) {
1503 if ($package == $this->_channelInfo['validatepackage']) {
1504 // channel validation packages are always validated by PEAR_Validate
1505 $val = new PEAR_Validate;
1506 return $val;
1507 }
1508
1509 if (!class_exists(str_replace('.', '_',
1510 $this->_channelInfo['validatepackage']['_content']))) {
1511 if ($this->isIncludeable(str_replace('_', '/',
1512 $this->_channelInfo['validatepackage']['_content']) . '.php')) {
1513 include_once str_replace('_', '/',
1514 $this->_channelInfo['validatepackage']['_content']) . '.php';
1515 $vclass = str_replace('.', '_',
1516 $this->_channelInfo['validatepackage']['_content']);
1517 $val = new $vclass;
1518 } else {
1519 $a = false;
1520 return $a;
1521 }
1522 } else {
1523 $vclass = str_replace('.', '_',
1524 $this->_channelInfo['validatepackage']['_content']);
1525 $val = new $vclass;
1526 }
1527 } else {
1528 $val = new PEAR_Validate;
1529 }
1530
1531 return $val;
1532 }

References isIncludeable(), and validate().

Here is the call graph for this function:

◆ getValidationPackage()

getValidationPackage ( )

Retrieve the name of the validation package for this channel

Returns
string|false

Definition at line 1468 of file ChannelFile.php.

1469 {
1470 if (!$this->_isValid && !$this->validate()) {
1471 return false;
1472 }
1473
1474 if (!isset($this->_channelInfo['validatepackage'])) {
1475 return array('attribs' => array('version' => 'default'),
1476 '_content' => 'PEAR_Validate');
1477 }
1478
1479 return $this->_channelInfo['validatepackage'];
1480 }

References validate().

Here is the call graph for this function:

◆ isIncludeable()

isIncludeable ( $path)

Definition at line 1534 of file ChannelFile.php.

1535 {
1536 $possibilities = explode(PATH_SEPARATOR, ini_get('include_path'));
1537 foreach ($possibilities as $dir) {
1538 if (file_exists($dir . DIRECTORY_SEPARATOR . $path)
1539 && is_readable($dir . DIRECTORY_SEPARATOR . $path)) {
1540 return true;
1541 }
1542 }
1543
1544 return false;
1545 }

Referenced by getValidationObject().

Here is the caller graph for this function:

◆ lastModified()

lastModified ( )

This function is used by the channel updater and retrieves a value set by the registry, or the current time if it has not been set

Returns
string

Definition at line 1552 of file ChannelFile.php.

1553 {
1554 if (isset($this->_channelInfo['_lastmodified'])) {
1555 return $this->_channelInfo['_lastmodified'];
1556 }
1557
1558 return time();
1559 }

◆ resetFunctions()

resetFunctions ( $type,
$mirror = false )

Empty all protocol definitions

Parameters
stringprotocol type
string|falsemirror name, if any

Definition at line 988 of file ChannelFile.php.

989 {
990 if ($mirror) {
991 if (isset($this->_channelInfo['servers']['mirror'])) {
992 $mirrors = $this->_channelInfo['servers']['mirror'];
993 if (!isset($mirrors[0])) {
994 $mirrors = array($mirrors);
995 }
996
997 foreach ($mirrors as $i => $mir) {
998 if ($mir['attribs']['host'] == $mirror) {
999 if (isset($this->_channelInfo['servers']['mirror'][$i][$type])) {
1000 unset($this->_channelInfo['servers']['mirror'][$i][$type]);
1001 }
1002
1003 return true;
1004 }
1005 }
1006
1007 return false;
1008 }
1009
1010 return false;
1011 }
1012
1013 if (isset($this->_channelInfo['servers']['primary'][$type])) {
1014 unset($this->_channelInfo['servers']['primary'][$type]);
1015 }
1016
1017 return true;
1018 }

Referenced by resetREST().

Here is the caller graph for this function:

◆ resetREST()

resetREST ( $mirror = false)

Since REST does not implement RPC, provide this as a logical wrapper around resetFunctions for REST

Parameters
string|falsemirror name, if any

Definition at line 978 of file ChannelFile.php.

979 {
980 return $this->resetFunctions('rest', $mirror);
981 }
resetFunctions($type, $mirror=false)

References resetFunctions().

Referenced by setDefaultPEARProtocols().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setAlias()

setAlias ( $alias,
$local = false )
Parameters
string
booleandetermines whether the alias is in channel.xml or local
Returns
boolean success

Definition at line 1244 of file ChannelFile.php.

1245 {
1246 if (!$this->validChannelServer($alias)) {
1248 array('tag' => 'suggestedalias', 'name' => $alias));
1249 return false;
1250 }
1251
1252 if ($local) {
1253 $this->_channelInfo['localalias'] = $alias;
1254 } else {
1255 $this->_channelInfo['suggestedalias'] = $alias;
1256 }
1257
1258 return true;
1259 }
validChannelServer($server)

References _validateError(), PEAR_CHANNELFILE_ERROR_INVALID_NAME, and validChannelServer().

Referenced by PEAR_Registry\_initializeChannelDirs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBaseURL()

setBaseURL ( $resourceType,
$url,
$mirror = false )
Parameters
stringResource Type this url links to
stringURL
string|falsemirror name, if this is not a primary server REST base URL

Definition at line 1382 of file ChannelFile.php.

1383 {
1384 if ($mirror) {
1385 if (!isset($this->_channelInfo['servers']['mirror'])) {
1387 array('mirror' => $mirror));
1388 return false;
1389 }
1390
1391 $setmirror = false;
1392 if (isset($this->_channelInfo['servers']['mirror'][0])) {
1393 foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {
1394 if ($mirror == $mir['attribs']['host']) {
1395 $setmirror = &$this->_channelInfo['servers']['mirror'][$i];
1396 break;
1397 }
1398 }
1399 } else {
1400 if ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) {
1401 $setmirror = &$this->_channelInfo['servers']['mirror'];
1402 }
1403 }
1404 } else {
1405 $setmirror = &$this->_channelInfo['servers']['primary'];
1406 }
1407
1408 $set = array('attribs' => array('type' => $resourceType), '_content' => $url);
1409 if (!isset($setmirror['rest'])) {
1410 $setmirror['rest'] = array();
1411 }
1412
1413 if (!isset($setmirror['rest']['baseurl'])) {
1414 $setmirror['rest']['baseurl'] = $set;
1415 $this->_isValid = false;
1416 return true;
1417 } elseif (!isset($setmirror['rest']['baseurl'][0])) {
1418 $setmirror['rest']['baseurl'] = array($setmirror['rest']['baseurl']);
1419 }
1420
1421 foreach ($setmirror['rest']['baseurl'] as $i => $url) {
1422 if ($url['attribs']['type'] == $resourceType) {
1423 $this->_isValid = false;
1424 $setmirror['rest']['baseurl'][$i] = $set;
1425 return true;
1426 }
1427 }
1428
1429 $setmirror['rest']['baseurl'][] = $set;
1430 $this->_isValid = false;
1431 return true;
1432 }

References _validateError(), and PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND.

Here is the call graph for this function:

◆ setDefaultPEARProtocols()

setDefaultPEARProtocols ( $version = '1.0',
$mirror = false )

Set a channel's protocols to the protocols supported by pearweb

Definition at line 1023 of file ChannelFile.php.

1024 {
1025 switch ($version) {
1026 case '1.0' :
1027 $this->resetREST($mirror);
1028
1029 if (!isset($this->_channelInfo['servers'])) {
1030 $this->_channelInfo['servers'] = array('primary' =>
1031 array('rest' => array()));
1032 } elseif (!isset($this->_channelInfo['servers']['primary'])) {
1033 $this->_channelInfo['servers']['primary'] = array('rest' => array());
1034 }
1035
1036 return true;
1037 break;
1038 default :
1039 return false;
1040 break;
1041 }
1042 }
resetREST($mirror=false)

References resetREST().

Here is the call graph for this function:

◆ setName()

setName ( $name)
Parameters
string
Returns
string|false @error PEAR_CHANNELFILE_ERROR_NO_NAME @error PEAR_CHANNELFILE_ERROR_INVALID_NAME

Definition at line 1082 of file ChannelFile.php.

1083 {
1084 return $this->setServer($name);
1085 }
setServer($server, $mirror=false)

References setServer().

Referenced by PEAR_Registry\_getChannel(), and PEAR_Registry\_initializeChannelDirs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPort()

setPort ( $port,
$mirror = false )

Set the socket number (port) that is used to connect to this channel

Parameters
integer
string|falsename of the mirror server, or false for the primary

Definition at line 1092 of file ChannelFile.php.

1093 {
1094 if ($mirror) {
1095 if (!isset($this->_channelInfo['servers']['mirror'])) {
1097 array('mirror' => $mirror));
1098 return false;
1099 }
1100
1101 if (isset($this->_channelInfo['servers']['mirror'][0])) {
1102 foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {
1103 if ($mirror == $mir['attribs']['host']) {
1104 $this->_channelInfo['servers']['mirror'][$i]['attribs']['port'] = $port;
1105 return true;
1106 }
1107 }
1108
1109 return false;
1110 } elseif ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) {
1111 $this->_channelInfo['servers']['mirror']['attribs']['port'] = $port;
1112 $this->_isValid = false;
1113 return true;
1114 }
1115 }
1116
1117 $this->_channelInfo['servers']['primary']['attribs']['port'] = $port;
1118 $this->_isValid = false;
1119 return true;
1120 }

References $port, _validateError(), and PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND.

Here is the call graph for this function:

◆ setServer()

setServer ( $server,
$mirror = false )
Parameters
string
Returns
string|false @error PEAR_CHANNELFILE_ERROR_NO_SERVER @error PEAR_CHANNELFILE_ERROR_INVALID_SERVER

Definition at line 1185 of file ChannelFile.php.

1186 {
1187 if (empty($server)) {
1188 $this->_validateError(PEAR_CHANNELFILE_ERROR_NO_SERVER);
1189 return false;
1190 } elseif (!$this->validChannelServer($server)) {
1192 array('tag' => 'name', 'name' => $server));
1193 return false;
1194 }
1195
1196 if ($mirror) {
1197 $found = false;
1198 foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {
1199 if ($mirror == $mir['attribs']['host']) {
1200 $found = true;
1201 break;
1202 }
1203 }
1204
1205 if (!$found) {
1207 array('mirror' => $mirror));
1208 return false;
1209 }
1210
1211 $this->_channelInfo['mirror'][$i]['attribs']['host'] = $server;
1212 return true;
1213 }
1214
1215 $this->_channelInfo['name'] = $server;
1216 return true;
1217 }

References _validateError(), PEAR_CHANNELFILE_ERROR_INVALID_NAME, PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND, and validChannelServer().

Referenced by PEAR_Registry\_getChannel(), and setName().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSSL()

setSSL ( $ssl = true,
$mirror = false )

Set the socket number (port) that is used to connect to this channel

Parameters
boolDetermines whether to turn on SSL support or turn it off
string|falsename of the mirror server, or false for the primary

Definition at line 1127 of file ChannelFile.php.

1128 {
1129 if ($mirror) {
1130 if (!isset($this->_channelInfo['servers']['mirror'])) {
1132 array('mirror' => $mirror));
1133 return false;
1134 }
1135
1136 if (isset($this->_channelInfo['servers']['mirror'][0])) {
1137 foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {
1138 if ($mirror == $mir['attribs']['host']) {
1139 if (!$ssl) {
1140 if (isset($this->_channelInfo['servers']['mirror'][$i]
1141 ['attribs']['ssl'])) {
1142 unset($this->_channelInfo['servers']['mirror'][$i]['attribs']['ssl']);
1143 }
1144 } else {
1145 $this->_channelInfo['servers']['mirror'][$i]['attribs']['ssl'] = 'yes';
1146 }
1147
1148 return true;
1149 }
1150 }
1151
1152 return false;
1153 } elseif ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) {
1154 if (!$ssl) {
1155 if (isset($this->_channelInfo['servers']['mirror']['attribs']['ssl'])) {
1156 unset($this->_channelInfo['servers']['mirror']['attribs']['ssl']);
1157 }
1158 } else {
1159 $this->_channelInfo['servers']['mirror']['attribs']['ssl'] = 'yes';
1160 }
1161
1162 $this->_isValid = false;
1163 return true;
1164 }
1165 }
1166
1167 if ($ssl) {
1168 $this->_channelInfo['servers']['primary']['attribs']['ssl'] = 'yes';
1169 } else {
1170 if (isset($this->_channelInfo['servers']['primary']['attribs']['ssl'])) {
1171 unset($this->_channelInfo['servers']['primary']['attribs']['ssl']);
1172 }
1173 }
1174
1175 $this->_isValid = false;
1176 return true;
1177 }

References _validateError(), and PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND.

Here is the call graph for this function:

◆ setSummary()

setSummary ( $summary)
Parameters
string
Returns
boolean success @error PEAR_CHANNELFILE_ERROR_NO_SUMMARY
Warning
PEAR_CHANNELFILE_ERROR_MULTILINE_SUMMARY

Definition at line 1225 of file ChannelFile.php.

1226 {
1227 if (empty($summary)) {
1229 return false;
1230 } elseif (strpos(trim($summary), "\n") !== false) {
1232 array('summary' => $summary));
1233 }
1234
1235 $this->_channelInfo['summary'] = $summary;
1236 return true;
1237 }
_validateWarning($code, $params=array())

References _validateError(), _validateWarning(), PEAR_CHANNELFILE_ERROR_MULTILINE_SUMMARY, and PEAR_CHANNELFILE_ERROR_NO_SUMMARY.

Here is the call graph for this function:

◆ setValidationPackage()

setValidationPackage ( $validateclass,
$version )

Set the package validation object if it differs from PEAR's default The class must be includeable via changing _ in the classname to path separator, but no checking of this is made.

Parameters
string|falsepass in false to reset to the default packagename regex
Returns
boolean success

Definition at line 1285 of file ChannelFile.php.

1286 {
1287 if (empty($validateclass)) {
1288 unset($this->_channelInfo['validatepackage']);
1289 }
1290 $this->_channelInfo['validatepackage'] = array('_content' => $validateclass);
1291 $this->_channelInfo['validatepackage']['attribs'] = array('version' => $version);
1292 }

◆ supports()

supports ( $type,
$name = null,
$mirror = false,
$version = '1.0' )
Parameters
stringprotocol type
stringprotocol name
stringversion
stringmirror name
Returns
boolean

Definition at line 887 of file ChannelFile.php.

888 {
889 $protocols = $this->getFunctions($type, $mirror);
890 if (!$protocols) {
891 return false;
892 }
893
894 foreach ($protocols as $protocol) {
895 if ($protocol['attribs']['version'] != $version) {
896 continue;
897 }
898
899 if ($name === null) {
900 return true;
901 }
902
903 if ($protocol['_content'] != $name) {
904 continue;
905 }
906
907 return true;
908 }
909
910 return false;
911 }

References getFunctions().

Here is the call graph for this function:

◆ supportsREST()

supportsREST ( $mirror = false)

Determines whether a channel supports Representational State Transfer (REST) protocols for retrieving channel information

Parameters
string
Returns
bool

Definition at line 919 of file ChannelFile.php.

920 {
921 if ($mirror == $this->_channelInfo['name']) {
922 $mirror = false;
923 }
924
925 if ($mirror) {
926 if ($mir = $this->getMirror($mirror)) {
927 return isset($mir['rest']);
928 }
929
930 return false;
931 }
932
933 return isset($this->_channelInfo['servers']['primary']['rest']);
934 }

References getMirror().

Here is the call graph for this function:

◆ toArray()

toArray ( )
Returns
array

Definition at line 298 of file ChannelFile.php.

299 {
300 if (!$this->_isValid && !$this->validate()) {
301 return false;
302 }
303 return $this->_channelInfo;
304 }

References $_channelInfo, and validate().

Here is the call graph for this function:

◆ toXml()

toXml ( )

Return an XML document based on previous parsing and modifications

Returns
string XML data

@access public

Definition at line 445 of file ChannelFile.php.

446 {
447 if (!$this->_isValid && !$this->validate()) {
449 return false;
450 }
451 if (!isset($this->_channelInfo['attribs']['version'])) {
452 $this->_channelInfo['attribs']['version'] = '1.0';
453 }
454 $channelInfo = $this->_channelInfo;
455 $ret = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
456 $ret .= "<channel version=\"" .
457 $channelInfo['attribs']['version'] . "\" xmlns=\"http://pear.php.net/channel-1.0\"
458 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
459 xsi:schemaLocation=\"http://pear.php.net/dtd/channel-"
460 . $channelInfo['attribs']['version'] . " http://pear.php.net/dtd/channel-" .
461 $channelInfo['attribs']['version'] . ".xsd\">
462 <name>$channelInfo[name]</name>
463 <summary>" . htmlspecialchars($channelInfo['summary'])."</summary>
464";
465 if (isset($channelInfo['suggestedalias'])) {
466 $ret .= ' <suggestedalias>' . $channelInfo['suggestedalias'] . "</suggestedalias>\n";
467 }
468 if (isset($channelInfo['validatepackage'])) {
469 $ret .= ' <validatepackage version="' .
470 $channelInfo['validatepackage']['attribs']['version']. '">' .
471 htmlspecialchars($channelInfo['validatepackage']['_content']) .
472 "</validatepackage>\n";
473 }
474 $ret .= " <servers>\n";
475 $ret .= ' <primary';
476 if (isset($channelInfo['servers']['primary']['attribs']['ssl'])) {
477 $ret .= ' ssl="' . $channelInfo['servers']['primary']['attribs']['ssl'] . '"';
478 }
479 if (isset($channelInfo['servers']['primary']['attribs']['port'])) {
480 $ret .= ' port="' . $channelInfo['servers']['primary']['attribs']['port'] . '"';
481 }
482 $ret .= ">\n";
483 if (isset($channelInfo['servers']['primary']['rest'])) {
484 $ret .= $this->_makeRestXml($channelInfo['servers']['primary']['rest'], ' ');
485 }
486 $ret .= " </primary>\n";
487 if (isset($channelInfo['servers']['mirror'])) {
488 $ret .= $this->_makeMirrorsXml($channelInfo);
489 }
490 $ret .= " </servers>\n";
491 $ret .= "</channel>";
492 return str_replace("\r", "\n", str_replace("\r\n", "\n", $ret));
493 }
_makeMirrorsXml($channelInfo)

References $_channelInfo, _makeMirrorsXml(), _makeRestXml(), _validateError(), PEAR_CHANNELFILE_ERROR_INVALID, and validate().

Here is the call graph for this function:

◆ validate()

validate ( )

Validate parsed file.

@access public

Returns
boolean

Definition at line 596 of file ChannelFile.php.

597 {
598 $this->_isValid = true;
599 $info = $this->_channelInfo;
600 if (empty($info['name'])) {
602 } elseif (!$this->validChannelServer($info['name'])) {
603 if ($info['name'] != '__uri') {
604 $this->_validateError(PEAR_CHANNELFILE_ERROR_INVALID_NAME, array('tag' => 'name',
605 'name' => $info['name']));
606 }
607 }
608 if (empty($info['summary'])) {
610 } elseif (strpos(trim($info['summary']), "\n") !== false) {
612 array('summary' => $info['summary']));
613 }
614 if (isset($info['suggestedalias'])) {
615 if (!$this->validChannelServer($info['suggestedalias'])) {
617 array('tag' => 'suggestedalias', 'name' =>$info['suggestedalias']));
618 }
619 }
620 if (isset($info['localalias'])) {
621 if (!$this->validChannelServer($info['localalias'])) {
623 array('tag' => 'localalias', 'name' =>$info['localalias']));
624 }
625 }
626 if (isset($info['validatepackage'])) {
627 if (!isset($info['validatepackage']['_content'])) {
629 }
630 if (!isset($info['validatepackage']['attribs']['version'])) {
631 $content = isset($info['validatepackage']['_content']) ?
632 $info['validatepackage']['_content'] :
633 null;
635 array('package' => $content));
636 }
637 }
638
639 if (isset($info['servers']['primary']['attribs'], $info['servers']['primary']['attribs']['port']) &&
640 !is_numeric($info['servers']['primary']['attribs']['port'])) {
642 array('port' => $info['servers']['primary']['attribs']['port']));
643 }
644
645 if (isset($info['servers']['primary']['attribs'], $info['servers']['primary']['attribs']['ssl']) &&
646 $info['servers']['primary']['attribs']['ssl'] != 'yes') {
648 array('ssl' => $info['servers']['primary']['attribs']['ssl'],
649 'server' => $info['name']));
650 }
651
652 if (isset($info['servers']['primary']['rest']) &&
653 isset($info['servers']['primary']['rest']['baseurl'])) {
654 $this->_validateFunctions('rest', $info['servers']['primary']['rest']['baseurl']);
655 }
656 if (isset($info['servers']['mirror'])) {
657 if ($this->_channelInfo['name'] == '__uri') {
659 }
660 if (!isset($info['servers']['mirror'][0])) {
661 $info['servers']['mirror'] = array($info['servers']['mirror']);
662 }
663 foreach ($info['servers']['mirror'] as $mirror) {
664 if (!isset($mirror['attribs']['host'])) {
666 array('type' => 'mirror'));
667 } elseif (!$this->validChannelServer($mirror['attribs']['host'])) {
669 array('server' => $mirror['attribs']['host'], 'type' => 'mirror'));
670 }
671 if (isset($mirror['attribs']['ssl']) && $mirror['attribs']['ssl'] != 'yes') {
673 array('ssl' => $info['ssl'], 'server' => $mirror['attribs']['host']));
674 }
675 if (isset($mirror['rest'])) {
676 $this->_validateFunctions('rest', $mirror['rest']['baseurl'],
677 $mirror['attribs']['host']);
678 }
679 }
680 }
681 return $this->_isValid;
682 }
_validateFunctions($protocol, $functions, $parent='')

References $_channelInfo, $_isValid, _validateError(), _validateFunctions(), _validateWarning(), PEAR_CHANNELFILE_ERROR_INVALID_HOST, PEAR_CHANNELFILE_ERROR_INVALID_NAME, PEAR_CHANNELFILE_ERROR_INVALID_PORT, PEAR_CHANNELFILE_ERROR_INVALID_SSL, PEAR_CHANNELFILE_ERROR_MULTILINE_SUMMARY, PEAR_CHANNELFILE_ERROR_NO_HOST, PEAR_CHANNELFILE_ERROR_NO_NAME, PEAR_CHANNELFILE_ERROR_NO_SUMMARY, PEAR_CHANNELFILE_ERROR_NOVALIDATE_NAME, PEAR_CHANNELFILE_ERROR_NOVALIDATE_VERSION, PEAR_CHANNELFILE_URI_CANT_MIRROR, and validChannelServer().

Referenced by getValidationObject(), getValidationPackage(), toArray(), and toXml().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validChannelServer()

validChannelServer ( $server)

Test whether a string contains a valid channel server.

Parameters
string$verthe package version to test
Returns
bool

Definition at line 722 of file ChannelFile.php.

723 {
724 if ($server == '__uri') {
725 return true;
726 }
727 return (bool) preg_match(PEAR_CHANNELS_SERVER_PREG, $server);
728 }
const PEAR_CHANNELS_SERVER_PREG
Definition Common.php:46

References PEAR_CHANNELS_SERVER_PREG.

Referenced by setAlias(), setServer(), and validate().

Here is the caller graph for this function:

Field Documentation

◆ $_channelInfo

$_channelInfo

Definition at line 173 of file ChannelFile.php.

Referenced by toArray(), toXml(), and validate().

◆ $_isValid

$_isValid = false

Definition at line 194 of file ChannelFile.php.

Referenced by validate().

◆ $_mirrorIndex

$_mirrorIndex

Definition at line 187 of file ChannelFile.php.

◆ $_stack

$_stack

Definition at line 159 of file ChannelFile.php.

◆ $_subchannelIndex

$_subchannelIndex

Definition at line 180 of file ChannelFile.php.

◆ $_supportedVersions

$_supportedVersions = array('1.0')

Definition at line 166 of file ChannelFile.php.


The documentation for this class was generated from the following file:
  • E:/Bearsampp-development/sandbox/core/libs/php/pear/pear/PEAR/ChannelFile.php