Auth_Yadis_XRDS Klassenreferenz


Öffentliche Methoden

 Auth_Yadis_XRDS (&$xmlParser, &$xrdNodes)
parseXRDS ($xml_string, $extra_ns_map=null)
 _addService ($priority, $service)
 _parse ()
 services ($filters=null, $filter_mode=SERVICES_YADIS_MATCH_ANY)

Ausführliche Beschreibung

Definiert in Zeile 252 der Datei XRDS.php.


Dokumentation der Elementfunktionen

_addService ( priority,
service 
)

private

Definiert in Zeile 331 der Datei XRDS.php.

00332     {
00333         $priority = intval($priority);
00334 
00335         if (!array_key_exists($priority, $this->serviceList)) {
00336             $this->serviceList[$priority] = array();
00337         }
00338 
00339         $this->serviceList[$priority][] = $service;
00340     }

_parse (  ) 

Creates the service list using nodes from the XRDS XML document.

private

Definiert in Zeile 348 der Datei XRDS.php.

00349     {
00350         $this->serviceList = array();
00351 
00352         $services = $this->parser->evalXPath('xrd:Service', $this->xrdNode);
00353 
00354         foreach ($services as $node) {
00355             $s =& new Auth_Yadis_Service();
00356             $s->element = $node;
00357             $s->parser =& $this->parser;
00358 
00359             $priority = $s->getPriority();
00360 
00361             if ($priority === null) {
00362                 $priority = SERVICES_YADIS_MAX_PRIORITY;
00363             }
00364 
00365             $this->_addService($priority, $s);
00366         }
00367     }

Auth_Yadis_XRDS ( &$  xmlParser,
&$  xrdNodes 
)

Instantiate a Auth_Yadis_XRDS object. Requires an XPath instance which has been used to parse a valid XRDS document.

Definiert in Zeile 258 der Datei XRDS.php.

00259     {
00260         $this->parser =& $xmlParser;
00261         $this->xrdNode = $xrdNodes[count($xrdNodes) - 1];
00262         $this->allXrdNodes =& $xrdNodes;
00263         $this->serviceList = array();
00264         $this->_parse();
00265     }

& parseXRDS ( xml_string,
extra_ns_map = null 
)

Parse an XML string (XRDS document) and return either a Auth_Yadis_XRDS object or null, depending on whether the XRDS XML is valid.

Parameter:
string $xml_string An XRDS XML string.
Rückgabe:
mixed $xrds An instance of Auth_Yadis_XRDS or null, depending on the validity of $xml_string

Definiert in Zeile 276 der Datei XRDS.php.

00277     {
00278         $_null = null;
00279 
00280         if (!$xml_string) {
00281             return $_null;
00282         }
00283 
00284         $parser = Auth_Yadis_getXMLParser();
00285 
00286         $ns_map = Auth_Yadis_getNSMap();
00287 
00288         if ($extra_ns_map && is_array($extra_ns_map)) {
00289             $ns_map = array_merge($ns_map, $extra_ns_map);
00290         }
00291 
00292         if (!($parser && $parser->init($xml_string, $ns_map))) {
00293             return $_null;
00294         }
00295 
00296         // Try to get root element.
00297         $root = $parser->evalXPath('/xrds:XRDS[1]');
00298         if (!$root) {
00299             return $_null;
00300         }
00301 
00302         if (is_array($root)) {
00303             $root = $root[0];
00304         }
00305 
00306         $attrs = $parser->attributes($root);
00307 
00308         if (array_key_exists('xmlns:xrd', $attrs) &&
00309             $attrs['xmlns:xrd'] != Auth_Yadis_XMLNS_XRDS) {
00310             return $_null;
00311         } else if (array_key_exists('xmlns', $attrs) &&
00312                    preg_match('/xri/', $attrs['xmlns']) &&
00313                    $attrs['xmlns'] != Auth_Yadis_XMLNS_XRD_2_0) {
00314             return $_null;
00315         }
00316 
00317         // Get the last XRD node.
00318         $xrd_nodes = $parser->evalXPath('/xrds:XRDS[1]/xrd:XRD');
00319 
00320         if (!$xrd_nodes) {
00321             return $_null;
00322         }
00323 
00324         $xrds = new Auth_Yadis_XRDS($parser, $xrd_nodes);
00325         return $xrds;
00326     }

services ( filters = null,
filter_mode = SERVICES_YADIS_MATCH_ANY 
)

Returns a list of service objects which correspond to <Service> elements in the XRDS XML document for this object.

Optionally, an array of filter callbacks may be given to limit the list of returned service objects. Furthermore, the default mode is to return all service objects which match ANY of the specified filters, but $filter_mode may be SERVICES_YADIS_MATCH_ALL if you want to be sure that the returned services match all the given filters. See Auth_Yadis_Yadis for detailed usage information on filter functions.

Parameter:
mixed $filters An array of callbacks to filter the returned services, or null if all services are to be returned.
integer $filter_mode SERVICES_YADIS_MATCH_ALL or SERVICES_YADIS_MATCH_ANY, depending on whether the returned services should match ALL or ANY of the specified filters, respectively.
Rückgabe:
mixed $services An array of Auth_Yadis_Service objects if $filter_mode is a valid mode; null if $filter_mode is an invalid mode (i.e., not SERVICES_YADIS_MATCH_ANY or SERVICES_YADIS_MATCH_ALL).

Definiert in Zeile 393 der Datei XRDS.php.

00395     {
00396 
00397         $pri_keys = array_keys($this->serviceList);
00398         sort($pri_keys, SORT_NUMERIC);
00399 
00400         // If no filters are specified, return the entire service
00401         // list, ordered by priority.
00402         if (!$filters ||
00403             (!is_array($filters))) {
00404 
00405             $result = array();
00406             foreach ($pri_keys as $pri) {
00407                 $result = array_merge($result, $this->serviceList[$pri]);
00408             }
00409 
00410             return $result;
00411         }
00412 
00413         // If a bad filter mode is specified, return null.
00414         if (!in_array($filter_mode, array(SERVICES_YADIS_MATCH_ANY,
00415                                           SERVICES_YADIS_MATCH_ALL))) {
00416             return null;
00417         }
00418 
00419         // Otherwise, use the callbacks in the filter list to
00420         // determine which services are returned.
00421         $filtered = array();
00422 
00423         foreach ($pri_keys as $priority_value) {
00424             $service_obj_list = $this->serviceList[$priority_value];
00425 
00426             foreach ($service_obj_list as $service) {
00427 
00428                 $matches = 0;
00429 
00430                 foreach ($filters as $filter) {
00431                     if (call_user_func_array($filter, array($service))) {
00432                         $matches++;
00433 
00434                         if ($filter_mode == SERVICES_YADIS_MATCH_ANY) {
00435                             $pri = $service->getPriority();
00436                             if ($pri === null) {
00437                                 $pri = SERVICES_YADIS_MAX_PRIORITY;
00438                             }
00439 
00440                             if (!array_key_exists($pri, $filtered)) {
00441                                 $filtered[$pri] = array();
00442                             }
00443 
00444                             $filtered[$pri][] = $service;
00445                             break;
00446                         }
00447                     }
00448                 }
00449 
00450                 if (($filter_mode == SERVICES_YADIS_MATCH_ALL) &&
00451                     ($matches == count($filters))) {
00452 
00453                     $pri = $service->getPriority();
00454                     if ($pri === null) {
00455                         $pri = SERVICES_YADIS_MAX_PRIORITY;
00456                     }
00457 
00458                     if (!array_key_exists($pri, $filtered)) {
00459                         $filtered[$pri] = array();
00460                     }
00461                     $filtered[$pri][] = $service;
00462                 }
00463             }
00464         }
00465 
00466         $pri_keys = array_keys($filtered);
00467         sort($pri_keys, SORT_NUMERIC);
00468 
00469         $result = array();
00470         foreach ($pri_keys as $pri) {
00471             $result = array_merge($result, $filtered[$pri]);
00472         }
00473 
00474         return $result;
00475     }


Die Dokumentation für diese Klasse wurde erzeugt aufgrund der Datei:
Copyright © 2003 - 2009 MyOOS [Shopsystem]. All rights reserved.
MyOOS [Shopsystem] is Free Software released under the GNU/GPL License.

Webmaster: info@r23.de (Impressum)
doxygen