public static function setMetadata($content, $kshow, $show_entry, $ignore_current = false, $version_info = null) { $xml_content = ""; $show_entry_data_key = $show_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); $current_content = $show_entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW ? "" : kFileSyncUtils::file_get_contents($show_entry_data_key); if ($ignore_current) { $current_content = ""; } $update_kshow = false; // compare the content and store only if different if ($content != $current_content) { $show_entry->setData("metadata.xml"); // re-create data key (to get latest version) $show_entry_data_key = $show_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); //$version = myContentStorage::getVersion($file_name); //$comments = "file path: " . $file_name . "\n"; $comments = "version: " . $show_entry_data_key->version . "\n"; $total_duration = 0; $editor_type = null; $content = myFlvStreamer::fixMetadata($content, $show_entry_data_key->version, $total_duration, $editor_type); // TODO - make fixMetadata a more generic funciton to return the editorType as well // save info file about the version if (isset($version_info)) { $content = self::addVersionInfo($content, $version_info); } //fixme $content = myFlvStreamer::modifiedByKeditor ( $content ); // total_duration is in seconds with 2 digits after the decimal point $show_entry->setLengthInMsecs($total_duration * 1000); $show_entry->setMediaType(entry::ENTRY_MEDIA_TYPE_SHOW); $show_entry->setEditorType($editor_type); $show_entry->setModifiedAt(time()); // update the modified_at date $show_entry->save(); kFileSyncUtils::file_put_contents($show_entry_data_key, $content, true); $xml_content = kFileSyncUtils::file_get_contents($show_entry_data_key); // replaced__getFileContent $update_kshow = true; $show_entry_id = $show_entry->getId(); // update the roughcut_entry table $all_entries_for_roughcut = self::getAllEntries($content); roughcutEntry::updateRoughcut($show_entry->getId(), $show_entry->getVersion(), $show_entry->getKshowId(), $all_entries_for_roughcut); $xml_content = $content; } else { $xml_content = $current_content; $comments = "old and new files are the same"; } if (!$kshow->getHasRoughcut() && $kshow->getIntroId() != $show_entry->getId()) { $kshow->setHasRoughcut(true); $update_kshow = true; } myStatisticsMgr::incKshowUpdates($kshow); $kshow->save(); return array($xml_content, $comments, $update_kshow); }
public function fixMetadata($increment_version = true, $content = null, $total_duration = null, $specific_version = null) { // check that the file of the desired version really exists $content_dir = myContentStorage::getFSContentRootPath(); if (!$content) { $content = $this->getMetadata($specific_version); } if ($increment_version) { // increment the counter of the file $this->setData(parent::getData()); } $file_name = kFileSyncUtils::getLocalFilePathForKey($this->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $specific_version)); // replaced__getDataPath $duration = $total_duration ? $total_duration : myMetadataUtils::getDuration($content); $this->setLengthInMsecs($duration * 1000); $total_duration = null; $editor_type = null; $version = myContentStorage::getVersion($file_name); $fixed_content = myFlvStreamer::fixMetadata($content, $version, $total_duration, $editor_type); $this->save(); $sync_key = $this->getSyncKey(self::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version); kFileSyncUtils::file_put_contents($sync_key, $fixed_content, false); // replaced__setFileContent return $fixed_content; }