items() public method

Returns an array of (key, value) pairs in the mapping.
public items ( )
Beispiel #1
0
 /**
  * @access private
  */
 function _fromOpenIDArgs($openid_args)
 {
     global $Auth_OpenID_registered_aliases;
     // Takes an Auth_OpenID_Mapping instance OR an array.
     if (!Auth_OpenID_Mapping::isA($openid_args)) {
         $openid_args = new Auth_OpenID_Mapping($openid_args);
     }
     $ns_args = array();
     // Resolve namespaces
     foreach ($openid_args->items() as $pair) {
         list($rest, $value) = $pair;
         $parts = explode('.', $rest, 2);
         if (count($parts) == 2) {
             list($ns_alias, $ns_key) = $parts;
         } else {
             $ns_alias = Auth_OpenID_NULL_NAMESPACE;
             $ns_key = $rest;
         }
         if ($ns_alias == 'ns') {
             if ($this->namespaces->addAlias($value, $ns_key) === null) {
                 return false;
             }
         } elseif ($ns_alias == Auth_OpenID_NULL_NAMESPACE && $ns_key == 'ns') {
             // null namespace
             if ($this->setOpenIDNamespace($value, false) === false) {
                 return false;
             }
         } else {
             $ns_args[] = array($ns_alias, $ns_key, $value);
         }
     }
     if (!$this->getOpenIDNamespace()) {
         if ($this->setOpenIDNamespace(Auth_OpenID_OPENID1_NS, true) === false) {
             return false;
         }
     }
     // Actually put the pairs into the appropriate namespaces
     foreach ($ns_args as $triple) {
         list($ns_alias, $ns_key, $value) = $triple;
         $ns_uri = $this->namespaces->getNamespaceURI($ns_alias);
         if ($ns_uri === null) {
             $ns_uri = $this->_getDefaultNamespace($ns_alias);
             if ($ns_uri === null) {
                 $ns_uri = Auth_OpenID_OPENID_NS;
                 $ns_key = sprintf('%s.%s', $ns_alias, $ns_key);
             } else {
                 $this->namespaces->addAlias($ns_uri, $ns_alias, true);
             }
         }
         $this->setArg($ns_uri, $ns_key, $value);
     }
     return true;
 }
Beispiel #2
0
 /**
  * @access private
  */
 function _fromOpenIDArgs($openid_args)
 {
     global $Auth_OpenID_registered_aliases;
     // Takes an Auth_OpenID_Mapping instance OR an array.
     if (!Auth_OpenID_Mapping::isA($openid_args)) {
         $openid_args = new Auth_OpenID_Mapping($openid_args);
     }
     $ns_args = array();
     // Resolve namespaces
     foreach ($openid_args->items() as $pair) {
         list($rest, $value) = $pair;
         $parts = explode('.', $rest, 2);
         if (count($parts) == 2) {
             list($ns_alias, $ns_key) = $parts;
         } else {
             $ns_alias = Auth_OpenID_NULL_NAMESPACE;
             $ns_key = $rest;
         }
         if ($ns_alias == 'ns') {
             if ($this->namespaces->addAlias($value, $ns_key) === null) {
                 return false;
             }
         } else {
             if ($ns_alias == Auth_OpenID_NULL_NAMESPACE && $ns_key == 'ns') {
                 // null namespace
                 if ($this->namespaces->addAlias($value, Auth_OpenID_NULL_NAMESPACE) === null) {
                     return false;
                 }
             } else {
                 $ns_args[] = array($ns_alias, $ns_key, $value);
             }
         }
     }
     // Ensure that there is an OpenID namespace definition
     $openid_ns_uri = $this->namespaces->getNamespaceURI(Auth_OpenID_NULL_NAMESPACE);
     if ($openid_ns_uri === null) {
         $openid_ns_uri = Auth_OpenID_OPENID1_NS;
     }
     $this->setOpenIDNamespace($openid_ns_uri);
     // Actually put the pairs into the appropriate namespaces
     foreach ($ns_args as $triple) {
         list($ns_alias, $ns_key, $value) = $triple;
         $ns_uri = $this->namespaces->getNamespaceURI($ns_alias);
         if ($ns_uri === null) {
             // Only try to map an alias to a default if it's an
             // OpenID 1.x message.
             if ($openid_ns_uri == Auth_OpenID_OPENID1_NS) {
                 foreach ($Auth_OpenID_registered_aliases as $alias => $uri) {
                     if ($alias == $ns_alias) {
                         $ns_uri = $uri;
                         break;
                     }
                 }
             }
             if ($ns_uri === null) {
                 $ns_uri = $openid_ns_uri;
                 $ns_key = sprintf('%s.%s', $ns_alias, $ns_key);
             } else {
                 $this->namespaces->addAlias($ns_uri, $ns_alias);
             }
         }
         $this->setArg($ns_uri, $ns_key, $value);
     }
     return true;
 }