本文整理汇总了PHP中Zend_Dom_Query::queryXpath方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Dom_Query::queryXpath方法的具体用法?PHP Zend_Dom_Query::queryXpath怎么用?PHP Zend_Dom_Query::queryXpath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Dom_Query
的用法示例。
在下文中一共展示了Zend_Dom_Query::queryXpath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDownloads
/**
* Get the list of downloads from Jdownloader
* @return array of Application_Model_JDownloaderPackage
*/
public function getDownloads()
{
if ($this->options->get('nightly', false)) {
$data = $this->sendRawCommand("/get/downloads/all/list");
} else {
$data = $this->sendRawCommand(self::CMD_GET_DOWNLOADS_ALL_LIST);
}
// time to parse xml
// WHILE NOT DOWNLOADING
/*
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jdownloader>
<package package_ETA="~" package_linksinprogress="0" package_linkstotal="1" package_loaded="0 B" package_name="Added 1298019679499" package_percent="0,00" package_size="82.11 MB" package_speed="0 B" package_todo="82.11 MB">
<file file_hoster="megavideo.com" file_name="The Big Bang Theory - 1x02 - The Big Bran Hypothes" file_package="Added 1298019679499" file_percent="0,00" file_speed="0" file_status=""/>
</package>
</jdownloader>
*/
// WHILE DONWLOADING
/*
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jdownloader>
<package package_ETA="14m:37s" package_linksinprogress="1" package_linkstotal="1" package_loaded="1.52 MB" package_name="Added 1298019679499" package_percent="1,85" package_size="82.11 MB" package_speed="94.00 KB" package_todo="80.59 MB">
<file file_hoster="megavideo.com" file_name="The Big Bang Theory - 1x02 - The Big Bran Hypothes.flv" file_package="Added 1298019679499" file_percent="1,85" file_speed="96256" file_status="ETA 14m:37s @ 94.00 KB/s (1/1)"/>
</package>
</jdownloader>
*/
$xml = new Zend_Dom_Query($data);
if ($this->options->get('nightly', false)) {
$result = $xml->queryXpath('//packages');
} else {
$result = $xml->queryXpath('//package');
}
$packages = array();
while ($result->valid()) {
/* @var $domPackage DOMElement */
$domPackage = $result->current();
$package = new Application_Model_JDownloaderPackage();
$package->setName($domPackage->getAttribute('package_name'))->setETA($domPackage->getAttribute('package_ETA'))->setPercent($domPackage->getAttribute('package_percent'))->setSize($domPackage->getAttribute('package_size'))->setDownloading($domPackage->getAttribute('package_linksinprogress') != '0');
/* @var $domFiles DOMNodeList */
$domFiles = $domPackage->getElementsByTagName('file');
for ($i = 0; $i < $domFiles->length; $i++) {
/* @var $domFile DOMElement */
$domFile = $domFiles->item($i);
$file = new Application_Model_JDownloaderFile();
$file->setName($domFile->getAttribute('file_name'))->setHoster($domFile->getAttribute('file_hoster'))->setPercent($domFile->getAttribute('file_percent'))->setDownloading($domFile->getAttribute('file_status') != '');
// add file inside the package
$package->appendFile($file);
}
// add package in the list
$packages[] = $package;
$result->next();
}
return $packages;
}
示例2: test11RetrieveConceptFiletrStatus
public function test11RetrieveConceptFiletrStatus()
{
// Use API to search for concept and filter on status
// todo: test additionele zoek parameters
print "\n" . "Test: get concept via filters";
$client = Authenticator::authenticate();
//prepare and send request
$uri = BASE_URI_ . '/public/api/find-concepts?q=prefLabel:' . CONCEPT_prefLabel . '&status:' . CONCEPT_status_forfilter . '&tenant:' . TENANT . '&inScheme:' . CONCEPT_schema_forfilter;
print "\n filtered request's uri: " . $uri . "\n";
$client->setUri($uri);
$client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
$client->SetHeaders(array('Accept' => 'text/html,application/xhtml+xml,application/xml', 'Content-Type' => 'application/xml', 'Accept-Language' => 'nl,en-US,en', 'Accept-Encoding' => 'gzip, deflate', 'Connection' => 'keep-alive'));
$response = $client->request(Zend_Http_Client::GET);
// analyse respond
print "\n get status: " . $response->getMessage() . "\n";
$this->AssertEquals(200, $response->getStatus());
$namespaces = array("rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "skos" => "http://www.w3.org/2004/02/skos/core#", "openskos" => "http://openskos.org/xmlns/openskos.xsd");
$dom = new Zend_Dom_Query();
$dom->setDocumentXML($response->getBody());
$dom->registerXpathNamespaces($namespaces);
$elem = $dom->queryXpath('/rdf:RDF');
$this->assertEquals(XML_ELEMENT_NODE, $elem->current()->nodeType, 'The root node of the response is not an element');
$this->assertEquals(1, $elem->current()->getAttribute("openskos:numFound"));
$resDescr = $dom->queryXpath('/rdf:RDF/rdf:Description');
$i = 0;
$l = $resDescr->count();
$resDescr->rewind();
while ($i < $l) {
$labels = $resDescr->current()->getElementsByTagName("altLabel");
//print "\n val:" . $labels ->item(0) ->textContent;
$randomn = rand(0, 4096);
$labels->item(0)->nodeValue = "test-1-" . $randomn;
$doc = $resDescr->current()->ownerDocument;
$xml = $doc->saveXML();
var_dump($xml);
// try $newdom isntead of $dom, which can be corrupted
//$dom = new DOMDocument('1.0', 'utf-8');
//$rdf = $dom -> createElement("rdf:RDF");
//$dom ->importNode($newDescr, TRUE);// appendChild($rdf);
//$rdf ->appendChild($newDescr);
//$xml = $dom->saveXML();
//var_dump($xml);
$client->setUri(BASE_URI_ . "/public/api/concept?");
$client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
$response = $client->setEncType('text/xml')->setRawData($xml)->setParameterGet('tenant', TENANT)->setParameterGet('collection', COLLECTION_1_code)->setParameterGet('key', API_KEY)->request(Zend_Http_Client::PUT);
print "\n Update response message: " . $response->getMessage();
$this->AssertEquals(200, $response->getStatus(), 'Update request returned worng status code');
$resDescr->next();
$i++;
}
}
示例3: testQueueJsString
public function testQueueJsString()
{
$script = 'Inline JS script.';
queue_js_string($script);
$matcher = array('tag' => 'script', 'attributes' => array('type' => 'text/javascript'));
$output = $this->_getJsOutput(false);
$dom = new Zend_Dom_Query('<fake>' . $output . '</fake>');
$result = $dom->queryXpath("//script[@type='text/javascript']");
$this->assertCount(1, $result, "Script tag for inline script not found.");
$this->assertContains($script, $output);
}
示例4: testQueueCssString
public function testQueueCssString()
{
$style = 'Inline stylesheet.';
queue_css_string($style, 'screen');
$matcher = array('tag' => 'style', 'attributes' => array('type' => 'text/css', 'media' => 'screen'));
$output = $this->_getCssOutput();
$dom = new Zend_Dom_Query('<fake>' . $output . '</fake>');
$result = $dom->queryXpath("//style[@type='text/css' and @media='screen']");
$this->assertCount(1, $result, "Style tag for inline stylesheet not found.");
$this->assertContains($style, $output);
}
示例5: _fetchResources
/**
* Fill a list of resource by type, group and page
* @param X_Page_ItemList_PItem $items an empty list
* @param string $resourceType the resource type selected
* @param string $resourceGroup the resource group selected
* @param int $page number of the page
* @return X_Page_ItemList_PItem the list filled
*/
private function _fetchResources(X_Page_ItemList_PItem $items, $resourceType, $resourceGroup, $page = 1)
{
X_Debug::i("Fetching resources for {$resourceType}/{$resourceGroup}/{$page}");
// if resourceGroup == new, query and url are specials
if ($resourceGroup == 'new') {
switch ($resourceType) {
case self::TYPE_MOVIES:
$url = self::URL_MOVIES_INDEX_NEW;
$xpathQuery = '//div[@id="maincontent"]//div[@class="galleryitem"]';
break;
case self::TYPE_ANIME:
$url = self::URL_ANIME_INDEX_NEW;
$xpathQuery = '//div[@id="sidebar"]//div[@id="text-5"]//tr[11]//td';
break;
case self::TYPE_TVSHOWS:
$url = self::URL_TVSHOWS_INDEX_NEW;
$xpathQuery = '//div[@id="sidebar"]//div[@id="text-5"]//tr[position()=1 or position()=4 or position()=5]//td//a/parent::node()';
break;
}
} else {
switch ($resourceType) {
case self::TYPE_MOVIES:
$url = sprintf(self::URL_MOVIES_INDEX_AZ, $resourceGroup);
$xpathQuery = '//div[@id="maincontent"]//p/*/a[1][node()][text()]';
$hasThumbnail = false;
$hasDescription = false;
break;
case self::TYPE_ANIME:
$url = self::URL_ANIME_INDEX_AZ;
$xpathQuery = '//div[@id="maincontent"]//p/*/a[1][node()][text()]';
break;
case self::TYPE_TVSHOWS:
$url = self::URL_TVSHOWS_INDEX_AZ;
$xpathQuery = '//div[@id="maincontent"]//p/*/a[1][node()][text()]';
break;
}
}
// fetch the page from filmstream (url is different for each $resourceType)
$htmlString = $this->_loadPage($url);
// load the readed page inside a DOM object, so we can user XPath for traversal
$dom = new Zend_Dom_Query($htmlString);
// execute the query
$result = $dom->queryXpath($xpathQuery);
if ($result->valid()) {
X_Debug::i("Resources found: " . $result->count());
$perPage = $this->config('items.perpage', 50);
// before to slice the results, we must check if a -next-page- is needed
$nextNeeded = $result->count() > $page * $perPage ? true : false;
$matches = array();
$i = 1;
while ($result->valid()) {
if ($i > ($page - 1) * $perPage && $i < $page * $perPage) {
$currentRes = $result->current();
if ($resourceGroup == 'new') {
$IdNode = $currentRes->firstChild;
while ($IdNode instanceof DOMText && $IdNode != null) {
$IdNode = $IdNode->nextSibling;
}
// anime, tvshow, subbed are on the side bar, and $currentRes has 1 child only
if ($currentRes->childNodes->length == 1) {
$labelNode = $IdNode;
} else {
$labelNode = $IdNode->nextSibling;
}
if (is_object($labelNode) && trim($labelNode->nodeValue) == '') {
$labelNode = $labelNode->parentNode;
}
$resourceId = str_replace('/', ':', substr($IdNode->getAttribute('href'), strlen(self::URL_BASE), -1));
// i've done everthing. If all doesn't work, just skip this entry
if ($resourceId == "") {
$i++;
$result->next();
continue;
}
$resourceLabel = trim(@$labelNode->nodeValue);
if ($resourceLabel == '') {
$resourceLabel = $currentRes->nodeValue;
}
$resourceDescription = null;
$resourceThumbnail = $IdNode->firstChild != null && !$IdNode->firstChild instanceof DOMText ? $IdNode->firstChild->getAttribute('src') : null;
} else {
$resourceId = str_replace('/', ':', substr($currentRes->getAttribute('href'), strlen(self::URL_BASE), -1));
$resourceLabel = trim($currentRes->nodeValue);
$resourceDescription = null;
$resourceThumbnail = null;
}
$matches[] = array($resourceId, $resourceLabel, $resourceDescription, $resourceThumbnail);
}
$i++;
$result->next();
}
if ($page > 1) {
//.........这里部分代码省略.........
示例6: fetch
/**
* Fetch info about location
*/
private function fetch()
{
// if $this->_location should be fetched
// $this->_fetched === false is true
// else all datas are in $this->_fetched (array)
if ($this->_fetched === false) {
if (!$this->options->enabled || !file_exists($this->options->path)) {
X_Debug::e('Helper disabled or wrong path');
$this->_fetched = array('source' => $this->_location, 'videos' => array(), 'audios' => array(), 'subs' => array());
return;
} else {
$xmlString = $this->_invoke();
}
$dom = new Zend_Dom_Query($xmlString);
$videos = array();
$audios = array();
$subs = array();
// search for videos
$result = $dom->queryXpath('//track[@type="Video"]');
$found = $result->count();
for ($i = 1; $i <= $found; $i++) {
$format = X_VlcShares_Plugins_Helper_StreaminfoInterface::AVCODEC_UNKNOWN;
foreach ($this->formatTests as $key => $test) {
$valid = true;
foreach ($test as $subtest) {
list($query, $value) = $subtest;
//X_Debug::i("Query: $query / Value: $value");
$nodeTest = $dom->queryXpath("//track[@type='Video'][{$i}]{$query}");
if (!$nodeTest->valid() || $nodeTest->current()->nodeValue != $value) {
$valid = false;
break;
}
}
if ($valid) {
$format = $key;
break;
}
}
$id = $dom->queryXpath("//track[@type='Video'][{$i}]/ID");
if ($id->valid()) {
$id = $id->current()->nodeValue;
$videos[] = array('codecName' => $format, 'codecType' => $format, 'id' => $id);
} else {
$videos[] = array('codecName' => $format, 'codecType' => $format);
}
}
// search for audios
$result = $dom->queryXpath('//track[@type="Audio"]');
$found = $result->count();
for ($i = 1; $i <= $found; $i++) {
$format = X_VlcShares_Plugins_Helper_StreaminfoInterface::AVCODEC_UNKNOWN;
foreach ($this->formatTests as $key => $test) {
$valid = true;
foreach ($test as $subtest) {
list($query, $value) = $subtest;
$nodeTest = $dom->queryXpath("//track[@type='Audio'][{$i}]{$query}");
if (!$nodeTest->valid() || $nodeTest->current()->nodeValue != $value) {
$valid = false;
break;
}
}
if ($valid) {
$format = $key;
break;
}
}
$id = $dom->queryXpath("//track[@type='Audio'][{$i}]/ID");
if ($id->valid()) {
$id = $id->current()->nodeValue;
$audios[] = array('codecName' => $format, 'codecType' => $format, 'id' => $id);
} else {
$audios[] = array('codecName' => $format, 'codecType' => $format);
}
}
// search for audios
$result = $dom->queryXpath('//track[@type="Text"]');
$found = $result->count();
for ($i = 1; $i <= $found; $i++) {
$language = $dom->queryXpath("//track[@type='Text'][{$i}]/Language")->current()->nodeValue;
$format = $dom->queryXpath("//track[@type='Text'][{$i}]/Format")->current()->nodeValue;
$id = $dom->queryXpath("//track[@type='Text'][{$i}]/ID");
if ($id->valid()) {
$id = $id->current()->nodeValue;
$subs[] = array('format' => $format, 'language' => $language, 'id' => $id);
} else {
$subs[] = array('format' => $format, 'language' => $language);
}
}
//X_Debug::i(var_export($videos, true));
//X_Debug::i(var_export($audios, true));
// fetch and decode mediainfo data here
$fetched = array('source' => $this->_location, 'videos' => $videos, 'audios' => $audios, 'subs' => $subs);
// I use lazy init for info
// and I insert results in cache
$this->_fetched = $fetched;
}
}
示例7: trim
try {
// it doesn't allow dotted directories (. and ..) and file/symlink
if ($entry->isDot() || !$entry->isDir()) {
continue;
}
if (!$createAll && array_search($entry->getFilename(), $pluginsList) === false) {
continue;
}
// plugin manifest file. I need it to get the version
$manifestFile = $entry->getRealPath() . '/manifest.xml';
if (!file_exists($manifestFile)) {
echo "[WWW] {$entry->getFilename()} isn't a plugin folder. Skipped" . PHP_EOL;
continue;
}
$dom = new Zend_Dom_Query(file_get_contents($manifestFile));
$result = $dom->queryXpath('//metadata/version');
$pluginVersion = trim($result->current()->nodeValue);
$result = $dom->queryXpath('//metadata/status');
$pluginState = trim($result->current()->nodeValue);
if ($pluginState == 'stable') {
$pluginState = '';
}
$pluginFilename = APPLICATION_PATH . $distDir . "/plugin_{$entry->getFilename()}_{$pluginVersion}{$pluginState}.zip";
$pluginZip = new PclZip($pluginFilename);
$response = $pluginZip->create($entry->getRealPath(), PCLZIP_OPT_REMOVE_PATH, $entry->getRealPath(), PCLZIP_CB_PRE_ADD, 'ignoreVcsCB');
if ($response == 0) {
echo "[EEE] Error creating {$entry->getFilename()} package: {$pluginZip->errorInfo(true)}" . PHP_EOL;
} else {
echo "Plugin package {{$entry->getFilename()}} created" . PHP_EOL;
}
unset($pluginZip);
示例8: getAbout
private function getAbout($response)
{
$dom = new Zend_Dom_Query();
$namespaces = RequestResponse::setNamespaces();
$dom->setDocumentXML($response->getBody());
$dom->registerXpathNamespaces($namespaces);
$description = $dom->queryXpath('/rdf:RDF/rdf:Description');
$this->assertEquals(1, $description->count(), "rdf:Description element is not declared");
$resURI = $description->current()->getAttribute("rdf:about");
$this->assertNotEquals("", $resURI, "No valid uri for SKOS concept");
return $resURI;
}
示例9: fetchThreads
protected function fetchThreads(X_Page_ItemList_PItem $items, $group)
{
if ($group == self::GROUP_LIVE) {
// LIVE CHANNELS PAGE
$html = $this->_loadPage(self::INDEX_LIVE, 10);
$pattern = '/<td class\\=\\"competition\\">(?P<label>[^\\<]{1}[^\\<]*)<\\/td>/';
$matches = array();
if (preg_match_all($pattern, $html, $matches, PREG_SET_ORDER)) {
foreach ($matches as $i => $match) {
$item = new X_Page_Item_PItem("{$this->getId()}-live-{$i}", $match['label']);
$item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ":location", "{$group}/{$i}")->setLink(array('l' => X_Env::encode("{$group}/{$i}")), 'default', false);
$items->append($item);
}
} else {
X_Debug::e("Group pattern failure {{$pattern}}");
}
} elseif ($group == self::GROUP_EVENTS) {
// EVENTS PAGE
$html = $this->_loadPage(self::INDEX_EVENTS, 10);
$pattern = '/<td class\\=\\"competition\\">(?P<label>[^\\<]{1}[^\\<]*)<\\/td>/';
$dom = new Zend_Dom_Query($html);
$results = $dom->queryXpath('//table[@class="itemlist"]//tr[position() > 1]');
while ($results->valid()) {
// 1 item = 2 tr
$tr1 = $results->current();
$results->next();
if (!$results->valid()) {
// this is very unusual, items could be % 2
break;
}
$tr2 = $results->current();
$tr1 = simplexml_import_dom($tr1);
$tr2 = simplexml_import_dom($tr2);
$label = implode(' - ', array('[' . ereg_replace("[^A-Za-z0-9 ]", "", (string) $tr1->td[2]->b[0]->span[0]) . ']', trim(ereg_replace("[^A-Za-z0-9 ]", "", $tr2->td[2]->b[0]) . ' ' . ereg_replace("[^A-Za-z0-9 ]", "", (string) $tr2->td[3]) . ' ' . ereg_replace("[^A-Za-z0-9 ]", "", (string) $tr2->td[4]->b[0])), '(' . trim((string) $tr1->td[1]->b[0]) . ')'));
$href = (string) $tr1->td[4]->a['href'];
$matches = array();
if (preg_match('/broadcast\\.php\\?matchid\\=(?P<id>[0-9]+)\\&part\\=sports/', $href, $matches)) {
// we have all info needed
$id = $matches['id'];
$item = new X_Page_Item_PItem("{$this->getId()}-events-{$id}", $label);
$item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ":location", "{$group}/{$id}")->setLink(array('l' => X_Env::encode("{$group}/{$id}")), 'default', false);
$items->append($item);
} else {
X_Debug::w("Match id not found in href {{$href}}");
}
$results->next();
}
if (preg_match_all($pattern, $html, $matches, PREG_SET_ORDER)) {
foreach ($matches as $i => $match) {
$item = new X_Page_Item_PItem("{$this->getId()}-live-{$i}", $match['label']);
$item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ":location", "{$group}/{$i}")->setLink(array('l' => X_Env::encode("{$group}/{$i}")), 'default', false);
$items->append($item);
}
}
}
}
示例10: resolveLocation
/**
* @see X_VlcShares_Plugins_ResolverInterface::resolveLocation
* @param string $location
* @return string real address of a resource
*/
function resolveLocation($location = null)
{
if (array_key_exists($location, $this->cachedLocation)) {
return $this->cachedLocation[$location];
}
// prevent no-location-given error
if ($location === null) {
return false;
}
$pageVideo = $this->config('index.url', 'http://www.dbforever.net/home.php') . "{$location}";
$htmlString = $this->_loadPage($pageVideo);
$dom = new Zend_Dom_Query($htmlString);
$results = $dom->queryXpath('//embed/attribute::flashvars');
if ($results->valid()) {
$attr = $results->current()->nodeValue;
$attrs = explode("&", $attr);
foreach ($attrs as $attr) {
list($type, $value) = explode('=', $attr);
if ($type == 'file') {
// fix for relative links inside bleach category
if (!X_Env::startWith($value, 'http://')) {
$value = "http://www.dbforever.net{$value}";
}
$this->cachedLocation[$location] = $value;
return $value;
}
}
}
$this->cachedLocation[$location] = false;
return false;
}
示例11: getInfo
/**
*
*/
public function getInfo($infos = null)
{
// uso per fare il parsing
if (is_null($infos)) {
$infos = $this->_send('');
}
/**
<root>
<volume>256</volume>
<length>234</length>
<time>12</time>
<state>playing</state>
<position>5</position>
<fullscreen></fullscreen>
<random>0</random>
<loop>0</loop>
<repeat>0</repeat>
<information>
<category name="Diffusione 0">
<info name="Tipo">Video</info>
<info name="Codifica">XVID</info>
<info name="Risoluzione">720x576</info>
<info name="Risoluzione video">720x576</info>
<info name="Immagini al secondo">25</info>
</category>
<category name="Diffusione 1">
<info name="Tipo">Audio</info>
<info name="Codifica">mpga</info>
<info name="Canali">Mono</info>
<info name="Campionamento">48000 Hz</info>
<info name="Bitrate">80 kb/s</info>
</category>
<meta-information>
<title><![CDATA[/media/Windows/video.avi]]></title>
<artist><![CDATA[]]></artist>
<genre><![CDATA[]]></genre>
<copyright><![CDATA[]]></copyright>
<album><![CDATA[]]></album>
<track><![CDATA[]]></track>
<description><![CDATA[]]></description>
<rating><![CDATA[]]></rating>
<date><![CDATA[]]></date>
<url><![CDATA[]]></url>
<language><![CDATA[]]></language>
<now_playing><![CDATA[]]></now_playing>
<publisher><![CDATA[]]></publisher>
<encoded_by><![CDATA[]]></encoded_by>
<art_url><![CDATA[]]></art_url>
<track_id><![CDATA[]]></track_id>
</meta-information>
</information>
<stats>
<readbytes>1498004</readbytes>
<inputbitrate>0,107826</inputbitrate>
<demuxreadbytes>1335729</demuxreadbytes>
<demuxbitrate>0,139785</demuxbitrate>
<decodedvideo>166</decodedvideo>
<displayedpictures>467</displayedpictures>
<lostpictures>27</lostpictures>
<decodedaudio>528</decodedaudio>
<playedabuffers>528</playedabuffers>
<lostabuffers>3</lostabuffers>
<sentpackets>0</sentpackets>
<sentbytes>0</sentbytes>
<sendbitrate>0,000000</sendbitrate>
</stats>
</root>
*/
$rInfos = array();
try {
$dom = new Zend_Dom_Query($infos);
// lunghezza
$results = $dom->queryXpath('/root/length');
if (count($results) > 0) {
$rInfos['length'] = $results->current()->nodeValue;
}
// posizione ora
$results = $dom->queryXpath('/root/time');
if (count($results) > 0) {
$rInfos['time'] = $results->current()->nodeValue;
}
// posizione name
//.........这里部分代码省略.........
示例12: _fetchVideos
private function _fetchVideos(X_Page_ItemList_PItem $items, $letter, $thread)
{
X_Debug::i("Fetching videos for {$letter}/{$thread}");
$baseUrl = $this->config('base.url', 'http://www.jigoku.it/anime-streaming/');
$baseUrl .= "{$thread}";
$htmlString = $this->_loadPage($baseUrl, true);
$dom = new Zend_Dom_Query($htmlString);
// xpath index stars from 1
$results = $dom->queryXpath('//div[@class="elenco"]//td[@class="serie"]/a');
X_Debug::i("Links found: " . $results->count());
//$found = false;
for ($i = 0; $i < $results->count(); $i++, $results->next()) {
$current = $results->current();
$label = trim(trim($current->textContent), chr(0xc2) . chr(0xa0));
if ($label == '') {
$label = X_Env::_('p_jigoku_nonamevideo');
}
$href = $current->getAttribute('href');
// href format: /anime-streaming/b-gata-h-kei/8306/episodio-2/
@(list(, , $epId, $epName) = explode('/', trim($href, '/')));
// works even without the $epName
$href = "{$epId}:{$epName}";
//$found = true;
X_Debug::i("Valid link found: {$href}");
$item = new X_Page_Item_PItem($this->getId() . "-{$label}", $label);
$item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$letter}/{$thread}/{$href}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$letter}/{$thread}/{$href}")), 'default', false);
if (APPLICATION_ENV == 'development') {
$item->setDescription("{$letter}/{$thread}/{$href}");
}
$items->append($item);
}
/*
if (!$found) {
$item = new X_Page_Item_PItem($this->getId().'-ops', X_Env::_('p_animedb_opsnovideo'));
$item->setType(X_Page_Item_PItem::TYPE_ELEMENT)
->setLink(X_Env::completeUrl(
//$urlHelper->url()
));
$items->append($item);
}
*/
}
示例13: resolveLocation
/**
* @see X_VlcShares_Plugins_ResolverInterface::resolveLocation
* @param string $location
* @return string real address of a resource
*/
function resolveLocation($location = null)
{
if (array_key_exists($location, $this->cachedLocation)) {
return $this->cachedLocation[$location];
}
// prevent no-location-given error
if ($location === null) {
return false;
}
$pageVideo = "http://allsp.ch/xml.php?id={$location}";
$htmlString = $this->_loadPage($pageVideo);
$dom = new Zend_Dom_Query($htmlString);
$results = $dom->queryXpath('//location');
if ($results->valid()) {
$value = $results->current()->nodeValue;
if ($value != '') {
$this->cachedLocation[$location] = $value;
return $value;
}
}
$this->cachedLocation[$location] = false;
return false;
}
示例14: test07CreateConceptWithoutUri
public function test07CreateConceptWithoutUri()
{
// Create a concept without Uri and with unique PrefLabel.
print "\n\n test07 ... \n";
$client = Authenticator::authenticate();
$randomn = rand(0, 4092);
$prefLabel = 'testPrefLable_' . $randomn;
$dateSubmitted = date(DateTime::ISO8601);
$xml = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:dcterms="http://purl.org/dc/terms/" > ' . '<rdf:Description>' . '<rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>' . '<dcterms:creator>Test</dcterms:creator>' . '<skos:prefLabel xml:lang="nl">' . $prefLabel . '</skos:prefLabel>' . '<dcterms:dateSubmitted>' . $dateSubmitted . '</dcterms:dateSubmitted>' . '<skos:inScheme rdf:resource="http://data.beeldengeluid.nl/gtaa/GeografischeNamen"/>' . '</rdf:Description>' . '</rdf:RDF>';
$client->setUri(BASE_URI_ . "/public/api/concept?");
$client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
$response = $client->setEncType('text/xml')->setRawData($xml)->setParameterGet('tenant', TENANT)->setParameterGet('collection', COLLECTION_1_code)->setParameterGet('key', API_KEY)->setParameterGet('autoGenerateIdentifiers', 'true')->request('POST');
if ($response->isSuccessful()) {
print "\n Concept created \n";
var_dump($response->getBody());
} else {
print "\n Failed to create concept: " . $response->getHeader('X-Error-Msg');
}
$this->AssertEquals(201, $response->getStatus());
print "\n HTTPResponseHeader-Location: " . $response->getHeader('Location');
$namespaces = array("rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "skos" => "http://www.w3.org/2004/02/skos/core#", "openskos" => "http://openskos.org/xmlns/openskos.xsd");
$dom = new Zend_Dom_Query();
$dom->setDocumentXML($response->getBody());
$dom->registerXpathNamespaces($namespaces);
$elem = $dom->queryXpath('/rdf:RDF');
$this->assertEquals($elem->current()->nodeType, XML_ELEMENT_NODE, 'The root node of the response is not an element');
$resURI = $dom->queryXpath('/rdf:RDF/rdf:Description')->current()->getAttribute("rdf:about");
$this->assertNotEquals("", $resURI, "No valid uri for SKOS concept");
$status = $dom->queryXpath('/rdf:RDF/rdf:Description/openskos:status');
$this->assertEquals(1, $status->count(), "No valid uri for SKOS concept");
print "\n New concept is created with URI {$resURI} and status" . $status->current()->nodeValue;
}
示例15: _fetchThreads
private function _fetchThreads(X_Page_ItemList_PItem $items, $type, $letter)
{
X_Debug::i("Fetching threads for {$type}/{$letter}");
switch ($type) {
case self::TYPE_SERIES_PERGENRE:
case self::TYPE_SERIES_PERLETTER:
$this->_fetchThreadsAPI($items, $type, $letter);
return;
case self::TYPE_SERIES:
$indexUrl = $this->config('index.series.url', self::PAGE_SERIES);
// more info for xpath: http://www.questionhub.com/StackOverflow/3428104
$queryXpath = '//a[@name="' . $letter . '"]/following-sibling::div[count(.| //a[@name="' . $letter . '"]/following-sibling::a[1]/preceding-sibling::div)=count(//a[@name="' . $letter . '"]/following-sibling::a[1]/preceding-sibling::div)]/a';
break;
case self::TYPE_OAV:
$indexUrl = $this->config('index.oav.url', self::PAGE_OAV);
$queryXpath = '//a[@name="' . $letter . '"]/following-sibling::div[count(.| //a[@name="' . $letter . '"]/following-sibling::a[1]/preceding-sibling::div)=count(//a[@name="' . $letter . '"]/following-sibling::a[1]/preceding-sibling::div)]/a';
break;
case self::TYPE_MOVIES:
$indexUrl = $this->config('index.movies.url', self::PAGE_MOVIES);
$queryXpath = '//div[@class="mpart"]//a';
break;
}
$htmlString = $this->_loadPage($indexUrl, true);
$dom = new Zend_Dom_Query($htmlString);
// fetch all threads inside the table
//$results = $dom->queryXpath('//table[@id="streaming_elenco"]//a[@name="' . $letter . '"][text()!=""]/ancestor::table[@id="streaming_elenco"]/tr[@class!="header"]/td[@class="serie"]/a');
$results = $dom->queryXpath($queryXpath);
X_Debug::i("Threads found: " . $results->count());
for ($i = 0; $i < $results->count(); $i++, $results->next()) {
$current = $results->current();
$label = $current->textContent;
$href = $current->getAttribute('href');
if ($type == self::TYPE_MOVIES) {
if (X_Env::startWith($href, $this->config('index.movie.url', self::PAGE_MOVIES))) {
$href = substr($href, strlen($this->config('index.movie.url', self::PAGE_MOVIES)));
}
// now href has format: /anime/movies, and we need both
// so replace / with a safer :
//$href = str_replace('/', ':', trim($href, '/'));
$href = trim($href, '/');
} else {
// href has format: /category/$NEEDEDVALUE/
// so i trim / from the bounds and then i get the $NEEDEDVALUE
@(list(, $href) = explode('/', trim($href, '/')));
}
$item = new X_Page_Item_PItem($this->getId() . "-{$label}", $label);
$item->setIcon('/images/icons/folder_32.png')->setType($type == self::TYPE_MOVIES ? X_Page_Item_PItem::TYPE_ELEMENT : X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$type}/{$letter}/{$href}")->setLink(array('l' => X_Env::encode("{$type}/{$letter}/{$href}"), 'action' => $type == self::TYPE_MOVIES ? 'mode' : 'share'), 'default', false);
if (APPLICATION_ENV == 'development') {
$item->setDescription("{$type}/{$letter}/{$href}");
}
$items->append($item);
}
}