Exemple #1
0
 protected function handleEntry($context, $feed, entry $entry, Entrydistribution $entryDistribution)
 {
     $fields = $this->profile->getAllFieldValues($entryDistribution);
     $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds()));
     $flavorAsset = reset($flavorAssets);
     $flavorAssetRemoteUrl = $entryDistribution->getFromCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_URL);
     $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getThumbAssetIds()));
     $xml = $feed->getItemXml($fields, $flavorAsset, $flavorAssetRemoteUrl, $thumbAssets);
     // we want to find the newest update time between all entries
     if ($entry->getUpdatedAt(null) > $context->lastBuildDate) {
         $context->lastBuildDate = $entry->getUpdatedAt(null);
     }
     return $xml;
 }
Exemple #2
0
 /**
  * @param entry $entry
  * @param SimpleXMLElement $mrss
  * @param kMrssParameters $mrssParams
  * @params string $features
  * @return SimpleXMLElement
  */
 public static function getEntryMrssXml(entry $entry, SimpleXMLElement $mrss = null, kMrssParameters $mrssParams = null, $features = null)
 {
     $instanceKey = self::generateInstanceKey($entry->getId(), $mrssParams, $features);
     if (is_null($mrss)) {
         $mrss = self::getInstanceFromPool($instanceKey);
         if ($mrss) {
             return $mrss;
         }
         $encoding = 'UTF-8';
         if ($mrssParams && !is_null($mrssParams->getEncoding())) {
             $encoding = $mrssParams->getEncoding();
         }
         if ($encoding) {
             $mrss = new SimpleXMLElement('<?xml version="1.0" encoding="' . $encoding . '"?><item/>');
         } else {
             $mrss = new SimpleXMLElement('<item/>');
         }
     }
     $mrss->addChild('entryId', $entry->getId());
     if ($entry->getReferenceID()) {
         $mrss->addChild('referenceID', self::stringToSafeXml($entry->getReferenceID()));
     }
     $mrss->addChild('createdAt', $entry->getCreatedAt(null));
     $mrss->addChild('updatedAt', $entry->getUpdatedAt(null));
     $mrss->addChild('title', self::stringToSafeXml($entry->getName()));
     if ($mrssParams && !is_null($mrssParams->getLink())) {
         $mrss->addChild('link', $mrssParams->getLink() . $entry->getId());
     }
     $mrss->addChild('type', $entry->getType());
     $mrss->addChild('licenseType', $entry->getLicenseType());
     $mrss->addChild('userId', $entry->getPuserId());
     $mrss->addChild('name', self::stringToSafeXml($entry->getName()));
     $mrss->addChild('status', self::stringToSafeXml($entry->getStatus()));
     $mrss->addChild('description', self::stringToSafeXml($entry->getDescription()));
     $thumbnailUrl = $mrss->addChild('thumbnailUrl');
     $thumbnailUrl->addAttribute('url', $entry->getThumbnailUrl());
     if (trim($entry->getTags(), " \r\n\t")) {
         $tags = $mrss->addChild('tags');
         foreach (explode(',', $entry->getTags()) as $tag) {
             $tags->addChild('tag', self::stringToSafeXml($tag));
         }
     }
     $categories = explode(',', $entry->getCategories());
     if (count($features) && in_array(ObjectFeatureType::CATEGORY_ENTRIES, $features)) {
         $partner = PartnerPeer::retrieveByPK(kCurrentContext::getCurrentPartnerId());
         $partnerEntitlement = $partner->getDefaultEntitlementEnforcement();
         kEntitlementUtils::initEntitlementEnforcement($partner->getId(), false);
         $categories = array();
         $categoryEntries = categoryEntryPeer::retrieveActiveByEntryId($entry->getId());
         $categoryIds = array();
         foreach ($categoryEntries as $categoryEntry) {
             $categoryIds[] = $categoryEntry->getCategoryId();
         }
         $entryCats = categoryPeer::retrieveByPKs($categoryIds);
         foreach ($entryCats as $entryCat) {
             $categories[] = $entryCat->getFullName();
         }
         if ($partnerEntitlement) {
             kEntitlementUtils::initEntitlementEnforcement($partner->getId(), true);
         }
         $keyToDelete = array_search(ObjectFeatureType::CATEGORY_ENTRIES, $features);
         unset($features[$keyToDelete]);
     }
     foreach ($categories as $category) {
         $category = trim($category);
         if ($category) {
             $categoryNode = $mrss->addChild('category', self::stringToSafeXml($category));
             if (strrpos($category, '>') > 0) {
                 $categoryNode->addAttribute('name', self::stringToSafeXml(substr($category, strrpos($category, '>') + 1)));
             } else {
                 $categoryNode->addAttribute('name', self::stringToSafeXml($category));
             }
         }
     }
     $mrss->addChild('partnerData', self::stringToSafeXml($entry->getPartnerData()));
     if ($entry->getAccessControlId()) {
         $mrss->addChild('accessControlId', $entry->getAccessControlId());
     }
     if ($entry->getConversionProfileId()) {
         $mrss->addChild('conversionProfileId', $entry->getConversionProfileId());
     }
     if ($entry->getStartDate(null)) {
         $mrss->addChild('startDate', $entry->getStartDate(null));
     }
     if ($entry->getEndDate(null)) {
         $mrss->addChild('endDate', $entry->getEndDate(null));
     }
     switch ($entry->getType()) {
         case entryType::MEDIA_CLIP:
             self::appendMediaEntryMrss($entry, $mrss);
             break;
         case entryType::MIX:
             self::appendMixEntryMrss($entry, $mrss);
             break;
         case entryType::PLAYLIST:
             self::appendPlaylistEntryMrss($entry, $mrss);
             break;
         case entryType::DATA:
             self::appendDataEntryMrss($entry, $mrss);
             break;
         case entryType::LIVE_STREAM:
             self::appendLiveStreamEntryMrss($entry, $mrss);
             break;
         default:
             break;
     }
     $assetsStatuses = array(asset::ASSET_STATUS_READY);
     if ($mrssParams && $mrssParams->getStatuses()) {
         $assetsStatuses = $mrssParams->getStatuses();
     }
     $assets = assetPeer::retrieveReadyByEntryId($entry->getId(), null, $assetsStatuses);
     foreach ($assets as $asset) {
         if ($mrssParams && !is_null($mrssParams->getFilterByFlavorParams()) && $asset->getFlavorParamsId() != $mrssParams->getFilterByFlavorParams()) {
             continue;
         }
         if ($asset instanceof flavorAsset) {
             self::appendFlavorAssetMrss($asset, $mrss, $mrssParams);
         }
         if ($asset instanceof thumbAsset) {
             self::appendThumbAssetMrss($asset, $mrss);
         }
     }
     $mrssContributors = self::getMrssContributors();
     if (count($mrssContributors)) {
         foreach ($mrssContributors as $mrssContributor) {
             try {
                 if (!count($features) || in_array($mrssContributor->getObjectFeatureType(), $features)) {
                     $mrssContributor->contribute($entry, $mrss, $mrssParams);
                 }
             } catch (kCoreException $ex) {
                 KalturaLog::err("Unable to add MRSS element for contributor [" . get_class($mrssContributor) . "] message [" . $ex->getMessage() . "]");
             }
         }
     }
     if ($mrssParams && $mrssParams->getIncludePlayerTag()) {
         $uiconfId = !is_null($mrssParams->getPlayerUiconfId()) ? '/ui_conf_id/' . $mrssParams->getPlayerUiconfId() : '';
         $playerUrl = kConf::get('apphome_url') . '/kwidget/wid/_' . $entry->getPartnerId() . '/entry_id/' . $entry->getId() . '/ui_conf' . ($uiconfId ? "/{$uiconfId}" : '');
         $player = $mrss->addChild('player');
         $player->addAttribute('url', $playerUrl);
     }
     if ($mrssParams && $mrssParams->getItemXpathsToExtend()) {
         self::addExtendingItemsToMrss($mrss, $mrssParams);
     }
     self::addInstanceToPool($instanceKey, $mrss);
     return $mrss;
 }
 /**
  * @param entry $entry
  * @param SimpleXMLElement $mrss
  * @param kMrssParameters $mrssParams
  * @return SimpleXMLElement
  */
 public static function getEntryMrssXml(entry $entry, SimpleXMLElement $mrss = null, kMrssParameters $mrssParams = null)
 {
     if ($mrss === null) {
         $mrss = new SimpleXMLElement('<item/>');
     }
     $mrss->addChild('entryId', $entry->getId());
     if ($entry->getReferenceID()) {
         $mrss->addChild('referenceID', $entry->getReferenceID());
     }
     $mrss->addChild('createdAt', $entry->getCreatedAt(null));
     $mrss->addChild('updatedAt', $entry->getUpdatedAt(null));
     $mrss->addChild('title', self::stringToSafeXml($entry->getName()));
     if ($mrssParams && !is_null($mrssParams->getLink())) {
         $mrss->addChild('link', $mrssParams->getLink() . $entry->getId());
     }
     $mrss->addChild('type', $entry->getType());
     $mrss->addChild('licenseType', $entry->getLicenseType());
     $mrss->addChild('userId', $entry->getPuserId(true));
     $mrss->addChild('name', self::stringToSafeXml($entry->getName()));
     $mrss->addChild('status', self::stringToSafeXml($entry->getStatus()));
     $mrss->addChild('description', self::stringToSafeXml($entry->getDescription()));
     $thumbnailUrl = $mrss->addChild('thumbnailUrl');
     $thumbnailUrl->addAttribute('url', $entry->getThumbnailUrl());
     if (trim($entry->getTags(), " \r\n\t")) {
         $tags = $mrss->addChild('tags');
         foreach (explode(',', $entry->getTags()) as $tag) {
             $tags->addChild('tag', self::stringToSafeXml($tag));
         }
     }
     $categories = explode(',', $entry->getCategories());
     foreach ($categories as $category) {
         $category = trim($category);
         if ($category) {
             $categoryNode = $mrss->addChild('category', self::stringToSafeXml($category));
             if (strrpos($category, '>') > 0) {
                 $categoryNode->addAttribute('name', self::stringToSafeXml(substr($category, strrpos($category, '>') + 1)));
             } else {
                 $categoryNode->addAttribute('name', self::stringToSafeXml($category));
             }
         }
     }
     $mrss->addChild('partnerData', self::stringToSafeXml($entry->getPartnerData()));
     if ($entry->getAccessControlId()) {
         $mrss->addChild('accessControlId', $entry->getAccessControlId());
     }
     if ($entry->getConversionProfileId()) {
         $mrss->addChild('conversionProfileId', $entry->getConversionProfileId());
     }
     if ($entry->getStartDate(null)) {
         $mrss->addChild('startDate', $entry->getStartDate(null));
     }
     if ($entry->getEndDate(null)) {
         $mrss->addChild('endDate', $entry->getEndDate(null));
     }
     switch ($entry->getType()) {
         case entryType::MEDIA_CLIP:
             self::appendMediaEntryMrss($entry, $mrss);
             break;
         case entryType::MIX:
             self::appendMixEntryMrss($entry, $mrss);
             break;
         case entryType::PLAYLIST:
             self::appendPlaylistEntryMrss($entry, $mrss);
             break;
         case entryType::DATA:
             self::appendDataEntryMrss($entry, $mrss);
             break;
         case entryType::LIVE_STREAM:
             self::appendLiveStreamEntryMrss($entry, $mrss);
             break;
         default:
             break;
     }
     $assets = assetPeer::retrieveReadyByEntryId($entry->getId());
     foreach ($assets as $asset) {
         if ($mrssParams && !is_null($mrssParams->getFilterByFlavorParams()) && $asset->getFlavorParamsId() != $mrssParams->getFilterByFlavorParams()) {
             continue;
         }
         if ($asset instanceof flavorAsset) {
             self::appendFlavorAssetMrss($asset, $mrss, $mrssParams);
         }
         if ($asset instanceof thumbAsset) {
             self::appendThumbAssetMrss($asset, $mrss);
         }
     }
     $mrssContributors = self::getMrssContributors();
     if (count($mrssContributors)) {
         foreach ($mrssContributors as $mrssContributor) {
             $mrssContributor->contribute($entry, $mrss, $mrssParams);
         }
     }
     if ($mrssParams && $mrssParams->getIncludePlayerTag()) {
         $uiconfId = !is_null($mrssParams->getPlayerUiconfId()) ? '/ui_conf_id/' . $mrssParams->getPlayerUiconfId() : '';
         $playerUrl = 'http://' . kConf::get('www_host') . '/kwidget/wid/_' . $entry->getPartnerId() . '/entry_id/' . $entry->getId() . '/ui_conf' . ($uiconfId ? "/{$uiconfId}" : '');
         $player = $mrss->addChild('player');
         $player->addAttribute('url', $playerUrl);
     }
     return $mrss;
 }