/** * @param string $xpath * @param string $fieldConfigId */ public function setNodeValueFieldConfigId($xpath, $fieldConfigId) { if (isset($this->_fieldValues[$fieldConfigId])) { kXml::setNodeValue($this->_xpath, $xpath, $this->_fieldValues[$fieldConfigId]); } }
public function setItemsPerPage($v) { kXml::setNodeValue($this->xpath, '/rss/channel/openSearch:itemsPerPage', $v); }
public function setBackgroudImage($widedBackgroundImageUrl = null, $standardBackgroundImageUrl = null) { if ($widedBackgroundImageUrl) { kXml::setNodeValue($this->xpath, 'background_image/@wide', $widedBackgroundImageUrl); } if ($standardBackgroundImageUrl) { kXml::setNodeValue($this->xpath, 'background_image/@standard', $standardBackgroundImageUrl); } }
/** * @param array $thumbAssets */ public function setThumbAsset(DOMElement $item, array $thumbAssets) { /** @var $thumbAsset thumbAsset */ $thumbAsset = $thumbAssets[0]; $url = $this->getAssetUrl($thumbAsset); kXml::setNodeValue($this->xpath, 'media:thumbnail/@url', $url, $item); kXml::setNodeValue($this->xpath, 'media:thumbnail/@width', $thumbAsset->getWidth(), $item); kXml::setNodeValue($this->xpath, 'media:thumbnail/@height', $thumbAsset->getHeight(), $item); }
/** * @param array $flavorAssets */ public function setThumbAssets(DOMElement $item, array $thumbAssets) { foreach ($thumbAssets as $thumbAsset) { /* @var $flavorAsset flavorAsset */ $content = $this->thumbnail->cloneNode(true); $mediaGroup = $this->xpath->query('media:group', $item)->item(0); $mediaGroup->appendChild($content); $url = $this->getAssetUrl($thumbAsset); kXml::setNodeValue($this->xpath, '@url', $url, $content); kXml::setNodeValue($this->xpath, '@width', $thumbAsset->getWidth(), $content); kXml::setNodeValue($this->xpath, '@height', $thumbAsset->getHeight(), $content); } }
public function setItemIgnore() { $itemNode = $this->xpath->query('/msdp:rss/msdp:channel/msdp:item')->item(0); kXml::setNodeValue($this->xpath, 'msdp:type', $this->getValueForField(KalturaMetroPcsDistributionField::ITEM_TYPE), $itemNode); kXml::setNodeValue($this->xpath, '@ignore', "Y", $itemNode); }
/** * @param string $xpath * @param string $fieldConfigId */ public function setOrRemoveNodeValueFieldConfigId($xpath, $fieldConfigId) { if (isset($this->_fieldValues[$fieldConfigId]) && $this->_fieldValues[$fieldConfigId]) { kXml::setNodeValue($this->_xpath, $xpath, $this->_fieldValues[$fieldConfigId]); } else { $node = $this->_xpath->query($xpath)->item(0); if ($node) { $node->parentNode->removeChild($node); } } }
public function setThumbAssetUrl($item, $thumbnailUrl, $thumbnailCredit) { kXml::setNodeValue($this->xpath, 'media:thumbnail/@url', $thumbnailUrl, $item); kXml::setNodeValue($this->xpath, 'media:thumbnail/@width', '320', $item); kXml::setNodeValue($this->xpath, 'media:thumbnail/@height', '240', $item); if (!empty($thumbnailCredit)) { kXml::setNodeValue($this->xpath, 'media:thumbnail/@credit', $thumbnailCredit, $item); } }
/** * @param array $values */ public function getItem(array $values, flavorAsset $flavorAsset = null, thumbAsset $thumbAsset = null, array $additionalAssets = null) { $item = $this->item->cloneNode(true); $pubDate = date('c', $values[TVComDistributionField::ITEM_PUB_DATE]); $expDate = date('c', $values[TVComDistributionField::ITEM_EXP_DATE]); $node = kXml::setNodeValue($this->xpath, 'guid', $values[TVComDistributionField::GUID_ID], $item); $node = kXml::setNodeValue($this->xpath, 'pubDate', $pubDate, $item); $node = kXml::setNodeValue($this->xpath, 'expDate', $expDate, $item); $node = kXml::setNodeValue($this->xpath, 'link', $values[TVComDistributionField::ITEM_LINK], $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:title', $values[TVComDistributionField::MEDIA_TITLE], $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:description', $values[TVComDistributionField::MEDIA_DESCRIPTION], $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:keywords', $values[TVComDistributionField::MEDIA_KEYWORDS], $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:copyright', $values[TVComDistributionField::MEDIA_COPYRIGHT], $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:rating', $values[TVComDistributionField::MEDIA_RATING], $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:restriction/@relationship', $values[TVComDistributionField::MEDIA_RESTRICTION_TYPE], $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:restriction', $values[TVComDistributionField::MEDIA_RESTRICTION_COUNTRIES], $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:category[@scheme=\'urn:tvcom:show-tmsid\']', $values[TVComDistributionField::MEDIA_CATEGORY_SHOW_TMSID], $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:category[@scheme=\'urn:tvcom:show-tmsid\']/@label', $values[TVComDistributionField::MEDIA_CATEGORY_SHOW_TMSID_LABEL], $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:category[@scheme=\'urn:tvcom:episode-tmsid\']', $values[TVComDistributionField::MEDIA_CATEGORY_EPISODE_TMSID], $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:category[@scheme=\'urn:tvcom:episode-tmsid\']/@label', $values[TVComDistributionField::MEDIA_CATEGORY_EPISODE_TMSID_LABEL], $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:category[@scheme=\'urn:tvcom:episodetype\']', $values[TVComDistributionField::MEDIA_CATEGORY_EPISODE_TYPE], $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:category[@scheme=\'urn:tvcom:original_air_date\']', $values[TVComDistributionField::MEDIA_CATEGORY_ORIGINAL_AIR_DATE], $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:category[@scheme=\'urn:tvcom:video_format\']', $values[TVComDistributionField::MEDIA_CATEGORY_VIDEO_FORMAT], $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:category[@scheme=\'urn:tvcom:season_number\']', $values[TVComDistributionField::MEDIA_CATEGORY_SEASON_NUMBER], $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:category[@scheme=\'urn:tvcom:episode_number\']', $values[TVComDistributionField::MEDIA_CATEGORY_EPISODE_NUMBER], $item); $dcTerms = "start={$pubDate}; end={$expDate}; scheme=W3C-DTF"; $node = kXml::setNodeValue($this->xpath, 'dcterms:valid', $dcTerms, $item); if ($flavorAsset) { $node = kXml::setNodeValue($this->xpath, 'media:group/media:content/@url', $this->getAssetUrl($flavorAsset), $item); $type = ''; switch ($flavorAsset->getFileExt()) { case 'mp4': $type = 'video/mp4'; break; case 'flv': $type = 'video/x-flv'; break; } $node = kXml::setNodeValue($this->xpath, 'media:group/media:content/@type', $type, $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:content/@fileSize', $flavorAsset->getSize(), $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:content/@expression', $values[TVComDistributionField::MEDIA_CATEGORY_EPISODE_TYPE], $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:content/@duration', floor($flavorAsset->getentry()->getDuration()), $item); } if ($thumbAsset) { $node = kXml::setNodeValue($this->xpath, 'media:group/media:thumbnail/@url', $this->getAssetUrl($thumbAsset), $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:thumbnail/@width', $thumbAsset->getWidth(), $item); $node = kXml::setNodeValue($this->xpath, 'media:group/media:thumbnail/@height', $thumbAsset->getHeight(), $item); } if (is_array($additionalAssets)) { foreach ($additionalAssets as $additionalAsset) { /* @var $additionalAsset asset */ $assetType = $additionalAsset->getType(); switch ($assetType) { case CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION): /* @var $captionPlugin CaptionPlugin */ $captionPlugin = KalturaPluginManager::getPluginInstance(CaptionPlugin::PLUGIN_NAME); $dummyElement = new SimpleXMLElement('<dummy/>'); $captionPlugin->contributeCaptionAssets($additionalAsset, $dummyElement); $dummyDom = dom_import_simplexml($dummyElement); $captionDom = $dummyDom->getElementsByTagName('subTitle'); $captionDom = $this->doc->importNode($captionDom->item(0), true); $captionDom = $item->appendChild($captionDom); break; case AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT): /* @var $attachmentPlugin AttachmentPlugin */ $attachmentPlugin = KalturaPluginManager::getPluginInstance(AttachmentPlugin::PLUGIN_NAME); $dummyElement = new SimpleXMLElement('<dummy/>'); $attachmentPlugin->contributeAttachmentAssets($additionalAsset, $dummyElement); $dummyDom = dom_import_simplexml($dummyElement); $attachmentDom = $dummyDom->getElementsByTagName('attachment'); $attachmentDom = $this->doc->importNode($attachmentDom->item(0), true); $attachmentDom = $item->appendChild($attachmentDom); break; } } } return $item; }
/** * @param array $values */ public function getItem(array $values, flavorAsset $flavorAsset = null, thumbAsset $thumbAsset = null) { $item = $this->item->cloneNode(true); kXml::setNodeValue($this->xpath, 'guid', $values[AvnDistributionField::GUID], $item); kXml::setNodeValue($this->xpath, 'pubDate', $values[AvnDistributionField::PUB_DATE], $item); kXml::setNodeValue($this->xpath, 'title', $values[AvnDistributionField::TITLE], $item); kXml::setNodeValue($this->xpath, 'description', $values[AvnDistributionField::DESCRIPTION], $item); kXml::setNodeValue($this->xpath, 'link', $values[AvnDistributionField::LINK], $item); kXml::setNodeValue($this->xpath, 'category', $values[AvnDistributionField::CATEGORY], $item); kXml::setNodeValue($this->xpath, 'amg:passthru', $this->getPassthruJsonObj($values), $item); if ($flavorAsset) { $url = $this->getAssetUrl($flavorAsset); $type = $this->getContentTypeFromUrl($url); kXml::setNodeValue($this->xpath, 'media:content/@url', $url, $item); kXml::setNodeValue($this->xpath, 'media:content/@type', $type, $item); if ($values[AvnDistributionField::ORDER_SUB] == '1') { kXml::setNodeValue($this->xpath, 'media:content/@isDefault', 'true', $item); } else { kXml::setNodeValue($this->xpath, 'media:content/@isDefault', 'false', $item); } } if ($thumbAsset) { kXml::setNodeValue($this->xpath, 'media:thumbnail/@url', $this->getAssetUrl($thumbAsset), $item); } return $item; }
protected function setReplaceAirDates() { if ($this->_distributionProfile->replaceAirDates === false) { kXml::setNodeValue($this->_xpath, '/FWCoreContainer/FWVideoDocument/fwReplaceAirDates', 'false'); } else { kXml::setNodeValue($this->_xpath, '/FWCoreContainer/FWVideoDocument/fwReplaceAirDates', 'true'); } }
/** * @param array $values * @param array $flavorAssets * @param array $thumbAssets */ public function getItem(array $values, entry $entry, array $flavorAssets = null, array $thumbAssets = null, array $additionalAssets = null) { $item = $this->item->cloneNode(true); kXml::setNodeValue($this->xpath, 'atom:title', $values[SynacorHboDistributionField::ENTRY_TITLE], $item); kXml::setNodeValue($this->xpath, 'atom:summary', $values[SynacorHboDistributionField::ENTRY_SUMMARY], $item); $updatedTime = $this->formatSynacorHboTime($values[SynacorHboDistributionField::ENTRY_UPDATED]); kXml::setNodeValue($this->xpath, 'atom:updated', $updatedTime, $item); kXml::setNodeValue($this->xpath, 'atom:author/atom:name', $values[SynacorHboDistributionField::ENTRY_AUTHOR_NAME], $item); $categoryValue = $values[SynacorHboDistributionField::ENTRY_CATEGORY_TERM]; if (strlen($categoryValue) > 0) { kXml::setNodeValue($this->xpath, 'atom:category/@term', $categoryValue, $item); } else { $this->removeNode('atom:category', $item); } $genreValue = $values[SynacorHboDistributionField::ENTRY_GENRE_TERM]; if (strlen($genreValue) > 0) { kXml::setNodeValue($this->xpath, 'atom:genre/@term', $genreValue, $item); } else { $this->removeNode('atom:genre', $item); } kXml::setNodeValue($this->xpath, 'atom:assetType', $values[SynacorHboDistributionField::ENTRY_ASSET_TYPE], $item); kXml::setNodeValue($this->xpath, 'atom:assetId', $values[SynacorHboDistributionField::ENTRY_ASSET_ID], $item); $startTime = $this->formatSynacorHboTime($values[SynacorHboDistributionField::ENTRY_OFFERING_START]); kXml::setNodeValue($this->xpath, 'atom:offering/atom:start', $startTime, $item); $endTime = $this->formatSynacorHboTime($values[SynacorHboDistributionField::ENTRY_OFFERING_END]); kXml::setNodeValue($this->xpath, 'atom:offering/atom:end', $endTime, $item); $ratingValue = $values[SynacorHboDistributionField::ENTRY_RATING]; if (strlen($ratingValue) > 0) { kXml::setNodeValue($this->xpath, 'atom:rating', $ratingValue, $item); $ratingType = stripos($ratingValue, 'tv') === '0' ? 'tv' : 'theatrical'; kXml::setNodeValue($this->xpath, 'atom:rating/@type', $ratingType, $item); } else { $this->removeNode('atom:rating', $item); } $durationInSeconds = ceil($entry->getDuration()); $durationInMinuesRoundedUp = ceil($durationInSeconds / 60); kXml::setNodeValue($this->xpath, 'atom:runtime', $durationInMinuesRoundedUp, $item); kXml::setNodeValue($this->xpath, 'atom:runtime/@timeInSeconds', $durationInSeconds, $item); kXml::setNodeValue($this->xpath, 'go:series/go:title', $values[SynacorHboDistributionField::ENTRY_SERIES_TITLE], $item); kXml::setNodeValue($this->xpath, 'atom:brand', $values[SynacorHboDistributionField::ENTRY_BRAND], $item); if (!is_null($flavorAssets) && is_array($flavorAssets) && count($flavorAssets) > 0) { $flavorAsset = $flavorAssets[0]; /* @var $flavorAsset flavorAsset */ $flavorUrl = $this->getAssetUrl($flavorAsset); // we don't have a way to identify the mime type of the file // as there is no guarantee that the file exists in the current data center // so we will just use those hardcoded conditions $mimeType = ''; switch ($flavorAsset->getFileExt()) { case 'flv': $mimeType = 'video/x-flv'; break; case 'mp4': $mimeType = 'video/mp4'; break; case 'mpeg': case 'mpg': $mimeType = 'video/mpeg'; break; default: $mimeType = 'video/x-flv'; // default requested by synacor } kXml::setNodeValue($this->xpath, 'atom:link[@type=\'VIDEO_MIME_TYPE\']/@href', $flavorUrl, $item); kXml::setNodeValue($this->xpath, 'atom:link[@type=\'VIDEO_MIME_TYPE\']/@type', $mimeType, $item); } if (!is_null($thumbAssets) && is_array($thumbAssets) && count($thumbAssets) > 0) { $thumbAsset = $thumbAssets[0]; /* @var $thumbAssets thumbAssets */ $thumbUrl = $this->getAssetUrl($thumbAsset); kXml::setNodeValue($this->xpath, 'atom:link[@type=\'image/jpeg\']/@href', $thumbUrl, $item); } if (is_array($additionalAssets)) { foreach ($additionalAssets as $additionalAsset) { /* @var $additionalAsset asset */ $assetType = $additionalAsset->getType(); switch ($assetType) { case CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION): /* @var $captionPlugin CaptionPlugin */ $captionPlugin = KalturaPluginManager::getPluginInstance(CaptionPlugin::PLUGIN_NAME); $dummyElement = new SimpleXMLElement('<dummy/>'); $captionPlugin->contributeCaptionAssets($additionalAsset, $dummyElement); $dummyDom = dom_import_simplexml($dummyElement); $captionDom = $dummyDom->getElementsByTagName('subTitle'); $captionDom = $this->doc->importNode($captionDom->item(0), true); $captionDom = $item->appendChild($captionDom); break; case AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT): /* @var $attachmentPlugin AttachmentPlugin */ $attachmentPlugin = KalturaPluginManager::getPluginInstance(AttachmentPlugin::PLUGIN_NAME); $dummyElement = new SimpleXMLElement('<dummy/>'); $attachmentPlugin->contributeAttachmentAssets($additionalAsset, $dummyElement); $dummyDom = dom_import_simplexml($dummyElement); $attachmentDom = $dummyDom->getElementsByTagName('attachment'); $attachmentDom = $this->doc->importNode($attachmentDom->item(0), true); $attachmentDom = $item->appendChild($attachmentDom); break; } } } return $item; }
/** * @param DOMElement $item * @param array $thumbAssets * @param array $remoteThumbailFileUrls */ public function setThumbAsset($item, array $thumbAssets, $remoteThumbailFileUrls) { $node = $this->xpath->query('thumbnail', $item)->item(0); if (count($thumbAssets)) { foreach ($thumbAssets as $thumbAsset) { /* @var $thumbAsset thumbAsset */ $thumbAssetId = $thumbAsset->getId(); $url = ''; if (!is_null($remoteThumbailFileUrls)) { $url = $remoteThumbailFileUrls[$thumbAssetId]; } $thumbnailNode = $this->thumbnail->cloneNode(true); $item->insertBefore($thumbnailNode, $node); kXml::setNodeValue($this->xpath, '@url', $url, $thumbnailNode); kXml::setNodeValue($this->xpath, '@height', $thumbAsset->getHeight(), $thumbnailNode); kXml::setNodeValue($this->xpath, '@width', $thumbAsset->getWidth(), $thumbnailNode); } } $node->parentNode->removeChild($node); }
public function setMovieTmsId($value) { kXml::setNodeValue($this->xpath, '/rss/channel/item/yt:movie_metadata/yt:tms_id', $value); }
public function setThumbnailsPath($smallThumbPath, $largeThumbPath) { kXml::setNodeValue($this->xpath, "/CMSFEED/FEEDITEM/IMAGE[@USE='SMALLTHUMB']", $smallThumbPath); kXml::setNodeValue($this->xpath, "/CMSFEED/FEEDITEM/IMAGE[@USE='LARGETHUMB']", $largeThumbPath); }
/** * @param string $xpath * @param string $value * @param DOMNode $contextnode */ public function setNodeValueDate($xpath, $value, DOMNode $contextnode = null) { $dateTime = new DateTime('@' . $value); // force time zone to GMT $dateTime->setTimezone(new DateTimeZone('GMT')); $date = $dateTime->format('c'); $date = str_replace('+00:00', 'Z', $date); kXml::setNodeValue($this->_xpath, $xpath, $date, $contextnode); }
public function setChecksum($value) { //TODO: veirfy that make sense kXml::setNodeValue($this->xpath, '/ProgramDescription/ProgramLocationTable/ProgramLocation/OnDemandProgram/Checksum', $value); }
/** * @param string $xpath * @param string $value */ public function setNodeValue($xpath, $value, DOMNode $contextnode = null) { kXml::setNodeValue($this->doc, $this->xpath, $xpath, $value, $contextnode); }
/** * @param asset $asset * @param string $class * @param string $encodingProfile * @param string $duration * @param string $url */ protected function createEnclosureXml(asset $asset, $class, $encodingProfile, $duration) { /** * * In QuickPlay's XML example, the namespace "http://www.quickplaymedia.com" is added to the "enclosure" * element regardless to the fact that it was registerted with the prefix "qpm" on the root element. * We cannot set a namespace that was already defined with a prefix because DOMDocument will add the element * as "qpm:enclosure" and won't set the namespace explicitly. * * The hack is to create a new KDOMDocument with default namespace "http://www.quickplaymedia.com" and then * add it to the xml manually (see getXml() method) * */ $syncKey = $asset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $fileSync = kFileSyncUtils::getLocalFileSyncForKey($syncKey); $contentNode = $this->_enclosureNode->cloneNode(true); kXml::setNodeValue($this->_xpath, '@encodingProfile', $encodingProfile, $contentNode); $url = $this->getAssetUrl($asset); $mimeType = $this->getContentTypeFromUrl($url); $enclosureDoc = new KDOMDocument(); $enclosureElement = $enclosureDoc->createElementNS('http://www.quickplaymedia.com', 'enclosure'); $xmlElement = $enclosureDoc->createElement('xml'); $enclosureDoc->appendChild($xmlElement); $enclosureNode = $enclosureDoc->importNode($contentNode, true); $enclosureNode->setAttribute('class', $class); $link = $enclosureNode->getElementsByTagName('link')->item(0); $link->setAttribute('type', $mimeType); $link->setAttribute('length', $fileSync->getFileSize()); $link->setAttribute('duration', $duration); $link->setAttribute('url', pathinfo($fileSync->getFilePath(), PATHINFO_BASENAME)); $xmlElement->appendChild($enclosureNode); return $enclosureDoc->saveXML($enclosureNode); }
public function setCuePoints(DOMElement $item, array $cuePoints) { foreach ($cuePoints as $cuePoint) { /* @var $cuePoint cuePoint */ $content = $this->cuePoint->cloneNode(true); $mediaGroup = $this->xpath->query('.', $item)->item(0); $mediaGroup->appendChild($content); kXml::setNodeValue($this->xpath, '@type', self::MILLISECONDS, $content); kXml::setNodeValue($this->xpath, '@startTime', $cuePoint->getStartTime(), $content); } }
public function addThumbAsset(DOMElement $item, asset $thumbAsset, $thumbnailCredit) { $thumbnailNode = $this->thumbnail->cloneNode(true); $item->appendChild($thumbnailNode); $url = $this->getAssetUrl($thumbAsset); kXml::setNodeValue($this->xpath, '@url', $url, $thumbnailNode); kXml::setNodeValue($this->xpath, '@width', $thumbAsset->getWidth(), $thumbnailNode); kXml::setNodeValue($this->xpath, '@height', $thumbAsset->getHeight(), $thumbnailNode); if ($thumbnailCredit) { kXml::setNodeValue($this->xpath, '@credit', $thumbnailCredit, $thumbnailNode); } }