ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
Auth_Yadis_XRDS Class Reference
+ Collaboration diagram for Auth_Yadis_XRDS:

Public Member Functions

 Auth_Yadis_XRDS ($xmlParser, $xrdNodes)
 Instantiate a Auth_Yadis_XRDS object.
 _addService ($priority, $service)
 private
 _parse ()
 Creates the service list using nodes from the XRDS XML document.
 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.

Static Public Member Functions

static 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.

Detailed Description

Definition at line 252 of file XRDS.php.

Member Function Documentation

Auth_Yadis_XRDS::_addService (   $priority,
  $service 
)

private

Definition at line 331 of file XRDS.php.

Referenced by _parse().

{
$priority = intval($priority);
if (!array_key_exists($priority, $this->serviceList)) {
$this->serviceList[$priority] = array();
}
$this->serviceList[$priority][] = $service;
}

+ Here is the caller graph for this function:

Auth_Yadis_XRDS::_parse ( )

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

private

Definition at line 348 of file XRDS.php.

References _addService(), and SERVICES_YADIS_MAX_PRIORITY.

Referenced by Auth_Yadis_XRDS().

{
$this->serviceList = array();
$services = $this->parser->evalXPath('xrd:Service', $this->xrdNode);
foreach ($services as $node) {
$s = new Auth_Yadis_Service();
$s->element = $node;
$s->parser = $this->parser;
$priority = $s->getPriority();
if ($priority === null) {
}
$this->_addService($priority, $s);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_Yadis_XRDS::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.

Definition at line 258 of file XRDS.php.

References _parse().

Referenced by parseXRDS().

{
$this->parser = $xmlParser;
$this->xrdNode = $xrdNodes[count($xrdNodes) - 1];
$this->allXrdNodes = $xrdNodes;
$this->serviceList = array();
$this->_parse();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static Auth_Yadis_XRDS::parseXRDS (   $xml_string,
  $extra_ns_map = null 
)
static

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

Parameters
string$xml_stringAn XRDS XML string.
Returns
mixed $xrds An instance of Auth_Yadis_XRDS or null, depending on the validity of $xml_string

Definition at line 276 of file XRDS.php.

References Auth_Yadis_getNSMap(), Auth_Yadis_getXMLParser(), Auth_Yadis_XMLNS_XRD_2_0, Auth_Yadis_XMLNS_XRDS, and Auth_Yadis_XRDS().

Referenced by Auth_OpenID_ServiceEndpoint\consumerFromXRDS(), Auth_OpenID_ServiceEndpoint\fromXRDS(), and Auth_Yadis_ProxyResolver\query().

{
$_null = null;
if (!$xml_string) {
return $_null;
}
$ns_map = Auth_Yadis_getNSMap();
if ($extra_ns_map && is_array($extra_ns_map)) {
$ns_map = array_merge($ns_map, $extra_ns_map);
}
if (!($parser && $parser->init($xml_string, $ns_map))) {
return $_null;
}
// Try to get root element.
$root = $parser->evalXPath('/xrds:XRDS[1]');
if (!$root) {
return $_null;
}
if (is_array($root)) {
$root = $root[0];
}
$attrs = $parser->attributes($root);
if (array_key_exists('xmlns:xrd', $attrs) &&
$attrs['xmlns:xrd'] != Auth_Yadis_XMLNS_XRDS) {
return $_null;
} else if (array_key_exists('xmlns', $attrs) &&
preg_match('/xri/', $attrs['xmlns']) &&
$attrs['xmlns'] != Auth_Yadis_XMLNS_XRD_2_0) {
return $_null;
}
// Get the last XRD node.
$xrd_nodes = $parser->evalXPath('/xrds:XRDS[1]/xrd:XRD');
if (!$xrd_nodes) {
return $_null;
}
$xrds = new Auth_Yadis_XRDS($parser, $xrd_nodes);
return $xrds;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_Yadis_XRDS::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.

Parameters
mixed$filtersAn array of callbacks to filter the returned services, or null if all services are to be returned.
integer$filter_modeSERVICES_YADIS_MATCH_ALL or SERVICES_YADIS_MATCH_ANY, depending on whether the returned services should match ALL or ANY of the specified filters, respectively.
Returns
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).

Definition at line 393 of file XRDS.php.

References $result, SERVICES_YADIS_MATCH_ALL, SERVICES_YADIS_MATCH_ANY, and SERVICES_YADIS_MAX_PRIORITY.

{
$pri_keys = array_keys($this->serviceList);
sort($pri_keys, SORT_NUMERIC);
// If no filters are specified, return the entire service
// list, ordered by priority.
if (!$filters ||
(!is_array($filters))) {
$result = array();
foreach ($pri_keys as $pri) {
$result = array_merge($result, $this->serviceList[$pri]);
}
return $result;
}
// If a bad filter mode is specified, return null.
if (!in_array($filter_mode, array(SERVICES_YADIS_MATCH_ANY,
return null;
}
// Otherwise, use the callbacks in the filter list to
// determine which services are returned.
$filtered = array();
foreach ($pri_keys as $priority_value) {
$service_obj_list = $this->serviceList[$priority_value];
foreach ($service_obj_list as $service) {
$matches = 0;
foreach ($filters as $filter) {
if (call_user_func_array($filter, array(&$service))) {
$matches++;
if ($filter_mode == SERVICES_YADIS_MATCH_ANY) {
$pri = $service->getPriority();
if ($pri === null) {
}
if (!array_key_exists($pri, $filtered)) {
$filtered[$pri] = array();
}
$filtered[$pri][] = $service;
break;
}
}
}
if (($filter_mode == SERVICES_YADIS_MATCH_ALL) &&
($matches == count($filters))) {
$pri = $service->getPriority();
if ($pri === null) {
}
if (!array_key_exists($pri, $filtered)) {
$filtered[$pri] = array();
}
$filtered[$pri][] = $service;
}
}
}
$pri_keys = array_keys($filtered);
sort($pri_keys, SORT_NUMERIC);
$result = array();
foreach ($pri_keys as $pri) {
$result = array_merge($result, $filtered[$pri]);
}
return $result;
}

The documentation for this class was generated from the following file: