/** * 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; }
/** * 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) { X_Debug::i('plugin triggered'); if ($item->getKey() == 'core-play') { X_Debug::w('core-play flagged as invalid because youtube link is invalid'); return false; } }
/** * Change the url of directplay link to add seeked value * @see X_VlcShares_Plugins_Abstract::filterModeItems() */ public function filterModeItems(X_Page_Item_PItem $item, $provider, Zend_Controller_Action $controller) { if ($item->getKey() == 'core-directwatch' && $item->isUrl()) { $ssValue = $controller->getRequest()->getParam($this->getId(), 0); if ($ssValue > 0) { // need to change the value $link = $item->getLink(); /* @var $hosterHelper X_VlcShares_Plugins_Helper_HosterSSWrapper */ $hosterHelper = $this->helpers()->hoster(); /* @var $hoster X_VlcShares_Plugins_Helper_HostInterface */ $hoster = $hosterHelper->getLastPositiveMatch(); /* @var $ssHelper X_VlcShares_Plugins_Helper_StreamSeeker */ $ssHelper = $this->helpers('streamseeker'); if ($ssHelper->isSeekableHoster($hoster)) { $newLink = $ssHelper->getSeekedUrl($link, $ssValue, $hoster); X_Debug::i("Changing link to {$newLink}"); $item->setLink($newLink); } else { X_Debug::f("A seekable hoster reported as unseekable on last check: " . get_class($hoster)); } } } }