Exemple #1
0
 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;
     }
 }