/** * Deletes a media work's attached media files and the actual entry in kaltura. */ public function delete_media_work($media_work_deleter) { $e = new entity($media_work_deleter->get_value('id')); $es = new entity_selector(); $es->add_type(id_of('av_file')); $es->add_right_relationship($media_work_deleter->get_value('id'), relationship_id_of('av_to_av_file')); $media_files = $es->run_one(); foreach ($media_files as $file) { reason_expunge_entity($file->id(), $media_work_deleter->admin_page->user_id); } if ($e->get_value('entry_id')) { $shim = new KalturaShim(); $user = new entity($media_work_deleter->admin_page->user_id); $shim->delete_media($e, $user->get_value('name')); } }
function get_kaltura_import_dir() { return KalturaShim::get_temp_import_dir(); }
private function _show_original_link($entity) { if (empty($this->previewer->admin_page)) { return; } $owner = $entity->get_owner(); if ($owner->id() != $this->previewer->admin_page->site_id) { return; } echo '<tr id="original_link_Row">'; $this->previewer->_row = $this->previewer->_row % 2; $this->previewer->_row++; echo '<td class="listRow' . $this->previewer->_row . ' col1">'; echo 'Original file URL:'; echo '</td>'; echo '<td class="listRow' . $this->previewer->_row . ' col2">'; $shim = new KalturaShim(); $file_ext = $shim->get_source_file_extension($entity); if ($orig_url = $shim->get_original_data_url($entity->get_value('entry_id'))) { echo '<a href="' . htmlspecialchars($orig_url) . '">' . htmlspecialchars($orig_url) . '</a>'; if (!empty($file_ext)) { echo ' (.' . $file_ext . ')' . "\n"; } } else { echo '(No original available)'; } echo '</td>'; echo '</tr>'; }
/** * The upload element is added to the form. */ function _add_file_upload_element() { if (KalturaShim::kaltura_enabled() && $this->manager->manages_media && $this->manager->get_value('transcoding_status') != 'converting') { $authenticator = array("reason_username_has_access_to_site", $this->manager->get_value("site_id")); $params = array('authenticator' => $authenticator, 'acceptable_extensions' => $this->recognized_extensions, 'max_file_size' => $this->_get_actual_max_upload_size(), 'head_items' => &$this->manager->head_items); $this->manager->add_element('upload_file', 'ReasonUpload', $params); $this->manager->add_element('upload_url'); $this->manager->add_comments('upload_url', form_comment('Or, you can place the media in any web-accessible location and paste its web address in here. <em>Tip: try pasting the address into another tab first, to make sure you have the address right!</em>')); $this->manager->set_comments('upload_file', form_comment('If the file is on your computer, browse to it here.') . form_comment('File must have one of the following extensions: .' . implode(', .', $this->recognized_extensions)) . form_comment('<div class="maxUploadSizeNotice">Maximum file size for uploading is ' . format_bytes_as_human_readable($this->_get_actual_max_upload_size()) . '. </div>')); if ($this->manager->get_value('transcoding_status') == 'ready') { $this->manager->set_display_name('upload_file', 'Upload Replacement File'); } } }
function associate_image($media_work, $data) { $tmp_path = KalturaShim::get_temp_dir() . 'temp_media_image_' . $media_work->get_value('entry_id') . '.jpg'; $f = fopen($tmp_path, 'w'); $thumb_opts = array('width' => $data['width'], 'quality' => 100); $image_url = $this->kaltura_shim->get_thumbnail($media_work->get_value('entry_id'), $data['length_in_msecs'] / 2.0 / 1000.0, $thumb_opts); $contents = get_reason_url_contents($image_url); fwrite($f, $contents); fclose($f); if (!empty($tmp_path) and file_exists($tmp_path)) { // Create a new entity for the image if ($id = $this->create_image_entity($media_work, $data)) { $im = new ImageManager(); //$im->convert_non_web_to = $this->convert_non_web_to; $im->thumbnail_width = REASON_STANDARD_MAX_THUMBNAIL_WIDTH; $im->thumbnail_height = REASON_STANDARD_MAX_THUMBNAIL_HEIGHT; $im->max_width = REASON_STANDARD_MAX_IMAGE_WIDTH; $im->max_height = REASON_STANDARD_MAX_IMAGE_HEIGHT; $im->load_by_type(id_of('image'), $id, get_user_id($data['puser_id'])); $im->handle_standard_image($id, $tmp_path); //$im->handle_original_image($id, $image); $im->create_default_thumbnail($id); if ($data['width'] > $im->max_width || $data['height'] > $im->max_height) { $image_path = PHOTOSTOCK . reason_format_image_filename($id, 'jpg'); $original_path = add_name_suffix($image_path, '_orig'); @copy($image_path, $original_path); resize_image($image_path, $im->max_width, $im->max_height); } // Pull the values generated in the content manager // and save them to the entity $values = array(); foreach ($im->get_element_names() as $element_name) { $values[$element_name] = $im->get_value($element_name); } reason_update_entity($id, get_user_id($data['puser_id']), $values, false); // Remove any existing association with an image and replace it with this new one delete_relationships(array('entity_a' => $media_work->id(), 'type' => relationship_id_of('av_to_primary_image'))); create_relationship($media_work->id(), $id, relationship_id_of('av_to_primary_image')); } else { trigger_error('Failed to create image entity.'); } } else { trigger_error('No path to image: ' . $tmp_path); } }