當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。