Пример #1
0
 public function getThumbnailUrl($version = null, $protocol = null)
 {
     if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_DISABLE_KMC_DRILL_DOWN_THUMB_RESIZE, $this->getPartnerId())) {
         $subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA;
         if ($this->getType() == entryType::MEDIA_CLIP && $this->getMediaType() != entry::ENTRY_MEDIA_TYPE_IMAGE) {
             $subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB;
         }
         $syncKey = $this->getSyncKey($subType);
         $fileSync = null;
         $serveRemote = false;
         $partner = PartnerPeer::retrieveByPK($this->getPartnerId());
         switch ($partner->getStorageServePriority()) {
             case StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_ONLY:
                 $serveRemote = true;
                 $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
                 if (!$fileSync) {
                     return null;
                 }
                 break;
             case StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_FIRST:
                 $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
                 if ($fileSync) {
                     $serveRemote = true;
                 }
                 break;
             case StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST:
                 $fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
                 if ($fileSync) {
                     break;
                 }
                 $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
                 if (!$fileSync) {
                     return null;
                 }
                 $serveRemote = true;
                 break;
             case StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY:
                 $fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
                 if (!$fileSync) {
                     return null;
                 }
                 break;
         }
         if ($serveRemote && $fileSync) {
             $url = $fileSync->getExternalUrl($this->getId());
             if (!is_null($protocol)) {
                 $url = preg_replace('/^https?/', $protocol, $url);
             }
             return $url;
         }
     }
     //$path = $this->getThumbnailPath ( $version );
     $path = myPartnerUtils::getUrlForPartner($this->getPartnerId(), $this->getSubpId()) . "/thumbnail/entry_id/" . $this->getId();
     $partner = $this->getPartner();
     if ($partner && $this->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO && $partner->getAudioThumbEntryId() && $partner->getAudioThumbEntryVersion()) {
         $thumbEntryId = $partner->getAudioThumbEntryId();
         $thumbVersion = $partner->getAudioThumbEntryVersion();
         $current_version = "{$thumbVersion}/thumb_entry_id/{$thumbEntryId}";
     } elseif ($partner && in_array($this->getType(), array(entryType::LIVE_STREAM, entryType::LIVE_CHANNEL)) && $partner->getLiveThumbEntryId() && $partner->getLiveThumbEntryVersion()) {
         $thumbEntryId = $partner->getLiveThumbEntryId();
         $thumbVersion = $partner->getLiveThumbEntryVersion();
         $current_version = "{$thumbVersion}/thumb_entry_id/{$thumbEntryId}";
     } else {
         $current_version = $this->getThumbnailVersion();
     }
     if ($version) {
         $path .= "/version/{$version}";
     } else {
         $path .= "/version/{$current_version}";
     }
     $assetCacheVersion = $this->getAssetCacheVersion();
     if ($assetCacheVersion != self::DEFAULT_ASSETCACHEVERSION) {
         // If the version is not the default, include it as part of the URL in order
         // to bypass existing image cache and produce a fresh thumbnail (which will
         // persist until assetCacheVersion is modified again)
         $path .= "/acv/{$assetCacheVersion}";
     }
     $url = myPartnerUtils::getThumbnailHost($this->getPartnerId(), $protocol) . $path;
     return $url;
 }
 public function getThumbnailUrl($version = null, $protocol = null)
 {
     if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_DISABLE_KMC_DRILL_DOWN_THUMB_RESIZE, $this->getPartnerId())) {
         $subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA;
         if ($this->getType() == entryType::MEDIA_CLIP && $this->getMediaType() != entry::ENTRY_MEDIA_TYPE_IMAGE) {
             $subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB;
         }
         $syncKey = $this->getSyncKey($subType);
         $fileSync = null;
         $serveRemote = false;
         $partner = PartnerPeer::retrieveByPK($this->getPartnerId());
         switch ($partner->getStorageServePriority()) {
             case StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_ONLY:
                 $serveRemote = true;
                 $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
                 if (!$fileSync) {
                     return null;
                 }
                 break;
             case StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_FIRST:
                 $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
                 if ($fileSync) {
                     $serveRemote = true;
                 }
                 break;
             case StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST:
                 $fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
                 if ($fileSync) {
                     break;
                 }
                 $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
                 if (!$fileSync) {
                     return null;
                 }
                 $serveRemote = true;
                 break;
             case StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY:
                 $fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
                 if (!$fileSync) {
                     return null;
                 }
                 break;
         }
         if ($serveRemote && $fileSync) {
             $url = $fileSync->getExternalUrl($this->getId());
             if (!is_null($protocol)) {
                 $url = preg_replace('/^https?/', $protocol, $url);
             }
             return $url;
         }
     }
     //$path = $this->getThumbnailPath ( $version );
     $path = myPartnerUtils::getUrlForPartner($this->getPartnerId(), $this->getSubpId()) . "/thumbnail/entry_id/" . $this->getId();
     $current_version = $this->getThumbnailVersion();
     if ($version) {
         $path .= "/version/{$version}";
     } else {
         $path .= "/version/{$current_version}";
     }
     $url = myPartnerUtils::getThumbnailHost($this->getPartnerId(), $protocol) . $path;
     return $url;
 }