public static function createFilePath($base_path, $file_name) { $id = self::getEntryIdFromFileName($file_name); // create a new path with the file name $entry = entryPeer::retrieveByPK($id); if ($entry) { KalturaLog::debug("Found entry for file_name [{$file_name}] -> entry_id [{$id}]"); $int_id = $entry->getIntId(); $path_name = myContentStorage::dirForId($int_id, $id) . "." . pathinfo($file_name, PATHINFO_EXTENSION); } else { KalturaLog::debug("Did NOT find entry for file_name [{$file_name}] -> entry_id [{$id}]"); $path_name = "AZ/" . pathinfo($file_name, PATHINFO_BASENAME); } // make sure the separator exists between the 2 paths // if ( ! kString::endsWith( $base_path , "/" ) ) $base_path .= "/"; kFile::fullMkdir($base_path . "/" . $path_name); return $base_path . "/" . $path_name; }
/** * @action getFeedByEntryId * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY * @param int $distributionProfileId * @param string $hash * @param string $entryId * @return file */ public function getFeedByEntryIdAction($distributionProfileId, $hash, $entryId) { if (!$this->getPartnerId() || !$this->getPartner()) { throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $this->getPartnerId()); } $profile = DistributionProfilePeer::retrieveByPK($distributionProfileId); if (!$profile || !$profile instanceof DoubleClickDistributionProfile) { throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_NOT_FOUND, $distributionProfileId); } if ($profile->getStatus() != KalturaDistributionProfileStatus::ENABLED) { throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_DISABLED, $distributionProfileId); } if ($profile->getUniqueHashForFeedUrl() != $hash) { throw new KalturaAPIException(DoubleClickDistributionErrors::INVALID_FEED_URL); } // Creates entry filter with advanced filter $entry = entryPeer::retrieveByPK($entryId); if (!$entry || $entry->getPartnerId() != $this->getPartnerId()) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId); } // Construct the feed $feed = new DoubleClickFeed('doubleclick_template.xml', $profile); $feed->setTotalResult(1); $feed->setStartIndex(1); $profileUpdatedAt = $profile->getUpdatedAt(null); $cacheDir = kConf::get("global_cache_dir") . "feeds/dist_{$distributionProfileId}/"; // check cache $cacheFileName = $cacheDir . myContentStorage::dirForId($entry->getIntId(), $entry->getId() . ".xml"); $updatedAt = max($profileUpdatedAt, $entry->getUpdatedAt(null)); if (file_exists($cacheFileName) && $updatedAt < filemtime($cacheFileName)) { $xml = file_get_contents($cacheFileName); } else { $entryDistribution = EntryDistributionPeer::retrieveByEntryAndProfileId($entry->getId(), $profile->getId()); if (!$entryDistribution) { throw new KalturaAPIException(ContentDistributionErrors::ENTRY_DISTRIBUTION_NOT_FOUND, ''); } $fields = $profile->getAllFieldValues($entryDistribution); $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds())); $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getThumbAssetIds())); $cuePoints = $this->getCuePoints($entry->getPartnerId(), $entry->getId()); $xml = $feed->getItemXml($fields, $flavorAssets, $thumbAssets, $cuePoints); mkdir(dirname($cacheFileName), 0777, true); file_put_contents($cacheFileName, $xml); } $feed->addItemXml($xml); header('Content-Type: text/xml'); echo $feed->getXml(); die; }