本文整理汇总了PHP中myContentStorage::getGeneralEntityPath方法的典型用法代码示例。如果您正苦于以下问题:PHP myContentStorage::getGeneralEntityPath方法的具体用法?PHP myContentStorage::getGeneralEntityPath怎么用?PHP myContentStorage::getGeneralEntityPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类myContentStorage
的用法示例。
在下文中一共展示了myContentStorage::getGeneralEntityPath方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateFilePathArr
public function generateFilePathArr($sub_type, $version = null)
{
static::validateFileSyncSubType($sub_type);
if ($sub_type == self::FILE_SYNC_ENTRY_SUB_TYPE_LIVE_PRIMARY || $sub_type == self::FILE_SYNC_ENTRY_SUB_TYPE_LIVE_SECONDARY) {
$res = myContentStorage::getGeneralEntityPath('entry/data', $this->getIntId(), $this->getId(), $sub_type);
return array(myContentStorage::getFSContentRootPath(), $res);
}
return parent::generateFilePathArr($sub_type, $version);
}
示例2: getWidgetImagePath
public function getWidgetImagePath()
{
return myContentStorage::getGeneralEntityPath("entry/widget", $this->getIntId(), $this->getId(), ".gif");
}
示例3: getPicturePath
public function getPicturePath()
{
$picfile = $this->getPicture();
$picfile = substr($picfile, strpos($picfile, '^'));
return myContentStorage::getGeneralEntityPath("kuser/pic", $this->getId(), $this->getId(), $picfile);
}
示例4: getSkinResourcePathByProperty
public function getSkinResourcePathByProperty($prop_name, skinContainer $skin_container)
{
if ($this->getId() == "") {
return "";
}
// TODO - these are hacks around the name of the field/clas/property - FIX !!!
// the prop_name is the field name not the class_name !!!
$prop_name = skinContainer::fixClassName($prop_name);
$param_value = $skin_container->getParamFromObject($prop_name);
if (kString::isEmpty($param_value)) {
// TODO - i don't think the hack should be here -
// i think that the myContentStorage will generate this value if the originqal value is empty
// - Eran ?
$param_value = myContentStorage::MIN_OBFUSCATOR_VALUE;
}
return myContentStorage::getGeneralEntityPath("kshow/skin/" . $prop_name, $this->getIntId(), $this->getId(), $param_value);
}
示例5: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
requestUtils::handleConditionalGet();
ignore_user_abort();
$entry_id = $this->getRequestParameter("entry_id");
$widget_id = $this->getRequestParameter("widget_id", 0);
$upload_token_id = $this->getRequestParameter("upload_token_id");
$version = $this->getIntRequestParameter("version", null, 0, 10000000);
$type = $this->getIntRequestParameter("type", 1, 1, 5);
//Hack: if KMS sends thumbnail request containing "!" char, the type should be treated as 5.
$width = $this->getRequestParameter("width", -1);
$height = $this->getRequestParameter("height", -1);
if (strpos($width, "!") || strpos($height, "!")) {
$type = 5;
}
$width = $this->getFloatRequestParameter("width", -1, -1, 10000);
$height = $this->getFloatRequestParameter("height", -1, -1, 10000);
$crop_provider = $this->getRequestParameter("crop_provider", null);
$quality = $this->getIntRequestParameter("quality", 0, 0, 100);
$src_x = $this->getFloatRequestParameter("src_x", 0, 0, 10000);
$src_y = $this->getFloatRequestParameter("src_y", 0, 0, 10000);
$src_w = $this->getFloatRequestParameter("src_w", 0, 0, 10000);
$src_h = $this->getFloatRequestParameter("src_h", 0, 0, 10000);
$vid_sec = $this->getFloatRequestParameter("vid_sec", -1, -1);
$vid_slice = $this->getRequestParameter("vid_slice", -1);
$vid_slices = $this->getRequestParameter("vid_slices", -1);
$density = $this->getFloatRequestParameter("density", 0, 0);
$stripProfiles = $this->getRequestParameter("strip", null);
$flavor_id = $this->getRequestParameter("flavor_id", null);
$file_name = $this->getRequestParameter("file_name", null);
$file_name = basename($file_name);
// actual width and height of image from which the src_* values were taken.
// these will be used to multiply the src_* parameters to make them relate to the original image size.
$rel_width = $this->getFloatRequestParameter("rel_width", -1, -1, 10000);
$rel_height = $this->getFloatRequestParameter("rel_height", -1, -1, 10000);
if ($width == -1 && $height == -1) {
$width = 120;
$height = 90;
} else {
if ($width == -1) {
// if only either width or height is missing reset them to zero, and convertImage will handle them
$width = 0;
} else {
if ($height == -1) {
$height = 0;
}
}
}
$bgcolor = $this->getRequestParameter("bgcolor", "ffffff");
$partner = null;
// validating the inputs
if (!is_numeric($quality) || $quality < 0 || $quality > 100) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'quality must be between 20 and 100');
}
if (!is_numeric($src_x) || $src_x < 0 || $src_x > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_x must be between 0 and 10000');
}
if (!is_numeric($src_y) || $src_y < 0 || $src_y > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_y must be between 0 and 10000');
}
if (!is_numeric($src_w) || $src_w < 0 || $src_w > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_w must be between 0 and 10000');
}
if (!is_numeric($src_h) || $src_h < 0 || $src_h > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_h must be between 0 and 10000');
}
if (!is_numeric($width) || $width < 0 || $width > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'width must be between 0 and 10000');
}
if (!is_numeric($height) || $height < 0 || $height > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'height must be between 0 and 10000');
}
if (!is_numeric($density) || $density < 0) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'density must be positive');
}
if (!is_numeric($vid_sec) || $vid_sec < -1) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'vid_sec must be positive');
}
if (!preg_match('/^[0-9a-fA-F]{1,6}$/', $bgcolor)) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'bgcolor must be six hexadecimal characters');
}
if ($upload_token_id) {
$upload_token = UploadTokenPeer::retrieveByPK($upload_token_id);
if ($upload_token) {
$partnerId = $upload_token->getPartnerId();
$partner = PartnerPeer::retrieveByPK($partnerId);
if ($density == 0) {
$density = $partner->getDefThumbDensity();
}
if (is_null($stripProfiles)) {
$stripProfiles = $partner->getStripThumbProfile();
}
$thumb_full_path = myContentStorage::getFSCacheRootPath() . myContentStorage::getGeneralEntityPath("uploadtokenthumb", $upload_token->getIntId(), $upload_token->getId(), $upload_token->getId() . ".jpg");
kFile::fullMkdir($thumb_full_path);
if (file_exists($upload_token->getUploadTempPath())) {
$src_full_path = $upload_token->getUploadTempPath();
//.........这里部分代码省略.........
示例6: execute
//.........这里部分代码省略.........
$isFlv = $flvWrapper->isFlv();
}
$clipFrom = $this->getRequestParameter("clipFrom", 0);
// milliseconds
if (is_null($clipTo)) {
$clipTo = $this->getRequestParameter("clipTo", self::NO_CLIP_TO);
}
// milliseconds
if ($clipTo == 0) {
$clipTo = self::NO_CLIP_TO;
}
if (!is_numeric($clipTo) || $clipTo < 0) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'clipTo must be a positive number');
}
$seekFrom = $this->getRequestParameter("seekFrom", -1);
if ($seekFrom <= 0) {
$seekFrom = -1;
}
$seekFromBytes = $this->getRequestParameter("seekFromBytes", -1);
if ($seekFromBytes <= 0) {
$seekFromBytes = -1;
}
if ($fileParam && is_dir($path)) {
$path .= "/{$fileParam}";
kFileUtils::dumpFile($path, null, null);
KExternalErrors::dieGracefully();
} else {
if (!$isFlv || $clipTo == self::NO_CLIP_TO && $seekFrom < 0 && $seekFromBytes < 0) {
$limit_file_size = 0;
if ($clipTo != self::NO_CLIP_TO) {
if (strtolower($flavorAsset->getFileExt()) == 'mp4' && PermissionPeer::isValidForPartner(PermissionName::FEATURE_ACCURATE_SERVE_CLIPPING, $flavorAsset->getPartnerId())) {
$contentPath = myContentStorage::getFSContentRootPath();
$tempClipName = $version . '_' . $clipTo . '.mp4';
$tempClipPath = $contentPath . myContentStorage::getGeneralEntityPath("entry/tempclip", $flavorAsset->getIntId(), $flavorAsset->getId(), $tempClipName);
if (!file_exists($tempClipPath)) {
kFile::fullMkdir($tempClipPath);
$clipToSec = round($clipTo / 1000, 3);
$cmdLine = kConf::get("bin_path_ffmpeg") . " -i {$path} -vcodec copy -acodec copy -f mp4 -t {$clipToSec} -y {$tempClipPath} 2>&1";
KalturaLog::log("Executing {$cmdLine}");
$output = array();
$return_value = "";
exec($cmdLine, $output, $return_value);
KalturaLog::log("ffmpeg returned {$return_value}, output:" . implode("\n", $output));
}
if (file_exists($tempClipPath)) {
KalturaLog::log("Dumping {$tempClipPath}");
kFileUtils::dumpFile($tempClipPath);
} else {
KalturaLog::err('Failed to clip the file using ffmpeg, falling back to rough clipping');
}
}
$mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($flavorAsset->getId());
if ($mediaInfo && ($mediaInfo->getVideoDuration() || $mediaInfo->getAudioDuration() || $mediaInfo->getContainerDuration())) {
$duration = $mediaInfo->getVideoDuration() ? $mediaInfo->getVideoDuration() : ($mediaInfo->getAudioDuration() ? $mediaInfo->getAudioDuration() : $mediaInfo->getContainerDuration());
$limit_file_size = floor(@kFile::fileSize($path) * ($clipTo / $duration) * 1.2);
}
}
$renderer = kFileUtils::getDumpFileRenderer($path, null, null, $limit_file_size);
if (!$fileName) {
$this->storeCache($renderer, $flavorAsset->getPartnerId());
}
$renderer->output();
KExternalErrors::dieGracefully();
}
}
$audioOnly = $this->getRequestParameter("audioOnly");
示例7: resizeEntryImage
public static function resizeEntryImage(entry $entry, $version, $width, $height, $type, $bgcolor = "ffffff", $crop_provider = null, $quality = 0, $src_x = 0, $src_y = 0, $src_w = 0, $src_h = 0, $vid_sec = -1, $vid_slice = 0, $vid_slices = -1, $orig_image_path = null)
{
$contentPath = myContentStorage::getFSContentRootPath();
$entry_status = $entry->getStatus();
$tempThumbName = $entry->getId() . "_{$width}_{$height}_{$type}_{$crop_provider}_{$bgcolor}_{$quality}_{$src_x}_{$src_y}_{$src_w}_{$src_h}_{$vid_sec}_{$vid_slice}_{$vid_slices}_{$entry_status}";
$entryThumbFilename = $entry->getThumbnail() ? $entry->getThumbnail() : "0.jpg";
if ($entry->getStatus() != entryStatus::READY || @$entryThumbFilename[0] == '&') {
$tempThumbName .= "_NOCACHE_";
}
// we remove the & from the template thumb otherwise getGeneralEntityPath will drop $tempThumbName from the final path
$entryThumbFilename = str_replace("&", "", $entryThumbFilename);
$basePath = myContentStorage::getGeneralEntityPath("entry/tempthumb", $entry->getIntId(), $tempThumbName, $entryThumbFilename, $version);
$tempThumbPath = $contentPath . $basePath;
$cachedTempThumbPath = myContentStorage::getFSCacheRootPath() . $basePath;
if (file_exists($cachedTempThumbPath)) {
header("X-Kaltura:cached-local-thumb-exists," . md5($cachedTempThumbPath));
return $cachedTempThumbPath;
}
if (file_exists($tempThumbPath)) {
header("X-Kaltura:cached-thumb-exists," . md5($tempThumbPath));
return $tempThumbPath;
}
if ($orig_image_path === null || !file_exists($orig_image_path)) {
$sub_type = $entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE ? entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA : entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB;
$orig_image_key = $entry->getSyncKey($sub_type, $version);
$orig_image_path = kFileSyncUtils::getReadyLocalFilePathForKey($orig_image_key);
}
// remark added so ffmpeg will try to load the thumbnail from the original source
//if (!file_exists($orig_image_path))
// KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
// check a request for animated thumbs without a concrete vid_slice
// in which case we'll create all the frames as one wide image
$multi = $vid_slice == -1 && $vid_slices != -1;
$count = $multi ? $vid_slices : 1;
$im = null;
if ($multi) {
$vid_slice = 0;
}
while ($count--) {
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_VIDEO && ($vid_sec != -1 || $vid_slices != -1) || !file_exists($orig_image_path)) {
if ($vid_sec != -1) {
$calc_vid_sec = min($vid_sec, floor($entry->getLengthInMsecs() / 1000));
} else {
if ($vid_slices != -1) {
$calc_vid_sec = floor($entry->getLengthInMsecs() / $vid_slices * min($vid_slice, $vid_slices) / 1000);
} else {
if ($entry->getStatus() != entryStatus::READY && $entry->getLengthInMsecs() == 0) {
$calc_vid_sec = $entry->getPartner() && $entry->getPartner()->getDefThumbOffset() ? $entry->getPartner()->getDefThumbOffset() : 3;
} else {
$calc_vid_sec = $entry->getBestThumbOffset();
}
}
}
$capturedThumbName = $entry->getId() . "_sec_{$calc_vid_sec}";
$capturedThumbPath = $contentPath . myContentStorage::getGeneralEntityPath("entry/tempthumb", $entry->getIntId(), $capturedThumbName, $entry->getThumbnail(), $version);
$orig_image_path = $capturedThumbPath . "temp_1.jpg";
// if we already captured the frame at that second, dont recapture, just use the existing file
if (!file_exists($orig_image_path)) {
// creating the thumbnail is a very heavy operation
// prevent calling it in parallel for the same thubmnail for 5 minutes
$cache = new myCache("thumb-processing", 5 * 60);
// 5 minutes
$processing = $cache->get($orig_image_path);
if ($processing) {
KExternalErrors::dieError(KExternalErrors::PROCESSING_CAPTURE_THUMBNAIL);
}
$cache->put($orig_image_path, true);
$flavorAsset = flavorAssetPeer::retrieveOriginalReadyByEntryId($entry->getId());
if (is_null($flavorAsset) || !($flavorAsset->hasTag(flavorParams::TAG_MBR) || $flavorAsset->hasTag(flavorParams::TAG_WEB))) {
// try the best playable
$flavorAsset = flavorAssetPeer::retrieveHighestBitrateByEntryId($entry->getId());
}
if (is_null($flavorAsset)) {
// if no READY ORIGINAL entry is available, try to retreive a non-READY ORIGINAL entry
$flavorAsset = flavorAssetPeer::retreiveOriginalByEntryId($entry->getId());
}
if (is_null($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$flavorSyncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$entry_data_path = kFileSyncUtils::getReadyLocalFilePathForKey($flavorSyncKey);
if (!$entry_data_path) {
// since this is not really being processed on this server, and will probably cause redirect in thumbnailAction
// remove from cache so later requests will still get redirected and will not fail on PROCESSING_CAPTURE_THUMBNAIL
$cache->remove($orig_image_path);
throw new kFileSyncException('no ready filesync on current DC', kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC);
}
myFileConverter::autoCaptureFrame($entry_data_path, $capturedThumbPath . "temp_", $calc_vid_sec, -1, -1);
$cache->remove($orig_image_path);
}
}
kFile::fullMkdir($tempThumbPath);
if ($crop_provider) {
$convertedImagePath = myFileConverter::convertImageUsingCropProvider($orig_image_path, $tempThumbPath, $width, $height, $type, $crop_provider, $bgcolor, true, $quality, $src_x, $src_y, $src_w, $src_h);
} else {
$convertedImagePath = myFileConverter::convertImage($orig_image_path, $tempThumbPath, $width, $height, $type, $bgcolor, true, $quality, $src_x, $src_y, $src_w, $src_h);
}
// die if resize operation failed
if ($convertedImagePath === null) {
KExternalErrors::dieError(KExternalErrors::IMAGE_RESIZE_FAILED);
//.........这里部分代码省略.........
示例8: resizeEntryImage
public static function resizeEntryImage(entry $entry, $version, $width, $height, $type, $bgcolor = "ffffff", $crop_provider = null, $quality = 0, $src_x = 0, $src_y = 0, $src_w = 0, $src_h = 0, $vid_sec = -1, $vid_slice = 0, $vid_slices = -1, $orig_image_path = null, $density = 0, $stripProfiles = false, $thumbParams = null, $format = null)
{
if (is_null($thumbParams) || !$thumbParams instanceof kThumbnailParameters) {
$thumbParams = new kThumbnailParameters();
}
$contentPath = myContentStorage::getFSContentRootPath();
$entry_status = $entry->getStatus();
$thumbName = $entry->getId() . "_{$width}_{$height}_{$type}_{$crop_provider}_{$bgcolor}_{$quality}_{$src_x}_{$src_y}_{$src_w}_{$src_h}_{$vid_sec}_{$vid_slice}_{$vid_slices}_{$entry_status}";
if ($orig_image_path) {
$thumbName .= '_oip_' . basename($orig_image_path);
}
if ($density) {
$thumbName .= "_dns_{$density}";
}
if ($stripProfiles) {
$thumbName .= "_stp_{$stripProfiles}";
}
$entryThumbFilename = $entry->getThumbnail() ? $entry->getThumbnail() : "0.jpg";
if ($entry->getStatus() != entryStatus::READY || @$entryThumbFilename[0] == '&') {
$thumbName .= "_NOCACHE_";
}
// we remove the & from the template thumb otherwise getGeneralEntityPath will drop $tempThumbName from the final path
$entryThumbFilename = str_replace("&", "", $entryThumbFilename);
//create final path for thumbnail created
$finalBasePath = myContentStorage::getGeneralEntityPath("entry/tempthumb", $entry->getIntId(), $thumbName, $entryThumbFilename, $version);
$finalThumbPath = $contentPath . $finalBasePath;
//Add unique id to the proccesing file path to avoid file being overwritten when several identical (with same parameters) calls are made before the final thumbnail is created
$thumbName .= "_" . uniqid() . "_";
//create path for processing thumbnail request
$processingBasePath = myContentStorage::getGeneralEntityPath("entry/tempthumb", $entry->getIntId(), $thumbName, $entryThumbFilename, $version);
$processingThumbPath = $contentPath . $processingBasePath;
if (!is_null($format)) {
$finalThumbPath = kFile::replaceExt($finalThumbPath, $format);
$processingThumbPath = kFile::replaceExt($processingThumbPath, $format);
}
if (file_exists($finalThumbPath) && @filesize($finalThumbPath)) {
header("X-Kaltura:cached-thumb-exists," . md5($finalThumbPath));
return $finalThumbPath;
}
if ($orig_image_path === null || !file_exists($orig_image_path)) {
$orig_image_path = self::getLocalImageFilePathByEntry($entry, $version);
}
// remark added so ffmpeg will try to load the thumbnail from the original source
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE && !file_exists($orig_image_path)) {
throw new kFileSyncException('no ready filesync on current DC', kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC);
}
// check a request for animated thumbs without a concrete vid_slice
// in which case we'll create all the frames as one wide image
$multi = $vid_slice == -1 && $vid_slices != -1;
$count = $multi ? $vid_slices : 1;
$im = null;
if ($multi) {
$vid_slice = 0;
}
while ($count--) {
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_VIDEO && ($vid_sec != -1 || $vid_slices != -1) || !file_exists($orig_image_path)) {
if ($vid_sec != -1) {
$calc_vid_sec = min($vid_sec, floor($entry->getLengthInMsecs() / 1000));
} else {
if ($vid_slices != -1) {
$calc_vid_sec = floor($entry->getLengthInMsecs() / $vid_slices * min($vid_slice, $vid_slices) / 1000);
} else {
if ($entry->getStatus() != entryStatus::READY && $entry->getLengthInMsecs() == 0) {
$calc_vid_sec = $entry->getPartner() && $entry->getPartner()->getDefThumbOffset() ? $entry->getPartner()->getDefThumbOffset() : 3;
} else {
$calc_vid_sec = $entry->getBestThumbOffset();
}
}
}
$capturedThumbName = $entry->getId() . "_sec_{$calc_vid_sec}";
$capturedThumbPath = $contentPath . myContentStorage::getGeneralEntityPath("entry/tempthumb", $entry->getIntId(), $capturedThumbName, $entry->getThumbnail(), $version);
$orig_image_path = $capturedThumbPath . "temp_1.jpg";
// if we already captured the frame at that second, dont recapture, just use the existing file
if (!file_exists($orig_image_path)) {
// limit creation of more than XX ffmpeg image extraction processes
if (kConf::hasParam("resize_thumb_max_processes_ffmpeg") && trim(exec("ps -e -ocmd|awk '{print \$1}'|grep -c " . kConf::get("bin_path_ffmpeg"))) > kConf::get("resize_thumb_max_processes_ffmpeg")) {
KExternalErrors::dieError(KExternalErrors::TOO_MANY_PROCESSES);
}
// creating the thumbnail is a very heavy operation
// prevent calling it in parallel for the same thubmnail for 5 minutes
$cache = new myCache("thumb-processing", 5 * 60);
// 5 minutes
$processing = $cache->get($orig_image_path);
if ($processing) {
KExternalErrors::dieError(KExternalErrors::PROCESSING_CAPTURE_THUMBNAIL);
}
$cache->put($orig_image_path, true);
$flavorAsset = assetPeer::retrieveHighestBitrateByEntryId($entry->getId(), flavorParams::TAG_THUMBSOURCE);
if (is_null($flavorAsset)) {
$flavorAsset = assetPeer::retrieveOriginalReadyByEntryId($entry->getId());
if ($flavorAsset) {
$flavorSyncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($flavorSyncKey, false, false);
if (!$fileSync) {
$flavorAsset = null;
}
}
if (is_null($flavorAsset) || !($flavorAsset->hasTag(flavorParams::TAG_MBR) || $flavorAsset->hasTag(flavorParams::TAG_WEB))) {
// try the best playable
$flavorAsset = assetPeer::retrieveHighestBitrateByEntryId($entry->getId(), null, flavorParams::TAG_SAVE_SOURCE);
//.........这里部分代码省略.........
示例9: execute
//.........这里部分代码省略.........
}
if (!is_numeric($height) || $height < 0 || $height > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'height must be between 0 and 10000');
}
if (!is_numeric($density) || $density < 0) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'density must be positive');
}
if (!is_numeric($vid_sec) || $vid_sec < -1) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'vid_sec must be positive');
}
if (!preg_match('/^[0-9a-fA-F]{1,6}$/', $bgcolor)) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'bgcolor must be six hexadecimal characters');
}
if ($vid_slices != -1 && $vid_slices <= 0 || !is_numeric($vid_slices)) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'vid_slices must be positive');
}
if ($upload_token_id) {
$upload_token = UploadTokenPeer::retrieveByPK($upload_token_id);
if ($upload_token) {
$partnerId = $upload_token->getPartnerId();
$partner = PartnerPeer::retrieveByPK($partnerId);
if ($partner) {
KalturaMonitorClient::initApiMonitor(false, 'extwidget.thumbnail', $partner->getId());
if ($quality == 0) {
$quality = $partner->getDefThumbQuality();
}
if ($density == 0) {
$density = $partner->getDefThumbDensity();
}
if (is_null($stripProfiles)) {
$stripProfiles = $partner->getStripThumbProfile();
}
}
$thumb_full_path = myContentStorage::getFSCacheRootPath() . myContentStorage::getGeneralEntityPath("uploadtokenthumb", $upload_token->getIntId(), $upload_token->getId(), $upload_token->getId() . ".jpg");
kFile::fullMkdir($thumb_full_path);
if (file_exists($upload_token->getUploadTempPath())) {
$src_full_path = $upload_token->getUploadTempPath();
$valid_image_types = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP);
$image_type = exif_imagetype($src_full_path);
if (!in_array($image_type, $valid_image_types)) {
// capture full frame
myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 3);
if (!file_exists($thumb_full_path)) {
myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 0);
}
$src_full_path = $thumb_full_path;
}
// and resize it
myFileConverter::convertImage($src_full_path, $thumb_full_path, $width, $height, $type, $bgcolor, true, $quality, $src_x, $src_y, $src_w, $src_h, $density, $stripProfiles, null, $format);
kFileUtils::dumpFile($thumb_full_path);
} else {
KalturaLog::info("token_id [{$upload_token_id}] not found in DC [" . kDataCenterMgr::getCurrentDcId() . "]. dump url to romote DC");
$remoteUrl = kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()) . $_SERVER['REQUEST_URI'];
kFileUtils::dumpUrl($remoteUrl);
}
}
}
if ($entry_id) {
$entry = entryPeer::retrieveByPKNoFilter($entry_id);
if (!$entry) {
// problem could be due to replication lag
kFileUtils::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()));
}
} else {
// get the widget
$widget = widgetPeer::retrieveByPK($widget_id);
示例10: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
requestUtils::handleConditionalGet();
ignore_user_abort();
$entry_id = $this->getRequestParameter("entry_id");
$widget_id = $this->getRequestParameter("widget_id", 0);
$upload_token_id = $this->getRequestParameter("upload_token_id");
$version = $this->getRequestParameter("version", null);
$width = $this->getRequestParameter("width", -1);
$height = $this->getRequestParameter("height", -1);
$type = $this->getRequestParameter("type", 1);
$crop_provider = $this->getRequestParameter("crop_provider", null);
$quality = $this->getRequestParameter("quality", 0);
$src_x = $this->getRequestParameter("src_x", 0);
$src_y = $this->getRequestParameter("src_y", 0);
$src_w = $this->getRequestParameter("src_w", 0);
$src_h = $this->getRequestParameter("src_h", 0);
$vid_sec = $this->getRequestParameter("vid_sec", -1);
$vid_slice = $this->getRequestParameter("vid_slice", -1);
$vid_slices = $this->getRequestParameter("vid_slices", -1);
// actual width and height of image from which the src_* values were taken.
// these will be used to multiply the src_* parameters to make them relate to the original image size.
$rel_width = $this->getRequestParameter("rel_width", -1);
$rel_height = $this->getRequestParameter("rel_height", -1);
if ($width == -1 && $height == -1) {
$width = 120;
$height = 90;
} else {
if ($width == -1) {
// if only either width or height is missing reset them to zero, and convertImage will handle them
$width = 0;
} else {
if ($height == -1) {
$height = 0;
}
}
}
$bgcolor = $this->getRequestParameter("bgcolor", "ffffff");
if ($upload_token_id) {
$upload_token = UploadTokenPeer::retrieveByPK($upload_token_id);
if ($upload_token) {
$thumb_full_path = myContentStorage::getFSCacheRootPath() . myContentStorage::getGeneralEntityPath("uploadtokenthumb", $upload_token->getIntId(), $upload_token->getId(), $upload_token->getId() . ".jpg");
kFile::fullMkdir($thumb_full_path);
if (file_exists($upload_token->getUploadTempPath())) {
$src_full_path = $upload_token->getUploadTempPath();
$valid_image_types = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP);
$image_type = exif_imagetype($src_full_path);
if (!in_array($image_type, $valid_image_types)) {
// capture full frame
myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 3);
if (!file_exists($thumb_full_path)) {
myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 0);
}
$src_full_path = $thumb_full_path;
}
// and resize it
myFileConverter::convertImage($src_full_path, $thumb_full_path, $width, $height, $type, $bgcolor, true, $quality, $src_x, $src_y, $src_w, $src_h);
kFile::dumpFile($thumb_full_path);
}
}
}
$entry = entryPeer::retrieveByPKNoFilter($entry_id);
// multiply the passed $src_* values so that they will relate to the original image size, according to $src_display_*
if ($rel_width != -1) {
$widthRatio = $entry->getWidth() / $rel_width;
$src_x = $src_x * $widthRatio;
$src_w = $src_w * $widthRatio;
}
if ($rel_height != -1) {
$heightRatio = $entry->getHeight() / $rel_height;
$src_y = $src_y * $heightRatio;
$src_h = $src_h * $heightRatio;
}
if (!$entry) {
// get the widget
$widget = widgetPeer::retrieveByPK($widget_id);
if (!$widget) {
KExternalErrors::dieError(KExternalErrors::ENTRY_AND_WIDGET_NOT_FOUND);
}
// get the kshow
$kshow_id = $widget->getKshowId();
$kshow = kshowPeer::retrieveByPK($kshow_id);
if ($kshow) {
$entry_id = $kshow->getShowEntryId();
} else {
$entry_id = $widget->getEntryId();
}
$entry = entryPeer::retrieveByPKNoFilter($entry_id);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
$subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB;
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA;
}
//.........这里部分代码省略.........