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