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); } }
/** * 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; }
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); }
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); }