当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Dom_Query::setDocumentHtml方法代码示例

本文整理汇总了PHP中Zend_Dom_Query::setDocumentHtml方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Dom_Query::setDocumentHtml方法的具体用法?PHP Zend_Dom_Query::setDocumentHtml怎么用?PHP Zend_Dom_Query::setDocumentHtml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Dom_Query的用法示例。


在下文中一共展示了Zend_Dom_Query::setDocumentHtml方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _changeExternalLinks

 protected static function _changeExternalLinks(&$content)
 {
     if (empty($content)) {
         return;
     }
     $dom = new Zend_Dom_Query();
     $dom->setDocumentHtml($content, 'utf-8');
     if ($dom->getDocumentErrors()) {
         return;
     }
     $query = $dom->query('.externalLink');
     if (!$query->count()) {
         return;
     }
     $links = array();
     /** @var DOMElement $a */
     foreach ($query as $a) {
         $link = $a->getAttribute('href');
         if (empty($link)) {
             continue;
         }
         $links[] = $link;
         GFNLinkProxy_Api::preload($link);
     }
     foreach ($links as $link) {
         $content = preg_replace_callback('#(<a[^>]+href=("|\')?)(' . preg_quote($link, '#') . ')(("|\')?[^>]+class=("|\')?[^"\']*externalLink[^"\']*("|\')?[^>]*>)#sU', array(__CLASS__, '_replace'), $content, 1);
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:28,代码来源:FrontController.php

示例2: getNewSizingChartContent

 /**
  * Get Sizing Chart content from remote resource
  */
 public function getNewSizingChartContent($ptn)
 {
     if ($ptn) {
         $uri = Mage::getStoreConfig('yk_config/asc/url') . $ptn;
         $client = new Zend_Http_Client();
         $client->setUri($uri);
         $response = $client->request();
         if ($html = $response->getBody()) {
             $dom = new Zend_Dom_Query();
             $dom->setDocumentHtml($html);
             $results = $dom->query(Mage::getStoreConfig('yk_config/asc/container'));
             if (count($results)) {
                 foreach ($results as $result) {
                     $innerHTML = '';
                     $children = $result->childNodes;
                     foreach ($children as $child) {
                         $innerHTML .= $child->ownerDocument->saveHTML($child);
                     }
                     return $innerHTML;
                 }
             }
         }
     }
     return false;
 }
开发者ID:Vedariy,项目名称:test,代码行数:28,代码来源:Chart.php

示例3: assertionsForHTMLConcept

 private function assertionsForHTMLConcept($response, $prefLabel, $altLabel, $hiddenLabel, $lang, $definition, $notation, $topConceptOf, $inScheme)
 {
     $dom = new Zend_Dom_Query();
     $dom->setDocumentHtml($response->getBody());
     //does not work because of . : $results1 = $dom->query('dl > dd  > a[href="http://hdl.handle.net/11148/CCR_C-4046_944cc750-1c29-ccf0-fb68-4d00385d7b42"]');
     $resultsUri1 = $dom->query('dl > dt');
     $propertyName = RequestResponse::getByIndex($resultsUri1, 2)->nodeValue;
     $this->AssertEquals("SKOS Class:", $propertyName);
     $resultsUri2 = $dom->query('dl > dd > a');
     $property = RequestResponse::getByIndex($resultsUri2, 2);
     $this->AssertEquals("http://www.w3.org/2004/02/skos/core#Concept", $property->nodeValue);
     $this->AssertEquals("http://www.w3.org/2004/02/skos/core#Concept", $property->getAttribute('href'));
     $h3s = $dom->query('h3');
     $inSchemeName = RequestResponse::getByIndex($h3s, 0)->nodeValue;
     $this->AssertEquals("inScheme", $inSchemeName);
     $lexLabels = RequestResponse::getByIndex($h3s, 2)->nodeValue;
     $this->AssertEquals("LexicalLabels", $lexLabels);
     $h4s = $dom->query('h4');
     $altLabelName = RequestResponse::getByIndex($h4s, 2)->nodeValue;
     $this->AssertEquals("skos:http://www.w3.org/2004/02/skos/core#altLabel", $altLabelName);
     $prefLabelName = RequestResponse::getByIndex($h4s, 4)->nodeValue;
     $this->AssertEquals("skos:http://www.w3.org/2004/02/skos/core#prefLabel", $prefLabelName);
     $notationName = RequestResponse::getByIndex($h4s, 5)->nodeValue;
     $this->AssertEquals("skos:http://www.w3.org/2004/02/skos/core#notation", $notationName);
     $list = $dom->query('ul > li > a > span');
     $prefLabelVal = RequestResponse::getByIndex($list, 4)->nodeValue;
     $this->AssertEquals($prefLabel, $prefLabelVal);
 }
开发者ID:OpenSKOS,项目名称:phpunittests,代码行数:28,代码来源:GetConcept2Test.php

示例4: assertionsForHTMLConcept

 private function assertionsForHTMLConcept($response)
 {
     $dom = new Zend_Dom_Query();
     $dom->setDocumentHtml($response->getBody());
     //does not work because of . : $results1 = $dom->query('dl > dd  > a[href="http://hdl.handle.net/11148/CCR_C-4046_944cc750-1c29-ccf0-fb68-4d00385d7b42"]');
     $resultsUri1 = $dom->query('dl > dt');
     $resultsUri2 = $dom->query('dl > dd > a');
     $propertyName = $this->getByIndex($resultsUri1, 2)->nodeValue;
     $property = $this->getByIndex($resultsUri2, 2);
     $this->AssertEquals("URI:", $propertyName);
     $this->AssertEquals(CONCEPT_handle, $property->nodeValue);
     $this->AssertEquals(CONCEPT_handle, $property->getAttribute('href'));
     $h2s = $dom->query('h2');
     $title = $this->getByIndex($h2s, 0)->nodeValue;
     $this->AssertEquals(CONCEPT_prefLabel, $title);
     $h3s = $dom->query('h3');
     $inScheme = $this->getByIndex($h3s, 0)->nodeValue;
     $this->AssertEquals("inScheme", $inScheme);
     $listHeads = $dom->query('ul');
     $inSchemeHead = $this->getByIndex($listHeads, 0);
     $inSchemeVal = $inSchemeHead->nodeValue;
     $inSchemeList = explode("\n", $inSchemeVal);
     $this->AssertEquals(CONCEPT_NUMBER_inScheme + 1, count($inSchemeList));
     $label = $dom->query('.prefLabel .label');
     $this->AssertEquals(CONCEPT_prefLabel, $label->current()->nodeValue);
 }
开发者ID:OpenSKOS,项目名称:phpunittests,代码行数:26,代码来源:GetConceptTest.php


注:本文中的Zend_Dom_Query::setDocumentHtml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。