/**
  * 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;
 }
 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++;
     }
 }
Exemple #3
0
 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);
 }
Exemple #4
0
 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);
 }
 /**
  * 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) {
             // we need the "previus-page" link
             $item = new X_Page_Item_PItem($this->getId() . "-previouspage", X_Env::_("p_filmstream_page_previous", $page - 1));
             $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$resourceType}/{$resourceGroup}/" . ($page - 1))->setLink(array('l' => X_Env::encode("{$resourceType}/{$resourceGroup}/" . ($page - 1))), 'default', false);
             $items->append($item);
         }
         foreach ($matches as $resource) {
             @(list($resourceId, $resourceLabel, $resourceDescription, $resourceThumbnail) = $resource);
             $item = new X_Page_Item_PItem($this->getId() . "-{$resourceType}-{$resourceGroup}-{$page}-{$resourceId}", $resourceLabel);
             $item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}")->setLink(array('l' => X_Env::encode("{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}")), 'default', false);
             if ($resourceDescription != null) {
                 $item->setDescription($resourceDescription);
             } elseif (APPLICATION_ENV == 'development') {
                 $item->setDescription("{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}");
             }
             if ($resourceThumbnail != null) {
                 $item->setThumbnail($resourceThumbnail);
             }
             $items->append($item);
         }
         if ($nextNeeded) {
             // we need the "previus-page" link
             $item = new X_Page_Item_PItem($this->getId() . "-nextpage", X_Env::_("p_filmstream_page_next", $page + 1));
             $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$resourceType}/{$resourceGroup}/" . ($page + 1))->setLink(array('l' => X_Env::encode("{$resourceType}/{$resourceGroup}/" . ($page + 1))), 'default', false);
             $items->append($item);
         }
     } else {
         X_Debug::e("Query failed {{$xpathQuery}}");
     }
 }
 /**
  * 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;
     }
 }
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);
 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;
 }
 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);
             }
         }
     }
 }
 /**
  * @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;
 }
 /**
  * 
  */
 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
         if ($this->options->version == '1.1.x') {
             $results = $dom->queryXpath('/root/information/meta-information/title');
             if (count($results) > 0) {
                 $rInfos['name'] = $results->current()->nodeValue;
             }
         } elseif ($this->options->version == '2.x') {
             $results = $dom->queryXpath('/root/information/category[@name="meta"]/info[@name="filename"]');
             if (count($results) > 0) {
                 $rInfos['name'] = $results->current()->nodeValue;
             }
         }
         /* l'aggiungo in 0.5 forse
         			// posizione ora
         			$results = $dom->queryXpath('/root/information/category');
         			if ( count($results) > 0 ) {
         				$rInfos['streams'] = array();
         				//$rInfos['length'] = $results[0]->nodeValue;
         				foreach ( $results as $category ) {
         					$stream = array();
         					//$stream
         					$rInfos['streams'][] = $stream;
         				}
         			}
         			*/
     } catch (Exception $e) {
         X_Debug::w("Catch exception: {$e->getMessage()}");
     }
     return $rInfos;
 }
 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);
     }
     */
 }
 /**
  * @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;
 }
 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;
 }
 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);
     }
 }
 /**
  * Find links using an alternative way
  * @author Valerio Moretti
  */
 private function _parseAlternativeScaper($htmlString, X_Page_ItemList_PItem $items, $category, $letter, $thread)
 {
     //mi suddivido il post in righe
     $htmlRows = explode('<br />', $htmlString);
     /*
     //qua volevo selezionarmi solo il codice del post per rendere il tutto piu' veloce
     //pero' sbaglio qualcosa e non mi funziona
     
     $dom = new Zend_Dom_Query($htmlString);
     $content = $dom->queryXpath('//ol[@id="posts"]/li[1]//div[@class="content"]');
     $htmlPost = $content->current();
     
     $htmlRows = explode('<br />', $htmlPost);
     */
     //analizzo riga per riga
     foreach ($htmlRows as $row) {
         //la mia ignoranza del Xpath e' immensa e questo e' l'unico modo che ho trovato per farlo funzionare
         $row = '<root>' . $row . '</root>';
         $dom = new Zend_Dom_Query($row);
         // xpath index stars from 1
         $results = $dom->queryXpath('//a');
         X_Debug::i("Links found: " . $results->count());
         $found = false;
         $title = '';
         //il testo del primo link della riga
         for ($i = 0; $i < $results->count(); $i++, $results->next()) {
             $current = $results->current();
             $label = trim(trim($current->nodeValue), chr(0xc2) . chr(0xa0));
             if ($label == '') {
                 $label = X_Env::_('p_animedb_nonamevideo');
             }
             if ($title == '') {
                 $title = $label;
             }
             $href = $current->getAttribute('href');
             try {
                 $hoster = $this->helpers()->hoster()->findHoster($href);
             } catch (Exception $e) {
                 // no hoster = no valid href
                 continue;
             }
             $href = "{$hoster->getId()}:{$hoster->getResourceId($href)}";
             $label = $label == $title ? $label : $title . ' | ' . $label;
             $label .= " [" . ucfirst($hoster->getId()) . "]";
             $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', "{$category}/{$letter}/{$thread}/{$href}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$category}/{$letter}/{$thread}/{$href}")), 'default', false);
             if (APPLICATION_ENV == 'development') {
                 $item->setDescription("{$category}/{$letter}/{$thread}/{$href}");
             }
             $items->append($item);
         }
     }
 }
 protected function fetchSubtitlesNOAPI()
 {
     if ($this->_location == null || $this->_location == false) {
         throw new Exception("Location value not setted");
     }
     // if there is no cached value
     if ($this->_fetched === false || !array_key_exists('subtitles', $this->_cachedSearch[$this->_location])) {
         if (is_array($this->_fetched)) {
             $toBeCached = $this->_fetched;
         } else {
             $toBeCached = array();
         }
         $uri = "http://video.google.com/timedtext?type=list&v=" . $this->_location;
         $http = $this->getHttpClient($uri);
         $response = $http->request();
         $xmlString = $response->getBody();
         $doc = new Zend_Dom_Query($xmlString);
         $results = $doc->queryXpath('//track');
         $subs = array();
         while ($results->valid()) {
             $current = $results->current();
             // <track id="0" name="" lang_code="en" lang_original="English" lang_translated="English" lang_default="true"/>
             $sub = array('id' => $current->getAttribute('id'), 'name' => $current->getAttribute('name'), 'lang_code' => $current->getAttribute('lang_code'), 'lang_original' => $current->getAttribute('lang_original'), 'lang_translated' => $current->getAttribute('lang_translated'), 'lang_default' => $current->getAttribute('lang_default'));
             $sub['xml_url'] = 'http://video.google.com/timedtext?type=track&' . 'lang=' . urlencode(utf8_encode($sub['lang_code'])) . '&' . 'name=' . urlencode(utf8_encode($sub['name'])) . '&' . 'v=' . $this->_location;
             //        "name=" + URLEncoder.encode(this.name, "UTF-8") +
             //        "&lang=" + URLEncoder.encode(this.lang, "UTF-8") +
             //        "&v=" + URLEncoder.encode(this.id, "UTF-8");
             $sub['srt_url'] = array('controller' => 'youtube', 'action' => 'convert', 'l' => X_Env::encode(utf8_encode($sub['lang_code'])), 'v' => $this->_location, 'f' => 'file.srt');
             $subs[$sub['lang_code']] = $sub;
             $results->next();
         }
         //X_Debug::i("Preg digest: ".print_r($matches, true));
         //X_Debug::i("Subs found: ".print_r($subs, true));
         $toBeCached['subtitles'] = $subs;
         $this->_fetched = $toBeCached;
         $this->_cachedSearch[$this->_location] = $toBeCached;
     }
     return $this;
 }
 public function testImport()
 {
     print "\n" . "Testing import ... ";
     $response = RequestResponse::ImportConceptRequest(self::$client, self::$postData, self::$boundaryNumeric);
     Logging::var_error_log("\n Response body ", $response->getBody(), __DIR__ . "/ImportResponse.html");
     $this->AssertEquals(200, $response->getStatus(), 'Failed to import concept');
     $output = array('0' => "The ouput of sending jobs: ");
     $retvar = 0;
     $sendjob = exec(PHP_JOBS_PROCESS, $output, $retvar);
     // check via spraql query
     //$sparqlResult = $this ->sparqlRetrieveTriplesForNotation(self::$notation);
     //var_dump($sparqlResult);
     self::$client->setUri(BASE_URI_ . '/public/api/find-concepts?q=prefLabel:' . self::$prefLabel);
     $responseGet = self::$client->request(Zend_Http_Client::GET);
     $this->AssertEquals(200, $responseGet->getStatus(), $responseGet->getMessage());
     $dom = new Zend_Dom_Query();
     $namespaces = RequestResponse::setNamespaces();
     $dom->registerXpathNamespaces($namespaces);
     $xml = $responseGet->getBody();
     $dom->setDocumentXML($xml);
     var_dump($xml);
     $results1 = $dom->query('rdf:RDF');
     $this->AssertEquals(1, $results1->current()->getAttribute('openskos:numFound'));
     $results2 = $dom->queryXpath('/rdf:RDF/rdf:Description');
     $this->AssertEquals(1, count($results2));
 }
 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 fileterd request's uri: " . $uri;
     $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
     if ($response->getStatus() != 200) {
         print "\n " . $response->getMessage();
     }
     print "\n Response Headers: ";
     var_dump($response->getHeaders());
     $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");
     print "\n\n\n Response Body: ";
     var_dump($response->getBody());
     $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');
     $resDescr = $dom->queryXpath('/rdf:RDF/rdf:Description');
     $resStatus = $dom->queryXpath('/rdf:RDF/rdf:Description/openskos:status');
     $this->assertEquals(1, $resDescr->count());
     $this->assertEquals($resDescr->count(), $resStatus->count(), "Not all result concepts have status field. ");
 }
 /**
  * @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;
     }
     $htmlString = $this->_loadPage($location);
     $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') {
                 $this->cachedLocation[$location] = $value;
                 return $value;
             }
         }
     }
     $this->cachedLocation[$location] = false;
     return false;
 }
 private function assertionsForXMLRDFConcept($response, $prefLabel, $altLabel, $hiddenLabel, $lang, $definition, $notation, $topConceptOf, $inScheme)
 {
     $dom = new Zend_Dom_Query();
     $namespaces = RequestResponse::setNamespaces();
     $dom->registerXpathNamespaces($namespaces);
     $xml = $response->getBody();
     $dom->setDocumentXML($xml);
     $results1 = $dom->queryXpath('/rdf:RDF/rdf:Description');
     $this->AssertEquals(1, count($results1));
     $this->AssertStringStartsWith(BASE_URI_ . "/" . OPENSKOS_SET_code, $results1->current()->getAttribute('rdf:about'));
     $results2 = $dom->query('rdf:type');
     $this->AssertEquals(CONCEPT_type, $results2->current()->getAttribute('rdf:resource'));
     $results3 = $dom->query('skos:notation');
     $this->AssertEquals($notation, $results3->current()->nodeValue);
     $results4 = $dom->query('skos:inScheme');
     $this->AssertEquals($inScheme, count($results4));
     $results5 = $dom->query('skos:topConceptOf');
     $this->AssertEquals($topConceptOf, count($results5));
     $results6 = $dom->query('skos:prefLabel');
     $this->AssertEquals($lang, $results6->current()->getAttribute('xml:lang'));
     $this->AssertEquals($prefLabel, $results6->current()->nodeValue);
     $results6a = $dom->query('skos:altLabel');
     $this->AssertEquals($lang, $results6a->current()->getAttribute('xml:lang'));
     $this->AssertEquals($altLabel, $results6a->current()->nodeValue);
     $results6b = $dom->query('skos:hiddenLabel');
     $this->AssertEquals($lang, $results6b->current()->getAttribute('xml:lang'));
     $this->AssertEquals($hiddenLabel, $results6b->current()->nodeValue);
     $results7 = $dom->query('skos:definition');
     $this->AssertEquals($definition, $results7->current()->nodeValue);
     $results9 = $dom->query('dcterms:creator');
     $this->AssertStringStartsWith(BASE_URI_, $results9->current()->getAttribute('rdf:resource'));
     $results8 = $dom->query('openskos:set');
     $this->AssertEquals(OPENSKOS_SET_code, $results8->current()->nodeValue);
 }
 protected function _convertoToSrt(Zend_Dom_Query $dom)
 {
     $this->getResponse()->setHeader('Content-type', 'application/x-subrip', true);
     //$this->getResponse()->setHeader('Content-type', 'text/plain', true);
     $results = $dom->queryXpath('//text');
     $i = 1;
     $string = '';
     while ($results->valid()) {
         $current = $results->current();
         $from = $current->getAttribute('start');
         $dur = $current->getAttribute('dur');
         $text = $current->nodeValue;
         $end = (double) $from + (double) $dur;
         $from = explode('.', (string) $from);
         $from = X_Env::formatTime($from[0]) . ',' . str_pad(substr($from[1], 0, 3), 3, '0', STR_PAD_RIGHT);
         $end = explode('.', (string) $end);
         $end = X_Env::formatTime($end[0]) . ',' . str_pad(substr($end[1], 0, 3), 3, '0', STR_PAD_RIGHT);
         $text = str_replace(array('&quot;', '&amp;', '&#39;'), array("\"", "&", "'"), utf8_decode($text));
         $string .= "{$i}\r\n";
         $string .= "{$from} --> {$end}\r\n";
         $string .= "{$text}\r\n";
         $string .= "\r\n";
         $results->next();
         $i++;
     }
     return $string;
 }
 protected function fetchChannels(X_Page_ItemList_PItem $items, $gPage = 1, $groupId, $page = 1)
 {
     $xml = $this->_loadPage(self::CHANNELS_INDEX, 10);
     $dom = new Zend_Dom_Query($xml);
     $_channels = $dom->queryXpath('//group[@id="' . $groupId . '"]/channel');
     $channels = array();
     while ($_channels->valid()) {
         $current = $_channels->current();
         $_channel = array('id' => $current->getAttribute('id'));
         try {
             $nameTag = $current->getElementsByTagName('name')->item(0);
             if ($nameTag->getAttribute('en') != '') {
                 $_channel['title'] = $nameTag->getAttribute('en');
             } else {
                 $_channel['title'] = $nameTag->nodeValue;
             }
         } catch (Exception $e) {
             $_channels->next();
             continue;
         }
         try {
             $sopTag = $current->getElementsByTagName('sop_address')->item(0);
             $_channel['url'] = trim($sopTag->nodeValue);
         } catch (Exception $e) {
             $_channels->next();
             continue;
         }
         if ($_channel['id'] != '' && $_channel['title'] != '' && $_channel['url'] != '') {
             $channels[] = $_channel;
         }
         $_channels->next();
     }
     $totalPageCount = $this->helpers()->paginator()->getPages($channels);
     if ($this->helpers()->paginator()->hasPrevious($channels, $page)) {
         $item = new X_Page_Item_PItem('previouspage', X_Env::_("previouspage", $page - 1, $totalPageCount));
         $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$gPage}/{$groupId}/" . ($page - 1))->setLink(array('l' => X_Env::encode("{$gPage}/{$groupId}/" . ($page - 1))), 'default', false);
         $items->append($item);
     }
     foreach ($this->helpers()->paginator()->getPage($channels, $page) as $channel) {
         $item = new X_Page_Item_PItem($this->getId() . "-{$groupId}-" . $channel['id'], $channel['title']);
         $item->setIcon('/images/icons/hosters/sopcast.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$gPage}/{$groupId}/{$page}/sopcast:{$channel['url']}")->setDescription("{$gPage}/{$groupId}/{$page}/sopcast:{$channel['url']}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$gPage}/{$groupId}/{$page}/sopcast:{$channel['url']}")), 'default', false);
         $items->append($item);
     }
     if ($this->helpers()->paginator()->hasNext($channels, $page)) {
         $item = new X_Page_Item_PItem('nextpage', X_Env::_("nextpage", $page + 1, $totalPageCount));
         $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$gPage}/{$groupId}/" . ($page + 1))->setLink(array('l' => X_Env::encode("{$gPage}/{$groupId}/" . ($page + 1))), 'default', false);
         $items->append($item);
     }
 }