php Auth_Yadis_getXMLParser类(方法)实例源码

下面列出了php Auth_Yadis_getXMLParser 类(方法)源码代码实例,从而了解它的用法。

作者:Jobav    项目:diacritice-meta-rep   
function detect_xml($r, &$out)
{
    global $__Auth_Yadis_xml_extensions;
    $out .= $r->h2('XML Support');
    // Try to get an XML extension.
    $ext = Auth_Yadis_getXMLParser();
    if ($ext !== null) {
        $out .= $r->p('XML parsing support is present using the ' . $r->b(get_class($ext)) . ' interface.');
        return true;
    } else {
        $out .= $r->p('XML parsing support is absent; please install one ' . 'of the following PHP extensions:');
        foreach ($__Auth_Yadis_xml_extensions as $name => $cls) {
            $out .= "<li>" . $r->b($name) . "</li>";
        }
        return false;
    }
}

作者:Jobav    项目:diacritice-meta-rep   
function _checkForm($html, $message_, $action_url, $form_tag_attrs, $submit_text)
 {
     $parser =& Auth_Yadis_getXMLParser();
     // Parse HTML source
     $this->assertTrue($parser->init($html, array()));
     // Get root element
     $form = $parser->evalXPath('/form[1]');
     $this->assertTrue(count($form) == 1);
     $form = $form[0];
     // Check required form attributes
     $form_attrs = $parser->attributes($form);
     foreach ($this->required_form_attrs as $k => $v) {
         $this->assertTrue($form_attrs[$k] == $v);
     }
     // Check extra form attributes
     foreach ($form_tag_attrs as $k => $v) {
         // Skip attributes that already passed the required
         // attribute check, since they should be ignored by the
         // form generation code.
         if (in_array($k, array_keys($this->required_form_attrs))) {
             continue;
         }
         $this->assertTrue($form_attrs[$k] == $v, "Form attr {$k} is " . $form_attrs[$k] . " (expected {$v})");
     }
     // Check hidden fields against post args
     $hiddens = array();
     $input_elements = $parser->evalXPath('input', $form);
     foreach ($input_elements as $e) {
         $attrs = $parser->attributes($e);
         if (strtoupper($attrs['type']) == 'HIDDEN') {
             $hiddens[] = $e;
         }
     }
     // For each post arg, make sure there is a hidden with that
     // value.  Make sure there are no other hiddens.
     $postargs = $message_->toPostArgs();
     foreach ($postargs as $name => $value) {
         $found = false;
         foreach ($hiddens as $e) {
             $attrs = $parser->attributes($e);
             if ($attrs['name'] == $name) {
                 $this->assertTrue($attrs['value'] == $value);
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             $this->fail("Post arg {$name} not found in form");
         }
     }
     $keys = array_keys($postargs);
     foreach ($hiddens as $e) {
         $attrs = $parser->attributes($e);
         $this->assertTrue(in_array($attrs['name'], $keys));
     }
     // Check action URL
     $this->assertTrue($form_attrs['action'] == $action_url);
     // Check submit text
     $submits = array();
     foreach ($input_elements as $e) {
         $attrs = $parser->attributes($e);
         if (strtoupper($attrs['type']) == 'SUBMIT') {
             $submits[] = $e;
         }
     }
     $this->assertTrue(count($submits) == 1);
     $attrs = $parser->attributes($submits[0]);
     $this->assertTrue($attrs['value'] == $submit_text);
 }

作者:sdgdsffdsff    项目:auth-cente   
/**
  * Parse an XML string (XRDS document) and return either a
  * Auth_Yadis_XRDS object or null, depending on whether the
  * XRDS XML is valid.
  *
  * @param string $xml_string An XRDS XML string.
  * @return mixed $xrds An instance of Auth_Yadis_XRDS or null,
  * depending on the validity of $xml_string
  */
 function &parseXRDS($xml_string, $extra_ns_map = null)
 {
     $_null = null;
     if (!$xml_string) {
         return $_null;
     }
     $parser = Auth_Yadis_getXMLParser();
     $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;
 }


问题


面经


文章

微信
公众号

扫码关注公众号