public function gen_afterPageBuild(X_Page_ItemList_PItem $list, Zend_Controller_Action $controller)
 {
     if (!$this->isDefaultRenderer()) {
         return;
     }
     X_Debug::i("Plugin triggered");
     $request = $controller->getRequest();
     $responseType = 'u:BrowseResponse';
     $num = count($list->getItems());
     if ($this->request['browseflag'] == 'BrowseMetadata') {
         $parentID = $this->_getParent($controller->getRequest());
         $item = new X_Page_Item_PItem('fake-item', "Container");
         $item->setLink(array_merge(array('controller' => $controller->getRequest()->getControllerName(), 'action' => $controller->getRequest()->getActionName()), $controller->getRequest()->getParams()));
         $item->setDescription("Fake description");
         $didl = X_Upnp::createMetaDIDL($item, $parentID, $num, $controller->getRequest()->getControllerName(), $controller->getRequest()->getActionName(), $controller->getRequest()->getParam('p', 'null'));
     } elseif ($this->request['browseflag'] == 'BrowseDirectChildren') {
         $parentID = $this->request['objectid'];
         $didl = X_Upnp::createDIDL($list->getItems(), $parentID, $num, $controller->getRequest()->getControllerName(), $controller->getRequest()->getActionName(), $controller->getRequest()->getParam('p', 'null'));
     }
     $xmlDIDL = $didl->saveXML();
     X_Debug::i("DIDL response: {$xmlDIDL}");
     // Build SOAP-XML reply from DIDL-XML and send it to upnp device
     $domSOAP = X_Upnp::createSOAPEnvelope($xmlDIDL, $num, $num, $responseType, $parentID);
     $soapXML = $domSOAP->saveXML();
     // turn off viewRenderer and Layout, add Content-Type and set response body
     $this->_render($soapXML, $controller);
 }
 static function sortAlphabetically(X_Page_Item_PItem $item1, X_Page_Item_PItem $item2)
 {
     // prevent warning for array modification
     $label1 = $item1->getLabel();
     $label2 = $item2->getLabel();
     return strcasecmp($label1, $label2);
 }
 public function gen_afterPageBuild(X_Page_ItemList_PItem $items, Zend_Controller_Action $controller)
 {
     if (count($items->getItems()) == 0) {
         X_Debug::i("Plugin triggered");
         $item = new X_Page_Item_PItem('emptylists', X_Env::_('p_emptylists_moveaway'));
         $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($controller->getHelper('url')->url()));
         $items->append($item);
     }
 }
 public function gen_afterPageBuild(X_Page_ItemList_PItem $items, Zend_Controller_Action $controller)
 {
     if ($this->helpers()->devices()->isWiimc() && $this->helpers()->devices()->isWiimcBeforeVersion('1.0.9')) {
         if (count($items->getItems()) === 1) {
             X_Debug::i("Plugin triggered");
             $item = new X_Page_Item_PItem('workaroundwiimcplaylistitemsbug', '-- Workaround for bug in Wiimc <= 1.0.9 --');
             $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($controller->getHelper('url')->url()));
             $items->append($item);
         }
     }
 }
 /**
  * Add the button BackToStream in controls page
  *
  * @param X_Streamer_Engine $engine
  * @param Zend_Controller_Action $controller the controller who handle the request
  * @return array
  */
 public function preGetControlItems(X_Streamer_Engine $engine, Zend_Controller_Action $controller)
 {
     // ignore if the streamer is not vlc
     if (!$engine instanceof X_Streamer_Engine_RtmpDump) {
         return;
     }
     $outputLink = "http://{%SERVER_NAME%}:{$this->helpers()->rtmpdump()->getStreamPort()}/";
     $outputLink = str_replace(array('{%SERVER_IP%}', '{%SERVER_NAME%}'), array($_SERVER['SERVER_ADDR'], strstr($_SERVER['HTTP_HOST'], ':') ? strstr($_SERVER['HTTP_HOST'], ':') : $_SERVER['HTTP_HOST']), $outputLink);
     $item = new X_Page_Item_PItem($this->getId(), X_Env::_('p_profiles_backstream'));
     $item->setType(X_Page_Item_PItem::TYPE_PLAYABLE)->setIcon('/images/icons/play.png')->setLink($outputLink);
     return new X_Page_ItemList_PItem(array($item));
 }
 public function getModeItems($provider, $location, Zend_Controller_Action $controller)
 {
     $list = new X_Page_ItemList_PItem();
     $urlHelper = $controller->getHelper('url');
     if ($this->countdown > 0) {
         $countdown = new X_Page_Item_PItem('core-countdown', X_Env::_('core_countdown', $this->countdown));
         $countdown->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon("/images/{$this->getId()}/logo.png")->setLink(X_Env::completeUrl($urlHelper->url()));
         $list->append($countdown);
     }
     if ($this->error_message) {
         $error = new X_Page_Item_PItem('core-error', X_Env::_($this->error_message));
         $error->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon("/images/{$this->getId()}/logo.png")->setLink(X_Env::completeUrl($urlHelper->url()));
         $list->append($error);
     }
     return $list;
 }
 /**
  * Return the -shared-folders- link
  * for the collection index
  * @param Zend_Controller_Action $controller
  * @return X_Page_ItemList_PItem
  */
 public function preGetCollectionsItems(Zend_Controller_Action $controller)
 {
     X_Debug::i("Plugin triggered");
     $updates = $this->checkUpdates();
     /* @var $urlHelper Zend_Controller_Action_Helper_Url */
     $urlHelper = $controller->getHelper('url');
     $list = new X_Page_ItemList_PItem();
     if ($updates['core'] !== false) {
         $link = new X_Page_Item_PItem("{$this->getId()}-coreupdate", X_Env::_('p_updatenotifier_collectionindex_core'));
         $link->setIcon('/images/updatenotifier/logo.png')->setDescription(X_Env::_('p_updatenotifier_collectionindex_core_desc'))->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink($urlHelper->url());
         $list->append($link);
     }
     if (count($updates['plugins'])) {
         $link = new X_Page_Item_PItem("{$this->getId()}-pluginsupdate", X_Env::_('p_updatenotifier_collectionindex_plugins', count($updates['plugins'])));
         $link->setIcon('/images/updatenotifier/logo.png')->setDescription(X_Env::_('p_updatenotifier_collectionindex_plugins_desc'))->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink($urlHelper->url());
         $list->append($link);
     }
     return count($list->getItems()) ? $list : null;
 }
 /**
  * Add the button BackToStream in controls page
  *
  * @param X_Streamer_Engine $engine
  * @param Zend_Controller_Action $controller the controller who handle the request
  * @return array
  */
 public function preGetControlItems(X_Streamer_Engine $engine, Zend_Controller_Action $controller)
 {
     $urlHelper = $controller->getHelper('url');
     $return = new X_Page_ItemList_PItem();
     if ($this->config('show.title', true)) {
         $onAirName = X_Env::_("p_streaminfo_unknown_source");
         if ($engine instanceof X_Streamer_Engine_Vlc) {
             $vlc = $engine->getVlcWrapper();
             $onAirName = $vlc->getCurrentName();
         } else {
             // try to find the name from the location (if any)
             $providerId = $controller->getRequest()->getParam('p', false);
             $location = $controller->getRequest()->getParam('l', false);
             if ($providerId && $location) {
                 $providerObj = X_VlcShares_Plugins::broker()->getPlugins($providerId);
                 $location = X_Env::decode($location);
                 if ($providerObj instanceof X_VlcShares_Plugins_ResolverInterface) {
                     $onAirName = $providerObj->resolveLocation($location);
                 }
             }
         }
         // show the title of the file
         $item = new X_Page_Item_PItem('streaminfo-onair', X_Env::_('p_streaminfo_onair') . ": {$onAirName}");
         $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($urlHelper->url()));
         $return->append($item);
     }
     if ($engine instanceof X_Streamer_Engine_Vlc) {
         $vlc = $engine->getVlcWrapper();
         if ($this->config('show.time', false)) {
             $currentTime = X_Env::formatTime($vlc->getCurrentTime());
             $totalTime = X_Env::formatTime($vlc->getTotalTime());
             $item = new X_Page_Item_PItem('streaminfo-time', "{$currentTime}/{$totalTime}");
             $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($urlHelper->url()));
             $return->append($item);
         }
     }
     return $return;
 }
 /**
  * Check the item in the collection should be filtered out
  * If return is false, the item will be discarded at 100%
  * If return is true, isn't sure that the item will be added
  * 'cause another plugin can prevent this
  * 
  * Plugins who check per-item acl or blacklist should hook here
  * 
  * @param X_Page_Item_PItem $item
  * @param string $provider
  * @param Zend_Controller_Action $controller
  * @return boolean true if item is ok, false if item should be discarded
  */
 public function filterShareItems(X_Page_Item_PItem $item, $provider, Zend_Controller_Action $controller)
 {
     $providerClass = X_VlcShares_Plugins::broker()->getPluginClass($provider);
     $providerObj = X_VlcShares_Plugins::broker()->getPlugins($provider);
     if (is_a($providerObj, 'X_VlcShares_Plugins_FileSystem')) {
         if ($item->getType() == X_Page_Item_PItem::TYPE_ELEMENT) {
             $itemLocation = $item->getCustom('X_VlcShares_Plugins_FileSystem:location');
             /* @var $urlHelper Zend_Controller_Action_Helper_Url */
             $urlHelper = $controller->getHelper('url');
             $path = $providerObj->resolveLocation($itemLocation);
             $thumb = new Application_Model_FsThumb();
             Application_Model_FsThumbsMapper::i()->fetchByPath($path, $thumb);
             if ($thumb->isNew()) {
                 $thumbUrl = X_Env::completeUrl($urlHelper->direct('thumb', 'fsthumbs', 'default', array('l' => X_Env::encode($itemLocation), 't' => 'dummy.jpg')));
             } else {
                 $thumbUrl = X_Env::completeUrl(Zend_Controller_Front::getInstance()->getBaseUrl() . $thumb->getUrl());
             }
             //$item->setDescription($itemLocation);
             $item->setThumbnail($thumbUrl);
         }
     }
     return true;
 }
 /**
  * Return true if $item is an hidden file or system file (check configs)
  * @param X_Page_Item_PItem $item
  * @param string $provider
  * @param Zend_Controller_Action $controller
  * @return boolean|null true or null if file is ok, false otherwise (will be filtered out)
  */
 public function filterShareItems(X_Page_Item_PItem $item, $provider, Zend_Controller_Action $controller)
 {
     try {
         $plugin = X_VlcShares_Plugins::broker()->getPlugins($provider);
         if (is_a($plugin, 'X_VlcShares_Plugins_FileSystem') && $plugin instanceof X_VlcShares_Plugins_ResolverInterface) {
             // i use instanceof ResolverInterface
             // so i have code suggestions
             // X_VlcShares_Plugins_FileSystem register a custom param in item
             // for location lookup
             $location = $plugin->resolveLocation($item->getCustom('X_VlcShares_Plugins_FileSystem:location'));
             // i must check for $location !== false as a fallback for no custom param case
             if ($location !== false && file_exists($location)) {
                 // i have a location to check for hidden files:
                 if ($this->_checkEntry($location) === false) {
                     X_Debug::i("Plugin triggered, item filtered: {$location}");
                     return false;
                 }
             }
             //X_Debug::i('Plugin triggered');
         }
     } catch (Exception $e) {
         X_Debug::w("Problem while filtering: {$e->getMessage()}");
     }
 }
 /**
  * Add megavideo id to jdownloader download queue
  * @param string $provider
  * @param string $location
  * @param string $pid
  * @param Zend_Controller_Action $controller
  * @return X_Page_ItemList_PItem
  */
 public function getSelectionItems($provider, $location, $pid, Zend_Controller_Action $controller)
 {
     // we want to expose items only if pid is this plugin
     if ($this->getId() != $pid) {
         return;
     }
     X_Debug::i('Plugin triggered');
     $action = $controller->getRequest()->getParam("{$this->getId()}:action", '');
     /* @var $jdownloader X_VlcShares_Plugins_Helper_JDownloader */
     $jdownloader = $this->helpers('jdownloader');
     // IF action = 'start, stop or pause'
     // execute the action and return confirm, then exit
     if ($action != '') {
         try {
             if ($action == "start") {
                 $jdownloader->sendRawCommand(X_VlcShares_Plugins_Helper_JDownloader::CMD_ACTION_START);
                 $link = new X_Page_Item_PItem($this->getId() . '-started', X_Env::_('p_jdownloader_selection_started'));
                 $link->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'share', 'pid' => null, "{$this->getId()}:action" => null), 'default', false);
                 return new X_Page_ItemList_PItem(array($link));
             }
             if ($action == "pause") {
                 $jdownloader->sendRawCommand(X_VlcShares_Plugins_Helper_JDownloader::CMD_ACTION_PAUSE);
                 $link = new X_Page_Item_PItem($this->getId() . '-started', X_Env::_('p_jdownloader_selection_paused'));
                 $link->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'share', 'pid' => null, "{$this->getId()}:action" => null), 'default', false);
                 return new X_Page_ItemList_PItem(array($link));
             }
             if ($action == "stop") {
                 $jdownloader->sendRawCommand(X_VlcShares_Plugins_Helper_JDownloader::CMD_ACTION_STOP);
                 $link = new X_Page_Item_PItem($this->getId() . '-started', X_Env::_('p_jdownloader_selection_stopped'));
                 $link->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'share', 'pid' => null, "{$this->getId()}:action" => null), 'default', false);
                 return new X_Page_ItemList_PItem(array($link));
             }
         } catch (Exception $e) {
             // connection problems or timeout
             $link = new X_Page_Item_PItem($this->getId() . '-error', X_Env::_('p_jdownloader_selection_error_network'));
             $link->setDescription($e->getMessage());
             $link->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'share', 'pid' => null, "{$this->getId()}:action" => null), 'default', false);
             return new X_Page_ItemList_PItem(array($link));
         }
     } else {
         // else only confirm the addict
         /* @var $megavideo X_VlcShares_Plugins_Helper_Megavideo */
         $megavideo = $this->helpers('megavideo');
         try {
             $megavideo->getServer();
         } catch (Exception $e) {
             // not loaded location yet
             X_Debug::i("Force location loading");
             $providerObj = X_VlcShares_Plugins::broker()->getPlugins($provider);
             if ($providerObj instanceof X_VlcShares_Plugins_ResolverInterface) {
                 $providerObj->resolveLocation($location);
             }
         }
         $url = null;
         try {
             $url = "http://www.megavideo.com/?v=" . $megavideo->getId();
         } catch (Exception $e) {
             // TODO please, rewrite this piece of code
             // it's really a shame
             // let's try to get the url from the hoster
             try {
                 switch ($provider) {
                     // special cases
                     case 'onlinelibrary':
                         // hoster/id is stored inside db
                         $exploded = explode('/', $location);
                         $exploded = array_pop($exploded);
                         $video = new Application_Model_Video();
                         Application_Model_VideosMapper::i()->find($exploded, $video);
                         $hoster = $video->getHoster();
                         $videoId = $video->getIdVideo();
                         break;
                     default:
                         // we try to get information by location decoding
                         // many plugins use a /-divided location with last param in the format of HOSTER:VIDEOID
                         $exploded = explode('/', $location);
                         $exploded = array_pop($exploded);
                         $exploded = explode(':', $exploded, 2);
                         @(list($hoster, $videoId) = $exploded);
                         break;
                 }
                 // lets search a valid hoster
                 $url = $this->helpers()->hoster()->getHoster($hoster)->getHosterUrl($videoId);
             } catch (Exception $e) {
                 // simply: provider isn't compatible
                 // trying direct download
                 $pObj = X_VlcShares_Plugins::broker()->getPlugins($provider);
                 if ($pObj instanceof X_VlcShares_Plugins_ResolverInterface) {
                     $url = $pObj->resolveLocation($location);
                     if (!X_Env::startWith($url, "http://") && !X_Env::startWith($url, "https://")) {
                         // not valid, revert changes
                         $url = null;
                     }
                 }
             }
         }
         try {
             if ($url === null) {
                 throw new Exception();
             }
             X_Debug::i("Appending {{$url}} to the queue");
             $jdownloader->addLink($url);
             $link = new X_Page_Item_PItem($this->getId() . '-added', X_Env::_('p_jdownloader_selection_added'));
         } catch (Zend_Http_Client_Adapter_Exception $e) {
             // connection problems or timeout
             $link = new X_Page_Item_PItem($this->getId() . '-error', X_Env::_('p_jdownloader_selection_error_network'));
             $link->setDescription($e->getMessage());
         } catch (Exception $e) {
             // wrapper/other error
             X_Debug::e("Trying to add a new download to JDowloader, but location isn't a megavideo url or there is an error");
             $link = new X_Page_Item_PItem($this->getId() . '-error', X_Env::_('p_jdownloader_selection_error_invalid'));
             $link->setDescription($e->getMessage());
         }
         $link->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'mode', $this->getId() => null, 'pid' => null), 'default', false);
         return new X_Page_ItemList_PItem(array($link));
     }
 }
 private function _prepareVideo(X_Page_ItemList_PItem $items, Zend_Gdata_Media_Feed $feed, $locationPrefix)
 {
     foreach ($feed as $yvideo) {
         /* @var $yvideo Zend_Gdata_YouTube_VideoEntry */
         if ($yvideo->getVideoDuration() == 0) {
             continue;
         }
         // no duration = no video
         $item = new X_Page_Item_PItem('youtube-video-' . $yvideo->getVideoId(), $yvideo->getVideoTitle() . ' [' . X_Env::formatTime($yvideo->getVideoDuration()) . ']');
         $thumb = $yvideo->getVideoThumbnails();
         @($thumb = $thumb[0]['url']);
         $item->setDescription($yvideo->getVideoDescription())->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon('/images/youtube/icons/video.png')->setThumbnail($thumb)->setCustom(__CLASS__ . ':location', "{$locationPrefix}/{$yvideo->getVideoId()}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$locationPrefix}/{$yvideo->getVideoId()}")), 'default', false)->setGenerator(__CLASS__);
         $items->append($item);
     }
 }
 /**
  * Remove vlc-play button if location is invalid
  * @param X_Page_Item_PItem $item,
  * @param string $provider
  * @param Zend_Controller_Action $controller
  */
 public function filterModeItems(X_Page_Item_PItem $item, $provider, Zend_Controller_Action $controller)
 {
     if ($item->getKey() == 'core-play') {
         X_Debug::i('plugin triggered');
         X_Debug::w('core-play flagged as invalid because the link is invalid');
         return false;
     }
 }
 public function getSelectionItems($provider, $location, $pid, Zend_Controller_Action $controller)
 {
     // we want to expose items only if pid is this plugin
     if ($this->getId() != $pid) {
         return;
     }
     // check for resolvable $location
     // this plugin is useless if i haven't an access
     // to the real location (url for stream or path for file)
     $provider = X_VlcShares_Plugins::broker()->getPlugins($provider);
     if (!$provider instanceof X_VlcShares_Plugins_ResolverInterface) {
         return;
     }
     $providerClass = get_class($provider);
     X_Debug::i('Plugin triggered');
     $urlHelper = $controller->getHelper('url');
     // i try to mark current selected sub based on $this->getId() param
     // in $currentSub i get the name of the current profile
     $currentSub = $controller->getRequest()->getParam($this->getId(), false);
     if ($currentSub !== false) {
         $currentSub = X_Env::decode($currentSub);
     }
     $return = new X_Page_ItemList_PItem();
     $item = new X_Page_Item_PItem($this->getId() . '-none', X_Env::_('p_audioswitcher_selection_none'));
     $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'mode', $this->getId() => null, 'pid' => null), 'default', false)->setHighlight($currentSub === false);
     $return->append($item);
     // i do the check for this on top
     // location param come in a plugin encoded way
     $location = $provider->resolveLocation($location);
     // check if infile support is enabled
     // by default infile.enabled is true
     if ($this->config('infile.enabled', true)) {
         // check for infile tracks
         $infileTracks = $this->helpers()->stream()->setLocation($location)->getAudiosInfo();
         //X_Debug::i(var_export($infileSubs, true));
         foreach ($infileTracks as $streamId => $track) {
             X_Debug::i("Valid infile-sub: [{$streamId}] {$track['language']} ({$track['format']})");
             $item = new X_Page_Item_PItem($this->getId() . '-stream-' . $streamId, X_Env::_("p_audioswitcher_subtype_" . self::STREAM) . " {$streamId} {$track['language']} {$track['format']}");
             $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':sub', self::STREAM . ":{$streamId}")->setLink(array('action' => 'mode', 'pid' => null, $this->getId() => X_Env::encode(self::STREAM . ":{$streamId}")), 'default', false)->setHighlight($currentSub == self::STREAM . ":{$streamId}");
             $return->append($item);
         }
     }
     // for file system source i will search for subs in filename notation
     // by default file.enabled is true
     if ($this->config('file.enabled', true) && is_a($provider, 'X_VlcShares_Plugins_FileSystem')) {
         $dirname = pathinfo($location, PATHINFO_DIRNAME);
         $filename = pathinfo($location, PATHINFO_FILENAME);
         $extTracks = $this->getFSTracks($dirname, $filename);
         foreach ($extTracks as $streamId => $track) {
             X_Debug::i("Valid extfile-sub: {$track['language']} ({$track['format']})");
             $item = new X_Page_Item_PItem($this->getId() . '-file-' . $streamId, X_Env::_("p_audioswitcher_subtype_" . self::FILE) . " {$track['language']} ({$track['format']})");
             $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':sub', self::FILE . ":{$streamId}")->setLink(array('action' => 'mode', 'pid' => null, $this->getId() => X_Env::encode(self::FILE . ":{$streamId}")), 'default', false)->setHighlight($currentSub == self::FILE . ":{$streamId}");
             $return->append($item);
         }
     }
     // general profiles are in the bottom of array
     return $return;
 }
 public function executeAction()
 {
     $request = $this->getRequest();
     //X_VlcShares_Plugins::broker()->gen_preProviderSelection($this);
     /*
     $provider = $request->getParam('p', false);
     if ( $provider === false || !X_VlcShares_Plugins::broker()->isRegistered($provider) ) {
     	throw new Exception("Invalid provider");
     }
     $location = X_Env::decode($request->getParam('l', ''));
     */
     $pid = $request->getParam('pid', false);
     $a = $request->getParam('a', false);
     $engineId = X_Streamer::i()->getStreamingEngineId();
     $engine = X_VlcShares_Plugins::helpers()->streamer()->get($engineId);
     X_VlcShares_Plugins::broker()->preExecute($engine, $pid, $a, $this);
     X_VlcShares_Plugins::broker()->execute($engine, $pid, $a, $this);
     X_VlcShares_Plugins::broker()->postExecute($engine, $pid, $a, $this);
     $pageItems = new X_Page_ItemList_PItem();
     $done = new X_Page_Item_PItem('core-opdone', X_Env::_('controls_done'));
     $done->setCustom('vlc_still_alive', $this->vlc->isRunning())->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('controller' => 'controls', 'action' => 'control', 'pid' => null, 'a' => null, 'param' => null), 'default', false);
     $pageItems->append($done);
     // links on top
     $pageItems->merge(X_VlcShares_Plugins::broker()->preGetExecuteItems($pid, $a, $this));
     // add separator between play items and options items
     $separator = new X_Page_Item_PItem('core-separator', X_Env::_('_____options_separator_____'));
     $separator->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('controller' => 'controls', 'action' => 'control', 'pid' => null, 'a' => null, 'param' => null), 'default', false);
     $pageItems->append($separator);
     // normal links
     $pageItems->merge(X_VlcShares_Plugins::broker()->getExecuteItems($pid, $a, $this));
     // bottom links
     $pageItems->merge(X_VlcShares_Plugins::broker()->postGetExecuteItems($pid, $a, $this));
     // trigger for page creation
     X_VlcShares_Plugins::broker()->gen_afterPageBuild($pageItems, $this);
 }
 /**
  *	Add button -watch megavideo stream directly-
  * 
  * @param string $provider
  * @param string $location
  * @param Zend_Controller_Action $controller
  */
 public function preGetModeItems($provider, $location, Zend_Controller_Action $controller)
 {
     if ($provider != $this->getId()) {
         return;
     }
     X_Debug::i("Plugin triggered");
     $url = $this->resolveLocation($location);
     if ($url) {
         $link = new X_Page_Item_PItem('core-directwatch', X_Env::_('p_animeland_watchdirectly'));
         $link->setIcon('/images/icons/play.png')->setType(X_Page_Item_PItem::TYPE_PLAYABLE)->setLink($url);
         return new X_Page_ItemList_PItem(array($link));
     }
 }
 protected function getDisableCacheButton()
 {
     $link = new X_Page_Item_PItem('core-cache-disable', X_Env::_('p_cache_disablebutton', date('d/m/Y H:i', $this->inCache->getCreated())));
     $link->setDescription(X_Env::_('p_cache_disablebutton_desc'))->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setLink(array($this->getId() => '0'), 'default', false);
     return $link;
 }
 public function menuChannels(X_Page_ItemList_PItem $items)
 {
     /* @var $parsed SimpleXmlElement */
     $page = $this->getChannelsListRaw();
     $parser = new X_PageParser_Parser_Own3dLive();
     $parsed = $parser->parse($page);
     if (!$parsed) {
         return;
     }
     foreach ($parsed as $match) {
         /* @var $match array */
         $id = "{$match['hoster']}:{$match['id']}";
         $label = $match['label'];
         $item = new X_Page_Item_PItem($this->getId() . "-{$id}", $label);
         $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$id}")->setDescription(APPLICATION_ENV == 'development' ? "{$id}" : null)->setIcon("/images/icons/hosters/own3dlive.png")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$id}")), 'default', false);
         $items->append($item);
     }
 }
 public function menuLinks(X_Page_ItemList_PItem $items, $category, $show, $type)
 {
     $i = 0;
     while (true) {
         $page = X_PageParser_Page::getPage(sprintf(self::URL_INDEX_LINKS, $type, $i++), new X_PageParser_Parser_Preg('/<a .*?href=\\"\\/dl\\/RaiTV\\/programmi\\/media\\/ContentItem-(?P<href>.*?).html#p=0\\".*?src=\\"(?P<thumbnail>.*?)\\".*?><h2>(?P<label>.*?)<\\/h2>/s', X_PageParser_Parser_Preg::PREG_MATCH_ALL, PREG_SET_ORDER));
         $this->preparePageLoader($page);
         $parsed = $page->getParsed();
         // exit first time no item found
         if (!count($parsed)) {
             return;
         }
         foreach ($parsed as $match) {
             $label = $match['label'];
             $href = $match['href'];
             $thumbnail = $match['thumbnail'];
             if ($thumbnail && !X_Env::startWith($thumbnail, 'http://')) {
                 $thumbnail = sprintf(self::URL_BASE, ltrim($thumbnail, '/'));
             }
             $item = new X_Page_Item_PItem($this->getId() . "-{$show}-{$type}-{$href}", $label);
             $item->setIcon("/images/icons/file_32.png");
             $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$category}/{$show}/{$type}/{$href}")->setThumbnail($thumbnail)->setDescription(APPLICATION_ENV == 'development' ? "{$category}/{$show}/{$type}/{$href}" : null)->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$category}/{$show}/{$type}/{$href}")), 'default', false);
             $items->append($item);
         }
     }
 }
 /**
  * Show a list of valid subs for the selected location
  * @param string $provider
  * @param string $location
  * @param string $pid
  * @param Zend_Controller_Action $controller
  * @return X_Page_ItemList_PItem
  */
 public function getSelectionItems($provider, $location, $pid, Zend_Controller_Action $controller)
 {
     // we want to expose items only if pid is this plugin
     if ($this->getId() != $pid) {
         return;
     }
     X_Debug::i('Plugin triggered');
     $urlHelper = $controller->getHelper('url');
     // i try to mark current selected sub based on $this->getId() param
     // in $currentSub i get the name of the current profile
     $currentSub = $controller->getRequest()->getParam($this->getId() . ':quality', false);
     $return = new X_Page_ItemList_PItem();
     $item = new X_Page_Item_PItem($this->getId() . '-normal', X_Env::_('p_megavideo_qualityselection_normal'));
     $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'mode', $this->getId() . ':quality' => null, 'pid' => null), 'default', false)->setHighlight($currentSub === false || $currentSub == X_VlcShares_Plugins_Helper_Megavideo::QUALITY_NORMAL);
     $return->append($item);
     $item = new X_Page_Item_PItem($this->getId() . '-full', X_Env::_('p_megavideo_qualityselection_full'));
     $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'mode', $this->getId() . ':quality' => X_VlcShares_Plugins_Helper_Megavideo::QUALITY_FULL, 'pid' => null), 'default', false)->setHighlight($currentSub == X_VlcShares_Plugins_Helper_Megavideo::QUALITY_FULL);
     $return->append($item);
     $item = new X_Page_Item_PItem($this->getId() . '-full', X_Env::_('p_megavideo_qualityselection_nopremium'));
     $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'mode', $this->getId() . ':quality' => X_VlcShares_Plugins_Helper_Megavideo::QUALITY_NOPREMIUM, 'pid' => null), 'default', false)->setHighlight($currentSub == X_VlcShares_Plugins_Helper_Megavideo::QUALITY_NOPREMIUM);
     $return->append($item);
     return $return;
 }
 public function menuEpisodes(X_Page_ItemList_PItem $items, $type, $filter, $pageN, $show, $season, $showType)
 {
     $page = X_PageParser_Page::getPage(sprintf(self::URL_BASE, $show), new X_PageParser_Parser_Preg('/new VideoSlider\\("' . $showType . '",(?P<json>.*?)\\)\\s+\\/\\/]]>/si', X_PageParser_Parser_Preg::PREG_MATCH));
     $this->preparePageLoader($page);
     $parsed = $page->getParsed();
     if ($parsed) {
         $json = Zend_Json::decode($parsed['json']);
         $url = "{$json['url']}?";
         foreach ($json['urlOptions'] as $key => $value) {
             if ($key == 'season') {
                 $value = $season;
             }
             if ($key == 'page') {
                 $value = "%s";
             }
             $url .= "{$key}={$value}&";
         }
         $url = rtrim($url, "&");
         $i = 1;
         while (true) {
             $page = X_PageParser_Page::getPage(sprintf($url, $i++), new X_PageParser_Parser_Preg('/<li.*?<a href=".*?watch\\/(?P<epid>.*?)\\/(?P<epname>.*?)".*?<img src="(?P<thumbnail>.*?)".*?alt="(?P<label>.*?)"(?P<extra>.*?)<\\/li>/s', X_PageParser_Parser_Preg::PREG_MATCH_ALL, PREG_SET_ORDER));
             $this->preparePageLoader($page);
             $parsed = $page->getParsed();
             // exit first time no item found
             if (!count($parsed)) {
                 return;
             }
             foreach ($parsed as $match) {
                 $label = $match['label'];
                 $href = "{$match['epid']}:{$match['epname']}";
                 $thumbnail = $match['thumbnail'];
                 if (strpos($match['extra'], 'class="hplus-sticker') !== false) {
                     // can ignore plus content
                     if (!$this->config('show.plus', true)) {
                         continue;
                     }
                     $label = "[Hulu+] {$label}";
                 }
                 $item = new X_Page_Item_PItem($this->getId() . "-{$show}-{$season}-{$href}", $label);
                 $item->setIcon("/images/icons/file_32.png");
                 $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$type}/{$filter}/{$pageN}/{$show}/{$season}:{$showType}/{$href}")->setThumbnail($thumbnail)->setDescription(APPLICATION_ENV == 'development' ? "{$type}/{$filter}/{$pageN}/{$show}/{$season}:{$showType}/{$href}" : null)->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$type}/{$filter}/{$pageN}/{$show}/{$season}:{$showType}/{$href}")), 'default', false);
                 $items->append($item);
             }
             // if parsed < per-page, i know there are no more videos
             if (count($parsed) < 5) {
                 break;
             }
         }
     }
 }
 /**
  * Convert an array of items in DIDL xml format
  * @param array $prmItems
  */
 static function createMetaDIDL(X_Page_Item_PItem $item, $parentUrl = '0', &$num, $defaultController = 'browse', $defaultAction = 'share', $defaultProvider = 'onlinelibrary')
 {
     # TODO: put object.container in container tags where they belong. But as long as the WDTVL doesn't mind... ;)
     # $prmItems is an array of arrays
     $xmlDoc = new DOMDocument('1.0', 'utf-8');
     $xmlDoc->formatOutput = true;
     # Create root element and add namespaces:
     $ndDIDL = $xmlDoc->createElementNS('urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/', 'DIDL-Lite');
     $ndDIDL->setAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
     $ndDIDL->setAttribute('xmlns:upnp', 'urn:schemas-upnp-org:metadata-1-0/upnp/');
     $ndDIDL->setAttribute('xmlns:dnla', 'urn:schemas-dlna-org:metadata-1-0/');
     $xmlDoc->appendChild($ndDIDL);
     //$ndRes = $xmlDoc->createElement('res');
     // container, request, element
     $ndItem = $xmlDoc->createElement('container');
     self::appendTag('upnp:class', 'object.container', $ndItem, $xmlDoc);
     $ndItem->setAttribute('childCount', $num);
     //{{{ MANDATORY PARAMS
     if ($item->isUrl()) {
         $ndItem->setAttribute('id', "{$parentUrl}/" . X_Env::_($item->getKey()));
     } else {
         $controller = $item->getLinkController() ? $item->getLinkController() : $defaultController;
         $action = $item->getLinkAction() ? $item->getLinkAction() : $defaultAction;
         $provider = $item->getLinkParam("p") ? $item->getLinkParam("p") : $defaultProvider;
         $location = $item->getLinkParam('l') ? $item->getLinkParam('l') : '';
         $params = $item->getLink();
         foreach (array('controller', 'action', 'p', 'l') as $key) {
             if (isset($params[$key])) {
                 unset($params[$key]);
             }
         }
         $customs = '';
         if (count($params)) {
             $customs .= '#';
             foreach ($params as $key => $value) {
                 $customs .= "/{$key}/{$value}";
             }
         }
         $ndItem->setAttribute('id', "{$controller}/{$action}/{$provider}/{$location}{$customs}");
     }
     $ndItem->setAttribute('parentID', $parentUrl);
     $ndItem->setAttribute('restricted', true);
     $ndItem->setAttribute('searchable', '0');
     //}}}
     self::appendTag('dc:title', $item->getLabel(), $ndItem, $xmlDoc);
     self::appendTag('dc:description', $item->getDescription(), $ndItem, $xmlDoc);
     if ($item->getThumbnail()) {
         self::appendTag('upnp:album_art', $item->getThumbnail(), $ndItem, $xmlDoc);
     }
     $ndDIDL->appendChild($ndItem);
     return $xmlDoc;
 }
 private function _fetchVideos(X_Page_ItemList_PItem $items, $sortType, $subType, $page, $serie, $thread)
 {
     X_Debug::i("Fetching videos for {$sortType}/{$subType}/{$page}/{$serie}/{$thread}");
     $url = $this->config('index.video.url', 'http://www.icefilms.info/membersonly/components/com_iceplayer/video.php?vid=') . $thread;
     $htmlString = $this->_loadPage($url);
     //$htmlString = str_replace(array("\n", "\r", "\t", chr(0xC2), chr(0xA0), chr(157)), '', $htmlString);
     X_Debug::i($htmlString);
     $catPattern = '/(*ANY)<div class\\=ripdiv><b>([^\\<]+)<\\/b>/';
     //$urlPattern = '/url\=http\:\/\/www.megaupload.com\/\?d\=([^\&]+)&([^\>]+)>([^\<]+)</';
     $urlPattern = '/onclick\\=\\\'go\\(([0-9]+)\\)\\\'\\>([^\\<]+)</';
     $matches = array();
     $links = array();
     if (preg_match_all($catPattern, $htmlString, $matches, PREG_OFFSET_CAPTURE)) {
         for ($i = 0; $i < count($matches[0]); $i++) {
             //$links[$matches[1][$i][0]] = array();
             $catLabel = $matches[1][$i][0];
             if (array_key_exists($i + 1, $matches[0])) {
                 if (!preg_match_all($urlPattern, substr($htmlString, $matches[0][$i][1], $matches[0][$i + 1][1] - $matches[0][$i][1]), $lMatches, PREG_SET_ORDER)) {
                     X_Debug::e("Pattern failure: {$urlPattern}");
                     continue;
                 }
             } else {
                 if (!preg_match_all($urlPattern, substr($htmlString, $matches[0][$i][1]), $lMatches, PREG_SET_ORDER)) {
                     X_Debug::e("Pattern failure: {$urlPattern}");
                     continue;
                 }
             }
             //X_Debug::i(var_export($lMatches, true));
             foreach ($lMatches as $lm) {
                 //@list(, $muId, , $label) = $lm;
                 @(list(, $muId, $label) = $lm);
                 // $muId now is a videoId of Icefilms
                 $label = "{$label} ({$catLabel})";
                 //$videoId = self::TYPE_MEGAUPLOAD.":$muId";
                 $videoId = $muId;
                 $item = new X_Page_Item_PItem($this->getId() . "-megaupload", "{$label}");
                 $item->setIcon('/images/icons/file_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$sortType}/{$subType}/{$page}/{$serie}/{$thread}/{$videoId}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$sortType}/{$subType}/{$page}/{$serie}/{$thread}/{$videoId}")), 'default', false);
                 if (APPLICATION_ENV == 'development') {
                     $item->setDescription("{$sortType}/{$subType}/{$page}/{$serie}/{$thread}/{$videoId}");
                 }
                 $items->append($item);
             }
         }
     } else {
         X_Debug::i("Pattern failure {$catPattern} or no video found");
     }
 }
 /**
  * Fill an X_Page_ItemList_PItem object ($items) with a 
  * simple list of static values
  * @param X_Page_ItemList_PItem $items
  * @param array $menuEntries an array of menu entries, keys are locations and values are label keys 
  * @param string $keyPrefix a string prepended to all items key 
  * @param string $locationPrefix a string prepended to all items location
  * @return X_Page_ItemList_PItem
  */
 static function fillStaticMenu(X_Page_ItemList_PItem $items, $menuEntries = array(), $keyPrefix = '', $locationPrefix = '')
 {
     foreach ($menuEntries as $location => $labelKey) {
         $entry = new X_Page_Item_PItem("{$keyPrefix}-{$location}", X_Env::_($labelKey));
         $entry->setDescription(APPLICATION_ENV == 'development' ? "{$locationPrefix}{$location}" : null);
         $entry->setGenerator(__METHOD__)->setIcon('/images/icons/folder_32.png')->setCustom(__METHOD__ . ":location", "{$locationPrefix}{$location}")->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setLink(array('l' => X_Env::encode("{$locationPrefix}{$location}")), 'default', false);
         $items->append($entry);
     }
     return $items;
 }
 public function selectionAction()
 {
     $request = $this->getRequest();
     X_VlcShares_Plugins::broker()->gen_preProviderSelection($this);
     $provider = $request->getParam('p', false);
     if ($provider === false || !X_VlcShares_Plugins::broker()->isRegistered($provider)) {
         throw new Exception("Invalid provider");
     }
     $pid = $request->getParam('pid', false);
     if ($pid === false || !X_VlcShares_Plugins::broker()->isRegistered($pid)) {
         throw new Exception("Invalid pluginId");
     }
     $location = X_Env::decode($request->getParam('l', ''));
     $pageItems = new X_Page_ItemList_PItem();
     // I add a "Back" button as first, this should redirect to mode action
     $back = new X_Page_Item_PItem('core-back', X_Env::_('back'));
     $back->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'mode', 'pid' => null), 'default', false);
     $pageItems->append($back);
     // links on top
     $pageItems->merge(X_VlcShares_Plugins::broker()->preGetSelectionItems($provider, $location, $pid, $this));
     // add separator between header items and options items
     $separator = new X_Page_Item_PItem('core-separator', X_Env::_('_____options_separator_____'));
     $separator->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($this->_helper->url->url()));
     $pageItems->append($separator);
     // normal links
     $pageItems->merge(X_VlcShares_Plugins::broker()->getSelectionItems($provider, $location, $pid, $this));
     // bottom links
     $pageItems->merge(X_VlcShares_Plugins::broker()->postGetSelectionItems($provider, $location, $pid, $this));
     // filter out items (parental-control / hidden file / system dir)
     foreach ($pageItems->getItems() as $key => $item) {
         $results = X_VlcShares_Plugins::broker()->filterSelectionItems($item, $provider, $pid, $this);
         if ($results != null && in_array(false, $results)) {
             $pageItems->remove($item);
         }
     }
     // trigger for page creation
     X_VlcShares_Plugins::broker()->gen_afterPageBuild($pageItems, $this);
 }
 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);
     }
     */
 }
 /**
  * Add the button BackToStream in controls page
  * 
  * @param X_Streamer_Engine $engine 
  * @param Zend_Controller_Action $controller the controller who handle the request
  * @return array
  */
 public function preGetControlItems(X_Streamer_Engine $engine, Zend_Controller_Action $controller)
 {
     // ignore if the streamer is not vlc
     if (!$engine instanceof X_Streamer_Engine_Vlc) {
         return;
     }
     X_Debug::i('Plugin triggered');
     $profileId = $controller->getRequest()->getParam($this->getId(), false);
     $urlHelper = $controller->getHelper('url');
     $outputLink = false;
     // i store the default link, so if i don't find the proper output
     // i will have a valid link for -go-to-stream- button
     //$output->setLink($this->config('default.link', "http://{$_SERVER['SERVER_ADDR']}:8081"));
     if ($profileId !== false) {
         $profile = new Application_Model_Profile();
         Application_Model_ProfilesMapper::i()->find($profileId, $profile);
         $outputLink = $profile->getLink();
     } else {
         // if store session is enabled, i try to get last output
         // method from store
         // else i fallback to best selection
         try {
             if ($this->config('store.session', true)) {
                 /* @var $cache X_VlcShares_Plugins_Helper_Cache */
                 $cache = $this->helpers()->helper('cache');
                 $outputLink = $cache->retrieveItem('profile::lastvlclink');
             }
         } catch (Exception $e) {
             // cache expired or cache disabled;
             X_Debug::i("Stored session not used");
         }
         if (!$outputLink) {
             X_Debug::i("Outputlink not found. Using best for this device");
             $profile = $this->getBest();
             $outputLink = $profile->getLink();
         }
     }
     $outputLink = self::prepareOutputLink($outputLink);
     $outputLink = str_replace(array('{%SERVER_IP%}', '{%SERVER_NAME%}'), array($_SERVER['SERVER_ADDR'], $_SERVER['HTTP_HOST']), $outputLink);
     $item = new X_Page_Item_PItem($this->getId(), X_Env::_('p_profiles_backstream'));
     $item->setType(X_Page_Item_PItem::TYPE_PLAYABLE)->setIcon('/images/icons/play.png')->setLink($outputLink);
     return new X_Page_ItemList_PItem(array($item));
 }
 public function menuChannels(X_Page_ItemList_PItem $items)
 {
     $auth = '';
     if ($this->config('auth.enabled', false)) {
         $auth = "&username="******"&userpassword="******"&option=andback";
     }
     $page = X_PageParser_Page::getPage(sprintf(self::URL_CHANNELS, $auth), new X_PageParser_Parser_Preg('%<p style="font-size:12px;.+>(?P<label>.*?)</a></p>(.*\\n){5}.*<a href="http://weeb.tv/channel/(?P<href>.*?)" title="(.*?)"><img src="(?P<thumbnail>.*)" alt=".*?" height="100" width="100" /></a>%', X_PageParser_Parser_Preg::PREG_MATCH_ALL, PREG_SET_ORDER));
     $this->preparePageLoader($page);
     $parsed = $page->getParsed();
     foreach ($parsed as $match) {
         $thumbnail = $match['thumbnail'];
         $label = $match['label'];
         $href = $match['href'];
         $item = new X_Page_Item_PItem($this->getId() . "-{$label}", $label);
         $item->setIcon('/images/icons/file_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$href}")->setDescription(APPLICATION_ENV == 'development' ? "{$href}" : null)->setThumbnail($thumbnail)->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$href}")), 'default', false);
         $items->append($item);
     }
 }
 /**
  * Add the go-to-control-page
  * 
  * @param X_Streamer_Engine $engine selected streamer engine
  * @param string $uri
  * @param string $provider id of the plugin that should handle request
  * @param string $location to stream
  * @param Zend_Controller_Action $controller the controller who handle the request
  * @return X_Page_ItemList_PItem 
  */
 public function getStreamItems(X_Streamer_Engine $engine, $uri, $provider, $location, Zend_Controller_Action $controller)
 {
     $urlHelper = $controller->getHelper('url');
     $item = new X_Page_Item_PItem($this->getId(), X_Env::_('p_controls_gotocontrols'));
     $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon('/images/icons/controls.png')->setLink(array('controller' => 'controls', 'action' => 'control'), 'default', false);
     return new X_Page_ItemList_PItem(array($item));
 }
 private function _fetchVideos(X_Page_ItemList_PItem $items, $resourceType, $pageN, $resourceGroup, $resourceId)
 {
     X_Debug::i("Fetching videos for {$resourceType}, {$pageN}, {$resourceGroup}, {$resourceId}");
     // as first thing we have to recreate the resource url from resourceId
     $url = sprintf(self::URL_BASE, $resourceId);
     $page = X_PageParser_Page::getPage($url, X_PageParser_Parser_StreamingOnlineVideos::instance());
     $this->preparePageLoader($page);
     foreach ($page->getParsed() as $link) {
         $videoId = $link['videoId'];
         $hosterId = $link['hosterId'];
         $videoCode = $link['link'];
         $videoLabel = trim("{$link['label']} [{$link['hosterId']}]");
         //$videoThumb = $link['thumbnail'];
         $item = new X_Page_Item_PItem("{$this->getId()}-hoster-{$hosterId}-{$videoId}", $videoLabel);
         $item->setIcon('/images/icons/file_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$resourceType}/{$pageN}/{$resourceGroup}/{$resourceId}/{$videoCode}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$resourceType}/{$pageN}/{$resourceGroup}/{$resourceId}/{$videoCode}")), 'default', false);
         if (APPLICATION_ENV == 'development') {
             $item->setDescription("{$resourceType}/{$pageN}/{$resourceGroup}/{$resourceId}/{$videoCode}");
         }
         /*
         if ( $videoThumb ) {
         	$item->setThumbnail($videoThumb);
         }
         */
         $items->append($item);
     }
 }