public function setMetadata($kshow, $content, $override_existing = true, $total_duration = null, $specific_version = null) { if ($this->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW) { return null; } // TODO - better to call this with slight modifications //myMetadataUtils::setMetadata ($content, $kshow, $this , $override_existing ); if ($specific_version == null) { // increment the counter of the file $this->setData(parent::getData()); } // check that the file of the desired version really exists // $content_dir = myContentStorage::getFSContentRootPath(); // $file_name = $content_dir . $this->getDataPath( $specific_version ); // replaced__getDataPath $sync_key = $this->getSyncKey(self::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $specific_version); if ($override_existing || !kFileSyncUtils::file_exists($sync_key, false)) { $duration = $total_duration ? $total_duration : myMetadataUtils::getDuration($content); $this->setLengthInMsecs($duration * 1000); $total_duration = null; $editor_type = null; $version = myContentStorage::getVersion(kFileSyncUtils::getReadyLocalFilePathForKey($sync_key)); $fixed_content = myFlvStreamer::fixMetadata($content, $version, $total_duration, $editor_type); $this->setModifiedAt(time()); // update the modified_at date $this->save(); $sync_key = $this->getSyncKey(self::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version); // TODO: here we assume we are UPDATING an exising version of the file - make sure all the following functions are tolerant. kFileSyncUtils::file_put_contents($sync_key, $fixed_content, false); // replaced__setFileContent // update the roughcut_entry table if ($kshow != null) { $kshow_id = $kshow->getId(); } else { $kshow_id = $this->getKshowId(); } $all_entries_for_roughcut = myMetadataUtils::getAllEntries($fixed_content); roughcutEntry::updateRoughcut($this->getId(), $version, $kshow_id, $all_entries_for_roughcut); return; } else { // no need to save changes - why increment the count if failed ?? return -1; } }
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); }