本文整理汇总了PHP中kFileSyncUtils::file_put_contents方法的典型用法代码示例。如果您正苦于以下问题:PHP kFileSyncUtils::file_put_contents方法的具体用法?PHP kFileSyncUtils::file_put_contents怎么用?PHP kFileSyncUtils::file_put_contents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kFileSyncUtils
的用法示例。
在下文中一共展示了kFileSyncUtils::file_put_contents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copyLiveMetadata
protected function copyLiveMetadata(baseEntry $object, $liveEntryId)
{
$recordedEntryId = $object->getId();
$partnerId = $object->getPartnerId();
$metadataProfiles = MetadataProfilePeer::retrieveAllActiveByPartnerId($partnerId, MetadataObjectType::ENTRY);
foreach ($metadataProfiles as $metadataProfile) {
$originMetadataObj = MetadataPeer::retrieveByObject($metadataProfile->getId(), MetadataObjectType::ENTRY, $liveEntryId);
if ($originMetadataObj) {
$metadataProfileId = $metadataProfile->getId();
$metadataProfileVersion = $metadataProfile->getVersion();
$destMetadataObj = new Metadata();
$destMetadataObj->setPartnerId($partnerId);
$destMetadataObj->setMetadataProfileId($metadataProfileId);
$destMetadataObj->setMetadataProfileVersion($metadataProfileVersion);
$destMetadataObj->setObjectType(MetadataObjectType::ENTRY);
$destMetadataObj->setObjectId($recordedEntryId);
$destMetadataObj->setStatus(KalturaMetadataStatus::VALID);
$originMetadataKey = $originMetadataObj->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA);
$originXml = kFileSyncUtils::file_get_contents($originMetadataKey, true, false);
// validate object exists
$object = kMetadataManager::getObjectFromPeer($destMetadataObj);
if ($object) {
$destMetadataObj->save();
} else {
KalturaLog::err('invalid object type');
continue;
}
$destMetadataKey = $destMetadataObj->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA);
kFileSyncUtils::file_put_contents($destMetadataKey, $originXml);
}
}
}
示例2: createMetadataProfile
function createMetadataProfile($version, $versionToXsdMap)
{
$metadataProfile = new MetadataProfile();
$metadataProfile->setPartnerId(99);
$metadataProfile->setStatus(MetadataProfile::STATUS_ACTIVE);
$metadataProfile->setName('Tvinci ingest v' . $version);
$metadataProfile->setSystemName('TvinciIngestV' . $version);
$metadataProfile->setDescription('Tvinci ingest schema version ' . $version);
$metadataProfile->setObjectType(MetadataObjectType::ENTRY);
$metadataProfile->setRequiredCopyTemplatePermissions(FEATURE_TVINCI_INGEST_BASE . $version);
$metadataProfile->save();
$xsdData = $versionToXsdMap[$version];
$key = $metadataProfile->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_DEFINITION);
kFileSyncUtils::file_put_contents($key, $xsdData);
kMetadataManager::parseProfileSearchFields($metadataProfile->getPartnerId(), $metadataProfile);
}
示例3: postSave
public function postSave(PropelPDO $con = null)
{
if ($this->xsdData) {
$key = $this->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_DEFINITION);
kFileSyncUtils::file_put_contents($key, $this->xsdData);
kMetadataManager::parseProfileSearchFields($this->getPartnerId(), $this);
}
if ($this->viewsData) {
$key = $this->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_VIEWS);
kFileSyncUtils::file_put_contents($key, $this->viewsData);
}
if ($this->xsltData) {
$key = $this->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_XSLT);
kFileSyncUtils::file_put_contents($key, $this->xsltData);
}
return parent::postSave($con);
}
示例4: createMetadataProfile
function createMetadataProfile()
{
$metadataProfile = new MetadataProfile();
$metadataProfile->setPartnerId(99);
$metadataProfile->setStatus(MetadataProfile::STATUS_ACTIVE);
$metadataProfile->setName('Live Stream Monitoring');
$metadataProfile->setSystemName('LiveMonitor');
$metadataProfile->setDescription('Email notification flag indicating a 24/7 live-entry should be monitored.');
$metadataProfile->setObjectType(MetadataObjectType::ENTRY);
$metadataProfile->setRequiredCopyTemplatePermissions(FEATURE_KALTURA_LIVE_MONITOR);
$metadataProfile->save();
$xsdData = '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Monitor" minOccurs="1" maxOccurs="1">
<xsd:annotation>
<xsd:documentation></xsd:documentation>
<xsd:appinfo>
<label>Monitor 24/7</label>
<key>monitor</key>
<searchable>true</searchable>
<description>Send E-mail notification if live-stream broadcast stopped</description>
</xsd:appinfo>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="listType">
<xsd:enumeration value="on"/>
<xsd:enumeration value="off"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="listType">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:schema>';
$key = $metadataProfile->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_DEFINITION);
kFileSyncUtils::file_put_contents($key, $xsdData);
kMetadataManager::parseProfileSearchFields($metadataProfile->getPartnerId(), $metadataProfile);
}
示例5: executeImpl
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
{
if (!$puser_kuser) {
$this->addError(APIErrors::INVALID_USER_ID, $puser_id);
return;
}
$entry_id = $this->getPM("entry_id");
$entry = entryPeer::retrieveByPK($entry_id);
// TODO - verify the user is allowed to modify the entry
if ($entry->getKshowId() === kshow::SANDBOX_ID) {
$this->addError(APIErrors::SANDBOX_ALERT);
return;
}
$entry->setThumbnail(".jpg");
$entry->setCreateThumb(false);
$entry->save();
if (isset($HTTP_RAW_POST_DATA)) {
$thumb_data = $HTTP_RAW_POST_DATA;
} else {
$thumb_data = file_get_contents("php://input");
}
$thumb_data_size = strlen($thumb_data);
$fileSyncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
$fileSync = FileSync::createForFileSyncKey($fileSyncKey);
kFileSyncUtils::file_put_contents($fileSyncKey, $thumb_data);
// update the metadata in case of a roughcut
if ($entry->getType() == entryType::MIX) {
$sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
$xml_doc = new DOMDocument();
$xml_doc->loadXML(kFileSyncUtils::file_get_contents($sync_key));
if (myMetadataUtils::updateThumbUrl($xml_doc, $entry->getThumbnailUrl())) {
$entry->setMetadata(null, $xml_doc->saveXML(), true, null, null);
//$entry->getVersion() );
}
myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE_THUMBNAIL, $entry);
}
$this->res = $entry->getBigThumbnailUrl();
$wrapper = objectWrapperBase::getWrapperClass($entry, objectWrapperBase::DETAIL_LEVEL_REGULAR);
$wrapper->removeFromCache("entry", $entry->getId());
$this->addMsg("entry", $wrapper);
}
示例6: postSave
public function postSave(PropelPDO $con = null)
{
parent::postSave($con);
if ($this->xslModified && $this->xsl && $this->getFeedId()) {
KalturaLog::debug("loads syndication feed id [" . $this->getFeedId() . "]");
$syndicationFeed = syndicationFeedPeer::retrieveByPK($this->getFeedId());
KalturaLog::debug("syndication feed id [" . $syndicationFeed->getId() . "] syndication feed type [" . get_class($syndicationFeed) . "]");
if ($syndicationFeed && $syndicationFeed instanceof genericSyndicationFeed) {
KalturaLog::log("Updating syndication feed xsl");
$syndicationFeed->setType(syndicationFeedType::KALTURA_XSLT);
$syndicationFeed->incrementVersion();
$syndicationFeed->save();
$syncKey = $syndicationFeed->getSyncKey(genericSyndicationFeed::FILE_SYNC_SYNDICATION_FEED_XSLT);
kFileSyncUtils::file_put_contents($syncKey, $this->xsl, false);
$this->xslModified = false;
}
}
}
示例7: setObjectContent
private function setObjectContent($assetObject, $content, $accuracy = null, $format = null, $shouldSetTranscriptFileName = false)
{
$assetObject->incrementVersion();
$ext = "txt";
if ($format) {
if ($format == "DFXP") {
$ext = "xml";
}
if ($format == "SRT") {
$ext = "srt";
}
}
$assetObject->setFileExt($ext);
$assetObject->save();
$syncKey = $assetObject->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
kFileSyncUtils::file_put_contents($syncKey, $content);
$finalPath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
$assetObject->setSize(kFile::fileSize($finalPath));
if ($shouldSetTranscriptFileName && !$assetObject->getFileName()) {
$language = str_replace(" ", "", $assetObject->getLanguage());
$patterns = array("{entryId}", "{language}");
$replacements = array($assetObject->getEntryId(), $language);
$fileName = str_replace($patterns, $replacements, self::FILE_NAME_PATTERN);
$assetObject->setFileName($fileName);
}
if (!$accuracy) {
$accuracy = self::DEFAULT_ACCURACY;
}
$assetObject->setAccuracy($accuracy);
$assetObject->setStatus(AttachmentAsset::ASSET_STATUS_READY);
$assetObject->save();
}
示例8: updateAction
/**
* Update Syndication Feed by ID
*
* @action update
* @param string $id
* @param KalturaBaseSyndicationFeed $syndicationFeed
* @return KalturaBaseSyndicationFeed
*/
public function updateAction($id, KalturaBaseSyndicationFeed $syndicationFeed)
{
$syndicationFeedDB = syndicationFeedPeer::retrieveByPK($id);
if (!$syndicationFeedDB) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $id);
}
if ($syndicationFeed instanceof KalturaGenericXsltSyndicationFeed && $syndicationFeed->xslt != null) {
$syndicationFeed->validateXslt();
$syndicationFeedDB->incrementVersion();
$syndicationFeedDB->save();
}
$syndicationFeed->type = null;
if ($syndicationFeed instanceof KalturaGenericXsltSyndicationFeed && $syndicationFeed->xslt != null) {
$key = $syndicationFeedDB->getSyncKey(genericSyndicationFeed::FILE_SYNC_SYNDICATION_FEED_XSLT);
kFileSyncUtils::file_put_contents($key, $syndicationFeed->xslt);
}
$syndicationFeed = $syndicationFeed->toUpdatableObject($syndicationFeedDB, array('type'));
$syndicationFeedDB->save();
$syndicationFeed = KalturaSyndicationFeedFactory::getInstanceByType($syndicationFeedDB->getType());
$syndicationFeed->fromObject($syndicationFeedDB);
return $syndicationFeed;
}
示例9: updateImpl
function updateImpl($id, $xmlData = null, $version = null)
{
$dbMetadata = MetadataPeer::retrieveByPK($id);
if (!$dbMetadata) {
throw new KalturaAPIException(MetadataErrors::METADATA_NOT_FOUND, $id);
}
if ($version && $dbMetadata->getVersion() != $version) {
throw new KalturaAPIException(MetadataErrors::INVALID_METADATA_VERSION, $dbMetadata->getVersion());
}
$dbMetadataProfile = MetadataProfilePeer::retrieveByPK($dbMetadata->getMetadataProfileId());
if (!$dbMetadataProfile) {
throw new KalturaAPIException(MetadataErrors::INVALID_METADATA_PROFILE, $dbMetadata->getMetadataProfileId());
}
$previousVersion = null;
if ($dbMetadata->getStatus() == Metadata::STATUS_VALID) {
$previousVersion = $dbMetadata->getVersion();
}
if ($xmlData) {
// if a metadata xslt is defined on the metadata profile - transform the given metadata
$xmlDataTransformed = $this->transformMetadata($dbMetadata->getMetadataProfileId(), $xmlData);
if ($xmlDataTransformed) {
$xmlData = $xmlDataTransformed;
}
$errorMessage = '';
if (!kMetadataManager::validateMetadata($dbMetadata->getMetadataProfileId(), $xmlData, $errorMessage)) {
// if metadata profile is transforming, and metadata profile version is not the latest, try to validate againts previous version
if ($dbMetadataProfile->getStatus() != MetadataProfile::STATUS_TRANSFORMING || $dbMetadata->getMetadataProfileVersion() >= $dbMetadataProfile->getVersion()) {
throw new KalturaAPIException(MetadataErrors::INVALID_METADATA_DATA, $errorMessage);
}
// validates against previous version
$errorMessagePrevVersion = '';
if (!kMetadataManager::validateMetadata($dbMetadata->getMetadataProfileId(), $xmlData, $errorMessagePrevVersion, true)) {
KalturaLog::err("Failed to validate metadata object [{$id}] against metadata profile previous version [" . $dbMetadata->getMetadataProfileVersion() . "] error: {$errorMessagePrevVersion}");
// throw the error with the original error message
throw new KalturaAPIException(MetadataErrors::INVALID_METADATA_DATA, $errorMessage);
}
} else {
$dbMetadata->setMetadataProfileVersion($dbMetadataProfile->getVersion());
}
$key = $dbMetadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA);
if (!kFileSyncUtils::compareContent($key, $xmlData)) {
$dbMetadata->incrementVersion();
$key = $dbMetadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA);
kFileSyncUtils::file_put_contents($key, $xmlData);
$dbMetadata->save();
kEventsManager::raiseEvent(new kObjectDataChangedEvent($dbMetadata, $previousVersion));
} else {
KalturaLog::info("XML data MD5 matches current filesync content MD5. Update is not necessary.");
//adding this save() in order to save the metadata profile version field in case there are no diffrences
$dbMetadata->save();
}
}
$metadata = new KalturaMetadata();
$metadata->fromObject($dbMetadata, $this->getResponseProfile());
return $metadata;
}
示例10: updateAction
/**
* Update Syndication Feed by ID
*
* @action update
* @param string $id
* @param KalturaBaseSyndicationFeed $syndicationFeed
* @return KalturaBaseSyndicationFeed
* @throws KalturaErrors::INVALID_FEED_ID
*/
public function updateAction($id, KalturaBaseSyndicationFeed $syndicationFeed)
{
$syndicationFeedDB = syndicationFeedPeer::retrieveByPK($id);
if (!$syndicationFeedDB) {
throw new KalturaAPIException(KalturaErrors::INVALID_FEED_ID, $id);
}
$syndicationFeed->validateStorageId($this->getPartnerId());
$syndicationFeed->toUpdatableObject($syndicationFeedDB, array('type'));
if ($syndicationFeed instanceof KalturaGenericXsltSyndicationFeed && $syndicationFeed->xslt != null) {
if (!$syndicationFeedDB instanceof genericSyndicationFeed) {
throw new KalturaAPIException(KalturaErrors::INVALID_FEED_TYPE, get_class($syndicationFeedDB));
}
$syndicationFeedDB->incrementVersion();
}
$syndicationFeedDB->save();
if ($syndicationFeed instanceof KalturaGenericXsltSyndicationFeed && $syndicationFeed->xslt != null) {
$key = $syndicationFeedDB->getSyncKey(genericSyndicationFeed::FILE_SYNC_SYNDICATION_FEED_XSLT);
kFileSyncUtils::file_put_contents($key, $syndicationFeed->xslt);
}
$syndicationFeed->type = null;
$syndicationFeed = KalturaSyndicationFeedFactory::getInstanceByType($syndicationFeedDB->getType());
$syndicationFeed->fromObject($syndicationFeedDB, $this->getResponseProfile());
return $syndicationFeed;
}
示例11: addFromUrlAction
/**
* @action addFromUrl
* @param string $entryId
* @param string $url
* @return KalturaThumbAsset
*
* @deprecated use thumbAsset.add and thumbAsset.setContent instead
*/
public function addFromUrlAction($entryId, $url)
{
$dbEntry = entryPeer::retrieveByPK($entryId);
if (!$dbEntry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$ext = pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_EXTENSION);
$dbThumbAsset = new thumbAsset();
$dbThumbAsset->setPartnerId($dbEntry->getPartnerId());
$dbThumbAsset->setEntryId($dbEntry->getId());
$dbThumbAsset->setStatus(thumbAsset::ASSET_STATUS_QUEUED);
$dbThumbAsset->setFileExt($ext);
$dbThumbAsset->incrementVersion();
$dbThumbAsset->save();
$syncKey = $dbThumbAsset->getSyncKey(thumbAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
kFileSyncUtils::file_put_contents($syncKey, file_get_contents($url));
$finalPath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
list($width, $height, $type, $attr) = getimagesize($finalPath);
$dbThumbAsset->setWidth($width);
$dbThumbAsset->setHeight($height);
$dbThumbAsset->setSize(filesize($finalPath));
$dbThumbAsset->setStatus(thumbAsset::ASSET_STATUS_READY);
$dbThumbAsset->save();
$thumbAssets = new KalturaThumbAsset();
$thumbAssets->fromObject($dbThumbAsset);
return $thumbAssets;
}
示例12: addMetadataWithProfilesSystemNames
//.........这里部分代码省略.........
$xmlDataArray = array();
//Construct mapping of all metadata profile system names, their fields and the field values.
foreach ($data as $key => $value) {
if (strpos($key, self::BULK_UPLOAD_METADATA_FIELD_PREFIX) === 0) {
$prefix = null;
$metadataProfileSystemName = null;
$metadataProfileFieldName = null;
list($prefix, $metadataProfileSystemName, $metadataProfileFieldName) = explode(self::BULK_UPLOAD_METADATA_SYSTEMNAME_SEPARATOR, $key);
if (!$prefix || !$metadataProfileSystemName || !$metadataProfileFieldName) {
$errorMessage = "Unexpected key structure. Expected metadata::ProfileSystemName::FieldSystemName.";
KalturaLog::err($errorMessage);
self::addBulkUploadResultDescription($object, $object->getBulkUploadId(), $errorMessage);
continue;
}
if (!isset($newFieldValuesMap[$metadataProfileSystemName])) {
$newFieldValuesMap[$metadataProfileSystemName] = array();
}
$newFieldValuesMap[$metadataProfileSystemName][$metadataProfileFieldName] = $value;
}
}
foreach ($newFieldValuesMap as $metadataProfileSystemName => $fieldsArray) {
/* @var array $fieldsArray */
if (!$fieldsArray || !count($fieldsArray)) {
continue;
}
$metadataProfile = MetadataProfilePeer::retrieveBySystemName($metadataProfileSystemName, $object->getPartnerId());
if (!$metadataProfile) {
$errorMessage = "Metadata profile with system name [{$metadataProfileSystemName}] could not be found.";
KalturaLog::err($errorMessage);
self::addBulkUploadResultDescription($object, $object->getBulkUploadId(), $errorMessage);
continue;
}
if ($metadataProfile->getObjectType() != kMetadataManager::getTypeNameFromObject($object)) {
$errorMessage = "Metadata profile [{$metadataProfileSystemName}] object type [" . $metadataProfile->getObjectType() . "] is not compatible with object type [" . kMetadataManager::getTypeNameFromObject($object) . "]";
KalturaLog::err($errorMessage);
self::addBulkUploadResultDescription($object, $object->getBulkUploadId(), $errorMessage);
continue;
}
$metadataProfileId = $metadataProfile->getId();
$xml = new DOMDocument();
$metadataProfileFields = array();
MetadataProfileFieldPeer::setUseCriteriaFilter(false);
$tmpMetadataProfileFields = MetadataProfileFieldPeer::retrieveByMetadataProfileId($metadataProfileId);
MetadataProfileFieldPeer::setUseCriteriaFilter(true);
foreach ($tmpMetadataProfileFields as $metadataProfileField) {
/* @var $metadataProfileField MetadataProfileField */
$metadataProfileFields[$metadataProfileField->getKey()] = $metadataProfileField;
}
foreach ($fieldsArray as $fieldSysName => $fieldValue) {
if (!isset($metadataProfileFields[$fieldSysName])) {
$errorMessage = "Metadata profile field with system name [{$fieldSysName}] missing from metadata profile with id [{$metadataProfileId}]";
KalturaLog::err($errorMessage);
self::addBulkUploadResultDescription($object, $object->getBulkUploadId(), $errorMessage);
continue;
}
$metadataProfileField = $metadataProfileFields[$fieldSysName];
KalturaLog::debug("Found field [" . $metadataProfileField->getXpath() . "] for value [{$fieldValue}]");
$fieldValues = explode(self::BULK_UPLOAD_MULTI_VALUES_DELIMITER, $fieldValue);
foreach ($fieldValues as $fieldSingleValue) {
if ($fieldSingleValue) {
if ($metadataProfileField->getType() == MetadataSearchFilter::KMC_FIELD_TYPE_DATE && !is_numeric($fieldSingleValue)) {
$valueAsDate = self::parseFormatedDate($fieldSingleValue);
if (!$valueAsDate || !strlen($valueAsDate)) {
$errorMessage = "Could not parse date format [{$fieldValue}] for field [{$key}]";
KalturaLog::err($errorMessage);
self::addBulkUploadResultDescription($object, $object->getBulkUploadId(), $errorMessage);
continue;
}
$fieldSingleValue = $valueAsDate;
}
if ($metadataProfileField->getType() == MetadataSearchFilter::KMC_FIELD_TYPE_INT && !is_numeric($fieldSingleValue)) {
$errorMessage = "Could not parse int format [{$fieldSingleValue}] for field [{$key}]";
KalturaLog::err($errorMessage);
self::addBulkUploadResultDescription($object, $object->getBulkUploadId(), $errorMessage);
continue;
}
self::addXpath($xml, $metadataProfileField->getXpath(), $fieldSingleValue);
}
}
$dataFound = true;
if ($dataFound && $xml->hasChildNodes()) {
$xmlDataArray[$metadataProfileId] = $xml->saveXML($xml->firstChild);
$xmlDataArray[$metadataProfileId] = trim($xmlDataArray[$metadataProfileId], " \n\r\t");
}
}
}
foreach ($xmlDataArray as $metadataProfileId => $xmlData) {
$errorMessage = '';
if (!kMetadataManager::validateMetadata($metadataProfileId, $xmlData, $errorMessage)) {
self::addBulkUploadResultDescription($object, $object->getBulkUploadId(), $errorMessage);
continue;
}
$metadataProfile = MetadataProfilePeer::retrieveByPK($metadataProfileId);
$dbMetadata = self::createOrFindMetadataObject($object, $metadataProfile);
KalturaLog::debug("Metadata [" . $dbMetadata->getId() . "] saved [{$xmlData}]");
$key = $dbMetadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA);
kFileSyncUtils::file_put_contents($key, $xmlData);
kEventsManager::raiseEvent(new kObjectDataChangedEvent($dbMetadata));
}
}
示例13: updateAction
/**
* Update an existing metadata object
*
* @action update
* @param int $id
* @param KalturaMetadataProfile $metadataProfile
* @param string $xsdData XSD metadata definition
* @param string $viewsData UI views definition
* @return KalturaMetadataProfile
* @throws KalturaErrors::INVALID_OBJECT_ID
* @throws MetadataErrors::METADATA_UNABLE_TO_TRANSFORM
* @throws MetadataErrors::METADATA_TRANSFORMING
*/
function updateAction($id, KalturaMetadataProfile $metadataProfile, $xsdData = null, $viewsData = null)
{
$dbMetadataProfile = MetadataProfilePeer::retrieveByPK($id);
if (!$dbMetadataProfile) {
throw new KalturaAPIException(KalturaErrors::INVALID_OBJECT_ID, $id);
}
if ($dbMetadataProfile->getStatus() != MetadataProfile::STATUS_ACTIVE) {
throw new KalturaAPIException(MetadataErrors::METADATA_TRANSFORMING);
}
$dbMetadataProfile = $metadataProfile->toUpdatableObject($dbMetadataProfile);
$key = $dbMetadataProfile->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_DEFINITION);
$oldXsd = kFileSyncUtils::getLocalFilePathForKey($key);
$oldVersion = $dbMetadataProfile->getVersion();
if ($xsdData) {
$xsdData = html_entity_decode($xsdData);
$dbMetadataProfile->incrementVersion();
}
if (!is_null($viewsData)) {
$viewsData = html_entity_decode($viewsData);
$dbMetadataProfile->incrementViewsVersion();
}
if ($xsdData) {
$xsdPath = sys_get_temp_dir() . '/' . uniqid() . '.xsd';
file_put_contents($xsdPath, $xsdData);
try {
kMetadataManager::diffMetadataProfile($dbMetadataProfile, $oldVersion, $oldXsd, $dbMetadataProfile->getVersion(), $xsdPath);
} catch (kXsdException $e) {
throw new KalturaAPIException(MetadataErrors::METADATA_UNABLE_TO_TRANSFORM, $e->getMessage());
}
$dbMetadataProfile->save();
$key = $dbMetadataProfile->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_DEFINITION);
kFileSyncUtils::moveFromFile($xsdPath, $key);
} else {
$dbMetadataProfile->save();
}
if (!is_null($viewsData) && $viewsData != '') {
$key = $dbMetadataProfile->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_VIEWS);
kFileSyncUtils::file_put_contents($key, $viewsData);
}
kMetadataManager::parseProfileSearchFields($dbMetadataProfile);
$metadataProfile->fromObject($dbMetadataProfile);
return $metadataProfile;
}
示例14: addConvertIsmCollectionJob
//.........这里部分代码省略.........
$remoteUrl = $fileSync->getExternalUrl($entry->getId());
}
// increment entry version
$ismVersion = $entry->incrementIsmVersion();
$entry->save();
$fileName = $entry->generateFileName(0, $ismVersion);
// creates convert data
$convertCollectionData = new kConvertCollectionJobData();
$convertCollectionData->setSrcFileSyncLocalPath($localPath);
$convertCollectionData->setSrcFileSyncRemoteUrl($remoteUrl);
$convertCollectionData->setDestFileName($fileName);
$clipOffset = null;
$clipDuration = null;
// look for clipping params
foreach ($flavorParamsOutputs as $flavorParamsOutput) {
$clipOffset = $flavorParamsOutput->getClipOffset();
$clipDuration = $flavorParamsOutput->getClipDuration();
if (isset($clipOffset) || isset($clipDuration)) {
KalturaLog::log("Found clipping params: clipOffset({$clipOffset}),clipDuration({$clipDuration})");
break;
}
}
$bitrates = array();
$finalFlavorParamsOutputs = array();
// check bitrates duplications & update clipping params
foreach ($flavorParamsOutputs as $flavorParamsOutputIndex => $flavorParamsOutput) {
if (!isset($bitrates[$flavorParamsOutput->getVideoBitrate()])) {
$bitrates[$flavorParamsOutput->getVideoBitrate()] = array();
}
// if one of clip params exsits - update the object and db
if (isset($clipOffset)) {
$flavorParamsOutputs[$flavorParamsOutputIndex]->setClipOffset($clipOffset);
}
if (isset($clipDuration)) {
$flavorParamsOutputs[$flavorParamsOutputIndex]->setClipDuration($clipDuration);
}
if (isset($clipOffset) || isset($clipDuration)) {
$flavorParamsOutputs[$flavorParamsOutputIndex]->save();
}
$bitrates[$flavorParamsOutput->getVideoBitrate()][] = $flavorParamsOutput->getId();
$finalFlavorParamsOutputs[$flavorParamsOutput->getId()] = $flavorParamsOutput;
}
foreach ($bitrates as $bitrate => $flavorParamsOutputIds) {
if (count($flavorParamsOutputIds) == 1) {
// no bitrate dupliaction
continue;
}
$tempFlavorParamsOutputs = array();
foreach ($flavorParamsOutputIds as $index => $flavorParamsOutputId) {
$tempFlavorParamsOutputs[] = $finalFlavorParamsOutputs[$flavorParamsOutputId];
}
// sort the flavors by height
usort($tempFlavorParamsOutputs, array('kBusinessConvertDL', 'compareFlavorsByHeight'));
// increment the bitrate so it will be a bit different for each flavor
$index = 0;
foreach ($tempFlavorParamsOutputs as $flavorParamsOutput) {
$finalFlavorParamsOutputs[$flavorParamsOutput->getId()]->setVideoBitrate($bitrate + $index++);
}
}
foreach ($finalFlavorParamsOutputs as $flavorParamsOutput) {
$convertCollectionFlavorData = new kConvertCollectionFlavorData();
$convertCollectionFlavorData->setFlavorAssetId($flavorParamsOutput->getFlavorAssetId());
$convertCollectionFlavorData->setFlavorParamsOutputId($flavorParamsOutput->getId());
$convertCollectionFlavorData->setReadyBehavior($flavorParamsOutput->getReadyBehavior());
$convertCollectionFlavorData->setVideoBitrate($flavorParamsOutput->getVideoBitrate());
$convertCollectionFlavorData->setAudioBitrate($flavorParamsOutput->getAudioBitrate());
$convertCollectionFlavorData->setAudioBitrate($flavorParamsOutput->getAudioBitrate());
$convertCollectionData->addFlavor($convertCollectionFlavorData);
}
$currentConversionEngine = conversionEngineType::EXPRESSION_ENCODER3;
KalturaLog::log("Using conversion engine [{$currentConversionEngine}]");
if (!$dbConvertCollectionJob) {
// creats a child convert job
if ($parentJob) {
$dbConvertCollectionJob = $parentJob->createChild();
KalturaLog::log("Created from parent convert job with entry id [" . $dbConvertCollectionJob->getEntryId() . "]");
} else {
$dbConvertCollectionJob = new BatchJob();
$dbConvertCollectionJob->setEntryId($entry->getId());
$dbConvertCollectionJob->setPartnerId($entry->getPartnerId());
$dbConvertCollectionJob->save();
KalturaLog::log("Created from convert collection job with entry id [" . $dbConvertCollectionJob->getEntryId() . "]");
}
}
KalturaLog::log("Calling CDLProceessFlavorsForCollection with [" . count($finalFlavorParamsOutputs) . "] flavor params");
$xml = KDLWrap::CDLProceessFlavorsForCollection($finalFlavorParamsOutputs);
$xml = str_replace(KDLCmdlinePlaceholders::OutFileName, $fileName, $xml);
$syncKey = $dbConvertCollectionJob->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_CONFIG);
kFileSyncUtils::file_put_contents($syncKey, $xml);
$fileSync = kFileSyncUtils::getLocalFileSyncForKey($syncKey);
$remoteUrl = $fileSync->getExternalUrl($entry->getId());
$localPath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
$commandLines = array(conversionEngineType::EXPRESSION_ENCODER3 => KDLCmdlinePlaceholders::InFileName . ' ' . KDLCmdlinePlaceholders::ConfigFileName);
$commandLinesStr = flavorParamsOutput::buildCommandLinesStr($commandLines);
$convertCollectionData->setInputXmlLocalPath($localPath);
$convertCollectionData->setInputXmlRemoteUrl($remoteUrl);
$convertCollectionData->setCommandLinesStr($commandLinesStr);
$dbConvertCollectionJob->setFileSize(kFile::fileSize($convertCollectionData->getSrcFileSyncLocalPath()));
return kJobsManager::addJob($dbConvertCollectionJob, $convertCollectionData, BatchJobType::CONVERT_COLLECTION, $currentConversionEngine);
}
示例15: setConfFileImpl
private function setConfFileImpl($v, $file_suffix = null, $isClone = false)
{
// $file_name = $this->getConfFilePath($file_suffix );
if ($this->getCreationMode() == self::UI_CONF_CREATION_MODE_MANUAL) {
throw new Exception("Should not edit MANUAL ui_confs via the API!! Only via the SVN");
}
if ($file_suffix) {
$sync_key = $this->getSyncKey(self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES);
} else {
$sync_key = $this->getSyncKey(self::FILE_SYNC_UICONF_SUB_TYPE_DATA);
}
$this->setUpdatedAt(time());
// make sure will be updated in the DB
if (version_compare($this->getSwfUrlVersion(), "2.5", ">=")) {
$v = str_replace('.entryName}', '.name}', $v);
}
// This is only called on Save, after parent::save(), so ID is present.
kFileSyncUtils::file_put_contents($sync_key, $v);
//replaced__setFileContent
}