本文整理汇总了PHP中kFileSyncUtils::file_exists方法的典型用法代码示例。如果您正苦于以下问题:PHP kFileSyncUtils::file_exists方法的具体用法?PHP kFileSyncUtils::file_exists怎么用?PHP kFileSyncUtils::file_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kFileSyncUtils
的用法示例。
在下文中一共展示了kFileSyncUtils::file_exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
$this->forceSystemAuthentication();
myDbHelper::$use_alternative_con = null;
//myDbHelper::DB_HELPER_CONN_PROPEL2
$uiConfId = $this->getRequestParameter("id");
$uiConf = uiConfPeer::retrieveByPK($uiConfId);
$subTypes = array(uiconf::FILE_SYNC_UICONF_SUB_TYPE_DATA, uiconf::FILE_SYNC_UICONF_SUB_TYPE_FEATURES);
foreach ($subTypes as $subType) {
if ($subType == uiconf::FILE_SYNC_UICONF_SUB_TYPE_DATA) {
echo "Data:" . PHP_EOL;
} else {
if ($subType == uiconf::FILE_SYNC_UICONF_SUB_TYPE_FEATURES) {
echo "Features:" . PHP_EOL;
}
}
$syncKey = $uiConf->getSyncKey($subType);
if (kFileSyncUtils::file_exists($syncKey)) {
echo "File sync already exists." . PHP_EOL;
} else {
list($rootPath, $filePath) = $uiConf->generateFilePathArr($subType);
$fullPath = $rootPath . $filePath;
if (file_exists($fullPath)) {
kFileSyncUtils::createSyncFileForKey($syncKey);
echo "Created successfully." . PHP_EOL;
} else {
echo "File not found:" . PHP_EOL;
echo $fullPath . PHP_EOL;
echo "Not creating file sync." . PHP_EOL;
}
}
echo PHP_EOL;
}
die;
}
示例2: execute
public function execute()
{
$jobId = $this->getRequestParameter("id");
$partnerId = $this->getRequestParameter("pid");
$type = $this->getRequestParameter("type");
$c = new Criteria();
$c->addAnd(BatchJobPeer::ID, $jobId);
$c->addAnd(BatchJobPeer::PARTNER_ID, $partnerId);
$c->addAnd(BatchJobPeer::JOB_TYPE, BatchJobType::BULKUPLOAD);
$batchJob = BatchJobPeer::doSelectOne($c);
if (!$batchJob) {
die("File not found");
}
header("Content-Type: text/plain; charset=UTF-8");
if ($type == "log") {
$bulkUploadResults = BulkUploadResultPeer::retrieveByBulkUploadId($jobId);
if (!count($bulkUploadResults)) {
$syncKey = $batchJob->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_BULKUPLOADLOG);
if (kFileSyncUtils::file_exists($syncKey, true)) {
$content = kFileSyncUtils::file_get_contents($syncKey, true);
echo $content;
die;
}
die("Log file is not ready");
}
$STDOUT = fopen('php://output', 'w');
$data = $batchJob->getData();
foreach ($bulkUploadResults as $bulkUploadResult) {
$values = array($bulkUploadResult->getTitle(), $bulkUploadResult->getDescription(), $bulkUploadResult->getTags(), $bulkUploadResult->getUrl(), $bulkUploadResult->getContentType());
if ($data instanceof kBulkUploadJobData && $data->getCsvVersion() > kBulkUploadJobData::BULK_UPLOAD_CSV_VERSION_V1) {
$values[] = $bulkUploadResult->getConversionProfileId();
$values[] = $bulkUploadResult->getAccessControlProfileId();
$values[] = $bulkUploadResult->getCategory();
$values[] = $bulkUploadResult->getScheduleStartDate('Y-m-d\\TH:i:s');
$values[] = $bulkUploadResult->getScheduleEndDate('Y-m-d\\TH:i:s');
$values[] = $bulkUploadResult->getThumbnailUrl();
$values[] = $bulkUploadResult->getPartnerData();
}
$values[] = $bulkUploadResult->getEntryId();
$values[] = $bulkUploadResult->getEntryStatus();
$values[] = $bulkUploadResult->getErrorDescription();
fputcsv($STDOUT, $values);
}
fclose($STDOUT);
} else {
$syncKey = $batchJob->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_BULKUPLOADCSV);
if (kFileSyncUtils::file_exists($syncKey, true)) {
$content = kFileSyncUtils::file_get_contents($syncKey, true);
echo $content;
die;
} else {
die("File not found");
}
}
die;
// no template needed
}
示例3: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
// where file is {entryId/flavorId}.{ism,ismc,ismv}
$objectId = $type = null;
$objectIdStr = $this->getRequestParameter("objectId");
if ($objectIdStr) {
list($objectId, $type) = @explode(".", $objectIdStr);
}
if (!$type || !$objectId) {
KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER);
}
$ks = $this->getRequestParameter("ks");
$referrer = base64_decode($this->getRequestParameter("referrer"));
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = '';
}
$syncKey = $this->getFileSyncKey($objectId, $type);
KalturaMonitorClient::initApiMonitor(false, 'extwidget.serveIsm', $this->entry->getPartnerId());
myPartnerUtils::enforceDelivery($this->entry, $this->flavorAsset);
if (!kFileSyncUtils::file_exists($syncKey, false)) {
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
if (is_null($fileSync)) {
KalturaLog::log("Error - no FileSync for type [{$type}] objectId [{$objectId}]");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
kFileUtils::dumpUrl($remoteUrl);
}
$path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
if ($type == 'ism') {
$fileData = $this->fixIsmManifestForReplacedEntry($path);
$renderer = new kRendererString($fileData, 'image/ism');
$renderer->output();
KExternalErrors::dieGracefully();
} else {
kFileUtils::dumpFile($path);
}
}
示例4: copyToEntry
public function copyToEntry($entryId = null, $partnerId = null)
{
$newFlavorAsset = $this->copy();
if ($partnerId) {
$newFlavorAsset->setPartnerId($partnerId);
}
if ($entryId) {
$newFlavorAsset->setEntryId($entryId);
}
$newFlavorAsset->save();
$flavorParamsOutput = flavorParamsOutputPeer::retrieveByFlavorAssetId($this->getId());
if ($flavorParamsOutput) {
$newFlavorParamsOutput = $flavorParamsOutput->copy();
$newFlavorParamsOutput->setPartnerId($newFlavorAsset->getPartnerId());
$newFlavorParamsOutput->setEntryId($newFlavorAsset->getEntryId());
$newFlavorParamsOutput->setFlavorAssetId($newFlavorAsset->getId());
$newFlavorParamsOutput->save();
}
$mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($this->getId());
if ($mediaInfo) {
$newMediaInfo = $mediaInfo->copy();
$newMediaInfo->setFlavorAssetId($newFlavorAsset->getId());
$newMediaInfo->save();
}
$assetSyncKey = $this->getSyncKey(self::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$convertLogSyncKey = $this->getSyncKey(self::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_CONVERT_LOG);
$newAssetSyncKey = $newFlavorAsset->getSyncKey(self::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$newConvertLogSyncKey = $newFlavorAsset->getSyncKey(self::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_CONVERT_LOG);
if (kFileSyncUtils::file_exists($assetSyncKey, true)) {
kFileSyncUtils::softCopy($assetSyncKey, $newAssetSyncKey);
}
if (kFileSyncUtils::file_exists($convertLogSyncKey, true)) {
kFileSyncUtils::softCopy($convertLogSyncKey, $newConvertLogSyncKey);
}
return $newFlavorAsset;
}
示例5: execute
public function execute()
{
requestUtils::handleConditionalGet();
$flavorId = $this->getRequestParameter("flavorId");
$shouldProxy = $this->getRequestParameter("forceproxy", false);
$ks = $this->getRequestParameter("ks");
$fileParam = $this->getRequestParameter("file");
$referrer = base64_decode($this->getRequestParameter("referrer"));
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = '';
}
$flavorAsset = flavorAssetPeer::retrieveById($flavorId);
if (is_null($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$entry = entryPeer::retrieveByPK($flavorAsset->getEntryId());
if (is_null($entry)) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
myPartnerUtils::blockInactivePartner($flavorAsset->getPartnerId());
myPartnerUtils::enforceDelivery($flavorAsset->getPartnerId());
//disabled enforce cdn because of rtmp delivery
//requestUtils::enforceCdnDelivery($flavorAsset->getPartnerId());
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if (!kFileSyncUtils::file_exists($syncKey, false)) {
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
if (is_null($fileSync)) {
KalturaLog::log("Error - no FileSync for flavor [" . $flavorAsset->getId() . "]");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
// always dump remote urls so they will be cached by the cdn transparently
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
kFile::dumpUrl($remoteUrl, true, true);
}
$path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
$flvWrapper = new myFlvHandler($path);
$isFlv = $flvWrapper->isFlv();
$clipFrom = $this->getRequestParameter("clipFrom", 0);
// milliseconds
$clipTo = $this->getRequestParameter("clipTo", 2147483647);
// milliseconds
if ($clipTo == 0) {
$clipTo = 2147483647;
}
if (is_dir($path) && $fileParam) {
$path .= "/{$fileParam}";
//echo "path($path),file($fileParam)";
kFile::dumpFile($path, null, null);
die;
} else {
if (!$isFlv) {
$limit_file_size = 0;
if ($clipTo != 2147483647) {
$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(@filesize($path) * ($clipTo / $duration));
}
}
kFile::dumpFile($path, null, null, $limit_file_size);
die;
}
}
$audioOnly = $this->getRequestParameter("audioOnly");
// milliseconds
if ($audioOnly === '0') {
// audioOnly was explicitly set to 0 - don't attempt to make further automatic investigations
} elseif ($flvWrapper->getFirstVideoTimestamp() < 0) {
$audioOnly = true;
}
$seekFrom = $this->getRequestParameter("seekFrom", -1);
if ($seekFrom <= 0) {
$seekFrom = -1;
}
$seekFromBytes = $this->getRequestParameter("seekFromBytes", -1);
if ($seekFromBytes <= 0) {
$seekFromBytes = -1;
}
$bytes = 0;
if ($seekFrom !== -1 && $seekFrom !== 0) {
list($bytes, $duration, $firstTagByte, $toByte) = $flvWrapper->clip(0, -1, $audioOnly);
list($bytes, $duration, $fromByte, $toByte, $seekFromTimestamp) = $flvWrapper->clip($seekFrom, -1, $audioOnly);
$seekFromBytes = myFlvHandler::FLV_HEADER_SIZE + $flvWrapper->getMetadataSize($audioOnly) + $fromByte - $firstTagByte;
} else {
list($bytes, $duration, $fromByte, $toByte, $fromTs, $cuepointPos) = myFlvStaticHandler::clip($path, $clipFrom, $clipTo, $audioOnly);
}
$metadataSize = $flvWrapper->getMetadataSize($audioOnly);
$dataOffset = $metadataSize + myFlvHandler::getHeaderSize();
$totalLength = $dataOffset + $bytes;
list($bytes, $duration, $fromByte, $toByte, $fromTs, $cuepointPos) = myFlvStaticHandler::clip($path, $clipFrom, $clipTo, $audioOnly);
list($rangeFrom, $rangeTo, $rangeLength) = requestUtils::handleRangeRequest($totalLength);
if ($totalLength < 1000) {
// (actually $total_length is probably 13 or 143 - header + empty metadata tag) probably a bad flv maybe only the header - dont cache
requestUtils::sendCdnHeaders("flv", $rangeLength, 0);
} else {
requestUtils::sendCdnHeaders("flv", $rangeLength);
}
header('Content-Disposition: attachment; filename="video.flv"');
// dont inject cuepoint into the stream
//.........这里部分代码省略.........
示例6: execute
public function execute()
{
//entitlement should be disabled to serveFlavor action as we do not get ks on this action.
KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
requestUtils::handleConditionalGet();
$flavorId = $this->getRequestParameter("flavorId");
$shouldProxy = $this->getRequestParameter("forceproxy", false);
$fileName = $this->getRequestParameter("fileName");
$fileParam = $this->getRequestParameter("file");
$fileParam = basename($fileParam);
$pathOnly = $this->getRequestParameter("pathOnly", false);
$referrer = base64_decode($this->getRequestParameter("referrer"));
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = '';
}
$flavorAsset = assetPeer::retrieveById($flavorId);
if (is_null($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$entryId = $this->getRequestParameter("entryId");
if (!is_null($entryId) && $flavorAsset->getEntryId() != $entryId) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
if ($fileName) {
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
header("Content-Type: application/force-download");
header("Content-Description: File Transfer");
}
$clipTo = null;
$entry = $flavorAsset->getentry();
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
KalturaMonitorClient::initApiMonitor(false, 'extwidget.serveFlavor', $flavorAsset->getPartnerId());
myPartnerUtils::enforceDelivery($entry, $flavorAsset);
$version = $this->getRequestParameter("v");
if (!$version) {
$version = $flavorAsset->getVersion();
}
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET, $version);
if ($pathOnly && kIpAddressUtils::isInternalIp($_SERVER['REMOTE_ADDR'])) {
$path = null;
list($file_sync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, false, false);
if ($file_sync) {
$parent_file_sync = kFileSyncUtils::resolve($file_sync);
$path = $parent_file_sync->getFullPath();
if ($fileParam && is_dir($path)) {
$path .= "/{$fileParam}";
}
}
$renderer = new kRendererString('{"sequences":[{"clips":[{"type":"source","path":"' . $path . '"}]}]}', 'application/json');
if ($path) {
$this->storeCache($renderer, $flavorAsset->getPartnerId());
}
$renderer->output();
KExternalErrors::dieGracefully();
}
if (kConf::hasParam('serve_flavor_allowed_partners') && !in_array($flavorAsset->getPartnerId(), kConf::get('serve_flavor_allowed_partners'))) {
KExternalErrors::dieError(KExternalErrors::ACTION_BLOCKED);
}
if (!kFileSyncUtils::file_exists($syncKey, false)) {
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
if (is_null($fileSync)) {
KalturaLog::log("Error - no FileSync for flavor [" . $flavorAsset->getId() . "]");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
// always dump remote urls so they will be cached by the cdn transparently
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
kFileUtils::dumpUrl($remoteUrl);
}
$path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
$isFlv = false;
if (!$shouldProxy) {
$flvWrapper = new myFlvHandler($path);
$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);
//.........这里部分代码省略.........
示例7: handleEntry
private function handleEntry($onlyExtractThumb, $prefix, $type, $entry_id, $name = null, $tags = null, $entry = null)
{
KalturaLog::debug("handleEntry({$type}, {$entry_id}, {$name})");
$this->clear($prefix, $entry_id);
$kuser_id = $this->kuser_id;
$entry_data_prefix = $kuser_id . '_' . ($prefix == '' ? 'data' : rtrim($prefix, '_'));
$uploads = myContentStorage::getFSUploadsPath();
$content = myContentStorage::getFSContentRootPath();
$media_source = $this->getParam('entry_media_source');
$media_type = $this->getParam('entry_media_type');
$entry_url = $this->getParam('entry_url');
$entry_source_link = $this->getParam('entry_source_link');
$entry_fileName = $this->getParam('entry_data');
$entry_thumbNum = $this->getParam('entry_thumb_num', 0);
$entry_thumbUrl = $this->getParam('entry_thumb_url', '');
$should_copy = $this->getParam('should_copy', false);
$skip_conversion = $this->getParam('skip_conversion', false);
$webcam_suffix = $this->getParam('webcam_suffix', '');
$duration = $this->getParam('duration', null);
$entry_fullPath = "";
$ext = null;
$entry = null;
if ($entry_id) {
$entry = entryPeer::retrieveByPK($entry_id);
} else {
$entry = new entry();
}
$this->entry = $entry;
$entry_status = $entry->getStatus();
if (is_null($entry_status)) {
$entry_status = entryStatus::READY;
}
// by the end of this block of code $entry_fullPath will point to the location of the entry
// the entry status will be set (IMPORT / PRECONVERT / READY)
// a background image is always previewed by the user no matter what source he used
// so the entry is already in the /uploads directory
// continue tracking the file upload
$te = new TrackEntry();
$te->setEntryId($entry_id);
$te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY);
KalturaLog::debug("handleEntry: media_source: {$media_source}, prefix: {$prefix}");
if ($media_source == entry::ENTRY_MEDIA_SOURCE_FILE || $prefix == 'bg_') {
$full_path = $this->getParam('entry_full_path');
if ($full_path) {
$entry_fullPath = $full_path;
} else {
$entry_fullPath = $uploads . $entry_data_prefix . strrchr($entry_fileName, '.');
}
if ($media_type == entry::ENTRY_MEDIA_TYPE_VIDEO || $media_type == entry::ENTRY_MEDIA_TYPE_AUDIO) {
$entry_status = entryStatus::PRECONVERT;
}
$te->setParam3Str($entry_fullPath);
$te->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA_SOURCE_FILE");
} else {
if ($media_source == entry::ENTRY_MEDIA_SOURCE_WEBCAM) {
// set $entry_fileName to webcam output file and flag that conversion is not needed
$webcam_basePath = $content . '/content/webcam/' . ($webcam_suffix ? $webcam_suffix : 'my_recorded_stream_' . $kuser_id);
$entry_fullPath = $webcam_basePath . '.' . kWAMSWebcam::OUTPUT_FILE_EXT;
$ext = kWAMSWebcam::OUTPUT_FILE_EXT;
if (file_exists($entry_fullPath)) {
// continue tracking the webcam
$te->setParam3Str($entry_fullPath);
$te->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA_SOURCE_WEBCAM");
} else {
KalturaLog::err("File [{$entry_fullPath}] does not exist");
$entry_status = entryStatus::ERROR_IMPORTING;
}
} else {
// if the url ends with .ext, we'll extract it this way
$urlext = strrchr($entry_url, '.');
// TODO: fix this patch
if (strlen($urlext) > 4) {
$urlext = '.jpg';
}
// if we got something wierd, assume we're downloading a jpg
$entry_fileName = $entry_data_prefix . $urlext;
KalturaLog::debug("handleEntry: media_type: {$media_type}");
if ($media_type == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$duration = 0;
$entry_fullPath = $uploads . $entry_fileName;
if (!kFile::downloadUrlToFile($entry_url, $entry_fullPath)) {
KalturaLog::debug("Failed downloading file[{$entry_url}]");
$entry_status = entryStatus::ERROR_IMPORTING;
}
// track images
$te->setParam3Str($entry_fullPath);
$te->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA_SOURCE_URL:ENTRY_MEDIA_TYPE_IMAGE");
} else {
if ($media_type == entry::ENTRY_MEDIA_TYPE_VIDEO) {
//fixme - we can extract during import
$ext = "flv";
} else {
$ext = "mp3";
}
$entry_status = entryStatus::IMPORT;
// track images
$te->setParam3Str($ext);
$te->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA_SOURCE_URL:ENTRY_MEDIA_TYPE_VIDEO");
}
}
//.........这里部分代码省略.........
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:101,代码来源:myInsertEntryHelper.class.php
示例8: executeImpl
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
{
KalturaLog::log("adddownloadAction: executeImpl ( {$partner_id} , {$subp_id} , {$puser_id} , {$partner_prefix} , {$puser_kuser})");
$entry_id = $this->getPM("entry_id");
$version = $this->getP("version");
$file_format = strtolower($this->getPM("file_format"));
$conversion_quality = $this->getP("conversion_quality", null);
$force_download = $this->getP("force_download", null);
$entry = entryPeer::retrieveByPK($entry_id);
if (!$entry) {
KalturaLog::log("add download Action entry not found");
$this->addError(APIErrors::INVALID_ENTRY_ID, $this->getObjectPrefix(), $entry_id);
return;
}
KalturaLog::log("adddownloadAction: entry found [{$entry_id}]");
/*
$content_path = myContentStorage::getFSContentRootPath();
$file_name = $content_path . $entry->getDataPath( $version ); // replaced__getDataPath
if (!file_exists($file_name))
*/
$sync_key = null;
$originalFlavorAsset = assetPeer::retrieveOriginalByEntryId($entry->getId());
if ($originalFlavorAsset) {
$sync_key = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
}
if (!$sync_key) {
$sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version);
}
if (!kFileSyncUtils::file_exists($sync_key)) {
// if not found local file - perhaps wasn't created here and wasn't synced yet
// try to see if remote exists - and proxy the request if it is.
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($sync_key, true, true);
if (!$local) {
// take input params and add to URL
$queryArr = array('entry_id' => $entry_id, 'version' => $version, 'file_format' => $file_format, 'conversion_quality' => $conversion_quality, 'force_download' => $force_download, 'ks' => $this->ks->toSecureString(), 'partner_id' => $partner_id, 'subp_id' => $subp_id, 'format' => $this->response_type);
$get_query = http_build_query($queryArr, '', '&');
$remote_url = kDataCenterMgr::getRedirectExternalUrl($fileSync, $_SERVER['REQUEST_URI']);
$url = strpos($remote_url, '?') === FALSE ? $remote_url . '?' . $get_query : $remote_url . '&' . $get_query;
// prxoy request to other DC
KalturaLog::log(__METHOD__ . ": redirecting to [{$url}]");
kFileUtils::dumpUrl($url);
}
KalturaLog::log("add download Action sync key doesn't exists");
$this->addError(APIErrors::INVALID_ENTRY_VERSION, $this->getObjectPrefix(), $entry_id, $version);
return;
}
if ($entry->getType() == entryType::MIX) {
KalturaLog::log("The Batch job for flattening a mix is no longer supported");
$this->addError(APIErrors::INVALID_ENTRY_TYPE, $this->getObjectPrefix(), $entry_id, $version);
return;
}
$flavorParamsId = 0;
if ($file_format != "original") {
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO) {
$file_format = "flv";
}
// Backward compatebility
if (!$file_format && $entry->getType() == entryType::DOCUMENT) {
$file_format = "swf";
}
$flavorParams = myConversionProfileUtils::getFlavorParamsFromFileFormat($partner_id, $file_format);
$flavorParamsId = $flavorParams->getId();
}
$jobs = kJobsManager::addBulkDownloadJob($partner_id, $puser_id, $entry->getId(), $flavorParamsId);
$job = $jobs[0];
// remove kConvertJobData object from batchJob.data
$job->setData(null);
$jobWrapperClass = objectWrapperBase::getWrapperClass($job, objectWrapperBase::DETAIL_LEVEL_DETAILED);
$this->addMsg("download", $jobWrapperClass);
// Backwards compatebilty for document entries
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_DOCUMENT || $entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_PDF) {
$this->addMsg("OOconvert", $jobWrapperClass);
$download_path = $entry->getDownloadUrl();
//TODO: once api_v3 will support parameters with '/' instead of '?', we can change this to war with api_v3
$download_path .= '/direct_serve/true/type/download/forceproxy/true/format/' . $file_format;
$this->addMsg('downloadUrl', $download_path);
}
}
示例9: handleImportFinished
/**
* @param BatchJob $dbBatchJob
* @param kImportJobData $data
* @param BatchJob $twinJob
* @return BatchJob
*/
public static function handleImportFinished(BatchJob $dbBatchJob, kImportJobData $data, BatchJob $twinJob = null)
{
KalturaLog::debug("Import finished, with file: " . $data->getDestFileLocalPath());
if ($dbBatchJob->getAbort()) {
return $dbBatchJob;
}
if (!$twinJob) {
if (!file_exists($data->getDestFileLocalPath())) {
throw new APIException(APIErrors::INVALID_FILE_NAME, $data->getDestFileLocalPath());
}
}
$msg = null;
$flavorAsset = kFlowHelper::createOriginalFlavorAsset($dbBatchJob->getPartnerId(), $dbBatchJob->getEntryId(), $msg);
if (!$flavorAsset) {
KalturaLog::err("Flavor asset not created for entry [" . $dbBatchJob->getEntryId() . "]");
kBatchManager::updateEntry($dbBatchJob, entryStatus::ERROR_CONVERTING);
$dbBatchJob->setMessage($msg);
$dbBatchJob->setDescription($dbBatchJob->getDescription() . "\n" . $msg);
return $dbBatchJob;
}
$syncKey = null;
if ($twinJob) {
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
// copy file sync
$twinData = $twinJob->getData();
if ($twinData instanceof kImportJobData) {
$twinFlavorAsset = flavorAssetPeer::retrieveById($twinData->getFlavorAssetId());
if ($twinFlavorAsset) {
$twinSyncKey = $twinFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if ($twinSyncKey && kFileSyncUtils::file_exists($twinSyncKey)) {
kFileSyncUtils::softCopy($twinSyncKey, $syncKey);
}
}
}
} else {
$ext = pathinfo($data->getDestFileLocalPath(), PATHINFO_EXTENSION);
KalturaLog::info("Imported file extension: {$ext}");
$flavorAsset->setFileExt($ext);
$flavorAsset->save();
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
kFileSyncUtils::moveFromFile($data->getDestFileLocalPath(), $syncKey);
}
// set the path in the job data
$data->setDestFileLocalPath(kFileSyncUtils::getLocalFilePathForKey($syncKey));
$data->setFlavorAssetId($flavorAsset->getId());
$dbBatchJob->setData($data);
$dbBatchJob->save();
kEventsManager::raiseEvent(new kObjectAddedEvent($flavorAsset));
return $dbBatchJob;
}
示例10: copyEntryData
public static function copyEntryData(entry $entry, entry $targetEntry)
{
// for any type that does not require assets:
$shouldCopyDataForNonClip = true;
if ($entry->getType() == entryType::MEDIA_CLIP) {
$shouldCopyDataForNonClip = false;
}
if ($entry->getType() == entryType::PLAYLIST) {
$shouldCopyDataForNonClip = false;
}
$shouldCopyDataForClip = false;
// only images get their data copied
if ($entry->getType() == entryType::MEDIA_CLIP) {
if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_VIDEO && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_AUDIO) {
$shouldCopyDataForClip = true;
}
}
if ($shouldCopyDataForNonClip || $shouldCopyDataForClip) {
// copy the data
$from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
// replaced__getDataPath
$to = $targetEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
// replaced__getDataPath
KalturaLog::log("copyEntriesByType - copying entry data [" . $from . "] to [" . $to . "]");
kFileSyncUtils::softCopy($from, $to);
}
$ismFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
if (kFileSyncUtils::fileSync_exists($ismFrom)) {
$ismTo = $targetEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
KalturaLog::log("copying entry ism [" . $ismFrom . "] to [" . $ismTo . "]");
kFileSyncUtils::softCopy($ismFrom, $ismTo);
}
$ismcFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
if (kFileSyncUtils::fileSync_exists($ismcFrom)) {
$ismcTo = $targetEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
KalturaLog::log("copying entry ism [" . $ismcFrom . "] to [" . $ismcTo . "]");
kFileSyncUtils::softCopy($ismcFrom, $ismcTo);
}
$from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
// replaced__getThumbnailPath
$considerCopyThumb = true;
// if entry is image - data is thumbnail, and it was copied
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$considerCopyThumb = false;
}
// if entry is not clip, and there is no file in both DCs - nothing to copy
if ($entry->getType() != entryType::MEDIA_CLIP && !kFileSyncUtils::file_exists($from, true)) {
$considerCopyThumb = false;
}
if ($considerCopyThumb) {
$skipThumb = false;
// don't attempt to copy a thumbnail for images - it's the same as the data which was just created
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO) {
// check if audio entry has real thumb, if not - don't copy thumb.
$originalFileSync = kFileSyncUtils::getOriginFileSyncForKey($from, false);
if (!$originalFileSync) {
$skipThumb = true;
}
}
if (!$skipThumb) {
$to = $targetEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
// replaced__getThumbnailPath
KalturaLog::log("copyEntriesByType - copying entry thumbnail [" . $from . "] to [" . $to . "]");
kFileSyncUtils::softCopy($from, $to);
}
}
// added by Tan-Tan 12/01/2010 to support falvors copy
$sourceAssets = assetPeer::retrieveByEntryId($entry->getId());
foreach ($sourceAssets as $sourceAsset) {
$sourceAsset->copyToEntry($targetEntry->getId(), $targetEntry->getPartnerId());
}
}
示例11: execute
//.........这里部分代码省略.........
// when flavor is null, we will get a default flavor
if ($flavor == "edit") {
$flavorAsset = flavorAssetPeer::retrieveBestEditByEntryId($entry->getId());
} elseif (!is_null($flavor)) {
$flavorAsset = flavorAssetPeer::retrieveById($flavor);
// when specific asset was request, we don't validate its tags
if ($flavorAsset && ($flavorAsset->getEntryId() != $entry->getId() || $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY)) {
$flavorAsset = null;
}
// we will throw an error later
} elseif (is_null($flavor) && !is_null($flavor_param_id)) {
$flavorAsset = flavorAssetPeer::retrieveByEntryIdAndFlavorParams($entry->getId(), $flavor_param_id);
if ($flavorAsset && $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) {
$flavorAsset = null;
}
// we will throw an error later
} else {
if ($entry->getSource() == entry::ENTRY_MEDIA_SOURCE_WEBCAM) {
$flavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($entry->getId());
} else {
$flavorAsset = flavorAssetPeer::retrieveBestPlayByEntryId($entry->getId());
}
if (!$flavorAsset) {
$flavorAssets = flavorAssetPeer::retreiveReadyByEntryIdAndTag($entry->getId(), flavorParams::TAG_WEB);
if (count($flavorAssets) > 0) {
$flavorAsset = $flavorAssets[0];
}
}
}
if (is_null($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if (kFileSyncUtils::file_exists($syncKey, false)) {
$path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
} else {
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
if (is_null($fileSync)) {
KalturaLog::log("Error - no FileSync for flavor [" . $flavorAsset->getId() . "]");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
$this->redirect($remoteUrl);
}
$flv_wrapper = new myFlvHandler($path);
$isFlv = $flv_wrapper->isFlv();
// scrubbing is not allowed within mp4 files
if (!$isFlv) {
$seek_from = $seek_from_bytes = -1;
}
if ($seek_from !== -1 && $seek_from !== 0) {
if ($audio_only === '0') {
// audio_only was explicitly set to 0 - don't attempt to make further automatic investigations
} elseif ($flv_wrapper->getFirstVideoTimestamp() < 0) {
$audio_only = true;
}
list($bytes, $duration, $first_tag_byte, $to_byte) = $flv_wrapper->clip(0, -1, $audio_only);
list($bytes, $duration, $from_byte, $to_byte, $seek_from_timestamp) = $flv_wrapper->clip($seek_from, -1, $audio_only);
$seek_from_bytes = myFlvHandler::FLV_HEADER_SIZE + $flv_wrapper->getMetadataSize($audio_only) + $from_byte - $first_tag_byte;
}
// the direct path without a cdn is "http://s3kaltura.s3.amazonaws.com".$entry->getDataPath();
$extStorageUrl = $entry->getExtStorageUrl();
if ($extStorageUrl && substr_count($extStorageUrl, 's3kaltura')) {
// if for some reason we didnt set our accurate $seek_from_timestamp reset it to the requested seek_from
if ($seek_from_timestamp == -1) {
$seek_from_timestamp = $seek_from;
示例12: convertPptToSwf
/**
* This will queue a batch job for converting the document file to swf
* Returns the URL where the new swf will be available
*
* @action convertPptToSwf
* @param string $entryId
* @return string
*/
function convertPptToSwf($entryId)
{
$dbEntry = entryPeer::retrieveByPK($entryId);
if (!$dbEntry || $dbEntry->getType() != KalturaEntryType::DOCUMENT) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$flavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
if (is_null($flavorAsset) || !$flavorAsset->isLocalReadyStatus()) {
throw new KalturaAPIException(KalturaErrors::ORIGINAL_FLAVOR_ASSET_IS_MISSING);
}
$sync_key = null;
$sync_key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if (!kFileSyncUtils::file_exists($sync_key)) {
// if not found local file - perhaps wasn't created here and wasn't synced yet
// try to see if remote exists - and proxy the request if it is.
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($sync_key, true, true);
if (!$local) {
$remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrl($fileSync);
kFileUtils::dumpApiRequest($remoteDCHost);
}
KalturaLog::log("convertPptToSwf sync key doesn't exists");
return;
}
$flavorParams = myConversionProfileUtils::getFlavorParamsFromFileFormat($dbEntry->getPartnerId(), flavorParams::CONTAINER_FORMAT_SWF);
$flavorParamsId = $flavorParams->getId();
$puserId = $this->getKuser()->getPuserId();
$err = "";
kBusinessPreConvertDL::decideAddEntryFlavor(null, $dbEntry->getId(), $flavorParamsId, $err);
$downloadPath = $dbEntry->getDownloadUrl();
//TODO: once api_v3 will support parameters with '/' instead of '?', we can change this to war with api_v3
return $downloadPath . '/direct_serve/true/type/download/forceproxy/true/format/swf';
}
示例13: copyEntry
//.........这里部分代码省略.........
$newEntry->setDataContent($toPlaylistXml->asXML());
break;
}
}
if ($shouldCopyDataForNonClip || $shouldCopyDataForClip) {
// copy the data
$from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
// replaced__getDataPath
$to = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
// replaced__getDataPath
KalturaLog::log("copyEntriesByType - copying entry data [" . $from . "] to [" . $to . "]");
kFileSyncUtils::softCopy($from, $to);
}
$ismFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
if (kFileSyncUtils::fileSync_exists($ismFrom)) {
$ismTo = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
KalturaLog::log("copying entry ism [" . $ismFrom . "] to [" . $ismTo . "]");
kFileSyncUtils::softCopy($ismFrom, $ismTo);
}
$ismcFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
if (kFileSyncUtils::fileSync_exists($ismcFrom)) {
$ismcTo = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
KalturaLog::log("copying entry ism [" . $ismcFrom . "] to [" . $ismcTo . "]");
kFileSyncUtils::softCopy($ismcFrom, $ismcTo);
}
$from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
// replaced__getThumbnailPath
$considerCopyThumb = true;
// if entry is image - data is thumbnail, and it was copied
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$considerCopyThumb = false;
}
// if entry is not clip, and there is no file in both DCs - nothing to copy
if ($entry->getType() != entryType::MEDIA_CLIP && !kFileSyncUtils::file_exists($from, true)) {
$considerCopyThumb = false;
}
if ($considerCopyThumb) {
$skipThumb = false;
// don't attempt to copy a thumbnail for images - it's the same as the data which was just created
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO) {
// check if audio entry has real thumb, if not - don't copy thumb.
$originalFileSync = kFileSyncUtils::getOriginFileSyncForKey($from, false);
if (!$originalFileSync) {
$skipThumb = true;
}
}
if (!$skipThumb) {
$to = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
// replaced__getThumbnailPath
KalturaLog::log("copyEntriesByType - copying entry thumbnail [" . $from . "] to [" . $to . "]");
kFileSyncUtils::softCopy($from, $to);
}
}
// added by Tan-Tan 12/01/2010 to support falvors copy
$sourceAssets = assetPeer::retrieveByEntryId($entry->getId());
foreach ($sourceAssets as $sourceAsset) {
$sourceAsset->copyToEntry($newEntry->getId(), $newEntry->getPartnerId());
}
// copy relationships to categories
KalturaLog::debug('Copy relationships to categories from entry [' . $entry->getId() . '] to entry [' . $newEntry->getId() . ']');
$c = KalturaCriteria::create(categoryEntryPeer::OM_CLASS);
$c->addAnd(categoryEntryPeer::ENTRY_ID, $entry->getId());
$c->addAnd(categoryEntryPeer::STATUS, CategoryEntryStatus::ACTIVE, Criteria::EQUAL);
$c->addAnd(categoryEntryPeer::PARTNER_ID, $entry->getPartnerId());
categoryEntryPeer::setUseCriteriaFilter(false);
$categoryEntries = categoryEntryPeer::doSelect($c);
示例14: convertPptToSwf
/**
* This will queue a batch job for converting the document file to swf
* Returns the URL where the new swf will be available
*
* @action convertPptToSwf
* @param string $entryId
* @return string
*/
function convertPptToSwf($entryId)
{
$dbEntry = entryPeer::retrieveByPK($entryId);
if (!$dbEntry || $dbEntry->getType() != KalturaEntryType::DOCUMENT) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
assetPeer::resetInstanceCriteriaFilter();
$flavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
if (is_null($flavorAsset) || $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) {
throw new KalturaAPIException(KalturaErrors::ORIGINAL_FLAVOR_ASSET_IS_MISSING);
}
$sync_key = null;
$sync_key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if (!kFileSyncUtils::file_exists($sync_key)) {
// if not found local file - perhaps wasn't created here and wasn't synced yet
// try to see if remote exists - and proxy the request if it is.
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($sync_key, true, true);
if (!$local) {
// take input params and add to URL
$queryArr = array('service' => 'document', 'action' => 'convertPptToSwf', 'entryId' => $entryId, 'format' => $this->params["format"], 'ks' => $this->getKs()->toSecureString());
$get_query = http_build_query($queryArr, '', '&');
$remote_url = kDataCenterMgr::getRedirectExternalUrl($fileSync, $_SERVER['REQUEST_URI']);
$url = strpos($remote_url, '?') === FALSE ? $remote_url . '?' . $get_query : $remote_url . '&' . $get_query;
// prxoy request to other DC
KalturaLog::log(__METHOD__ . ": redirecting to [{$url}]");
kFile::dumpUrl($url);
}
KalturaLog::log("convertPptToSwf sync key doesn't exists");
return;
}
$flavorParams = myConversionProfileUtils::getFlavorParamsFromFileFormat($dbEntry->getPartnerId(), flavorParams::CONTAINER_FORMAT_SWF);
$flavorParamsId = $flavorParams->getId();
$puserId = $this->getKuser()->getPuserId();
$err = "";
kBusinessPreConvertDL::decideAddEntryFlavor(null, $dbEntry->getId(), $flavorParamsId, $err);
$downloadPath = $dbEntry->getDownloadUrl();
//TODO: once api_v3 will support parameters with '/' instead of '?', we can change this to war with api_v3
return $downloadPath . '/direct_serve/true/type/download/forceproxy/true/format/swf';
}
示例15: executeImpl
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
{
$kshowId = $this->getP("kshow_id");
$numberOfVersions = $this->getP("number_of_versions", 5);
// must be int and not more than 50
$numberOfVersions = (int) $numberOfVersions;
$numberOfVersions = min($numberOfVersions, 50);
$kshow = kshowPeer::retrieveByPK($kshowId);
if (!$kshow) {
$this->addError(APIErrors::KSHOW_DOES_NOT_EXISTS);
return;
}
$showEntry = $kshow->getShowEntry();
if (!$showEntry) {
$this->addError(APIErrors::ROUGHCUT_NOT_FOUND);
return;
}
$sync_key = $showEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
$showEntryDataPath = kFileSyncUtils::getLocalFilePathForKey($sync_key);
$versionsInfoFilePath = $showEntryDataPath . '.info';
$lastVersionDoc = new KDOMDocument();
$lastVersionDoc->loadXML(kFileSyncUtils::file_get_contents($sync_key, true, false));
$lastVersion = myContentStorage::getVersion($showEntryDataPath);
// check if we need to refresh the data in the info file
$refreshInfoFile = true;
if (file_exists($versionsInfoFilePath)) {
$versionsInfoDoc = new KDOMDocument();
$versionsInfoDoc->load($versionsInfoFilePath);
$lastVersionInInfoFile = kXml::getLastElementAsText($versionsInfoDoc, "ShowVersion");
if ($lastVersionInInfoFile && $lastVersion == $lastVersionInInfoFile) {
$refreshInfoFile = false;
} else {
$refreshInfoFile = true;
}
} else {
$refreshInfoFile = true;
}
// refresh or create the data in the info file
if ($refreshInfoFile) {
$versionsInfoDoc = new KDOMDocument();
$xmlElement = $versionsInfoDoc->createElement("xml");
// start from the first edited version (100001) and don't use 100000
for ($i = myContentStorage::MIN_OBFUSCATOR_VALUE + 1; $i <= $lastVersion; $i++) {
$version_sync_key = $showEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $i);
if (kFileSyncUtils::file_exists($version_sync_key, false)) {
$xmlContent = kFileSyncUtils::file_get_contents($version_sync_key);
//echo "[" . htmlspecialchars( $xmlContent ) . "]<br>";
$xmlDoc = new KDOMDocument();
$xmlDoc->loadXML($xmlContent);
$elementToCopy = kXml::getFirstElement($xmlDoc, "MetaData");
//echo "[$i]";
$elementCloned = $elementToCopy->cloneNode(true);
$elementImported = $versionsInfoDoc->importNode($elementCloned, true);
$xmlElement->appendChild($elementImported);
}
}
$versionsInfoDoc->appendChild($xmlElement);
kFile::setFileContent($versionsInfoFilePath, $versionsInfoDoc->saveXML());
// FileSync OK - created a temp file on DC's disk
}
$metadataNodes = $versionsInfoDoc->getElementsByTagName("MetaData");
$count = 0;
$versionsInfo = array();
for ($i = $metadataNodes->length - 1; $i >= 0; $i--) {
$metadataNode = $metadataNodes->item($i);
$node = kXml::getFirstElement($metadataNode, "ShowVersion");
$showVersion = $node ? $node->nodeValue : "";
$node = kXml::getFirstElement($metadataNode, "PuserId");
$puserId = $node ? $node->nodeValue : "";
$node = kXml::getFirstElement($metadataNode, "ScreenName");
$screenName = $node ? $node->nodeValue : "";
$node = kXml::getFirstElement($metadataNode, "UpdatedAt");
$updatedAt = $node ? $node->nodeValue : "";
$versionsInfo[] = array("version" => $showVersion, "puserId" => $puserId, "screenName" => $screenName, "updatedAt" => $updatedAt);
$count++;
if ($count >= $numberOfVersions) {
break;
}
}
$this->addMsg("show_versions", $versionsInfo);
}