From 14c097ff41e0410784aa1fdae7b4312ec70ff5e0 Mon Sep 17 00:00:00 2001 From: Heshan Date: Mon, 14 Mar 2011 20:58:44 +0530 Subject: Move common codes from the insert and update, and formate the helper thumbnails --- includes/preset.inc | 3 ++- includes/video_helper.inc | 16 +++++++--------- modules/video_ui/video.admin.inc | 8 ++++---- plugins/.cvsignore | 1 - transcoders/video_ffmpeg.inc | 6 ++++++ video.field.inc | 41 ++++++++++++++-------------------------- video.module | 26 +++++++++++++++---------- 7 files changed, 49 insertions(+), 52 deletions(-) delete mode 100644 plugins/.cvsignore diff --git a/includes/preset.inc b/includes/preset.inc index d3a3fdd..c2870a5 100644 --- a/includes/preset.inc +++ b/includes/preset.inc @@ -62,7 +62,8 @@ class video_preset { * @return array $properties */ public function properties() { - module_load_include('inc', 'video_ui', 'video.preset'); + // adding modules/video_ui to load this file even if UI module is disabled + module_load_include('inc', 'video', 'modules/video_ui/video.preset'); $presets = array(); $preset = $this->preset; foreach ($preset as $preset_name) { diff --git a/includes/video_helper.inc b/includes/video_helper.inc index e47830c..cd743c7 100644 --- a/includes/video_helper.inc +++ b/includes/video_helper.inc @@ -89,21 +89,19 @@ class video_helper { $thumbnail->filepath = ''; $thumbnail->url = ''; //@todo future enhancements for our thumbnails - $thumbnail->alt = ''; - $thumbnail->title = ''; - $thumbnail->description = ''; - + $thumbnail->alt = $variables['entity']->title; + $thumbnail->title = $variables['entity']->title; +// $thumbnail->description = ''; // Setup our thumbnail path. - $default_thumbnail = file_load($field_settings['default_video_thumbnail']); - $use_default_img = isset($variables['item']['use_default_video_thumb']) ? - $variables['item']['use_default_video_thumb'] : FALSE; + $use_default_img = isset($variables['item']['use_default_video_thumb']) ? TRUE : FALSE; if ($use_default_img && !empty($field_settings['default_video_thumbnail'])) { + $default_thumbnail = file_load($field_settings['default_video_thumbnail']['fid']); // Check the checkbox to use default thumbnail on node $thumbnail->filepath = $default_thumbnail->uri; - } elseif (isset($variables['item']['video_thumb']) ? $variables['item']['video_thumb'] : FALSE) { + } elseif (isset($variables['item']['thumbanail']) ? TRUE : FALSE) { // actual video thumbnails is present - $thumbnail_load = file_load($variables['item']['video_thumb']); + $thumbnail_load = file_load($variables['item']['thumbanail']); $thumbnail->filepath = $thumbnail_load->uri; } else { //need some type of default if nothing is present diff --git a/modules/video_ui/video.admin.inc b/modules/video_ui/video.admin.inc index e55e774..11259e9 100644 --- a/modules/video_ui/video.admin.inc +++ b/modules/video_ui/video.admin.inc @@ -60,19 +60,19 @@ function video_general_admin_settings() { ); $form['video_bypass_conversion'] = array( '#type' => 'checkbox', - '#title' => t('Bypass Video Conversion'), + '#title' => t('Bypass video conversion'), '#default_value' => variable_get('video_bypass_conversion', FALSE), '#description' => t('Bypass video conversion when creating videos.') ); $form['video_convert_on_save'] = array( '#type' => 'checkbox', - '#title' => t('Video Convert on Node Submit'), + '#title' => t('Video convert on node submit'), '#default_value' => variable_get('video_convert_on_save', FALSE), - '#description' => t('Convert videos on node submit.') + '#description' => t('Convert videos on node submit will enable by default for all users.') ); $form['video_use_default_thumb'] = array( '#type' => 'checkbox', - '#title' => t('Override Auto Thumbnails with Default'), + '#title' => t('Override video thumbnails with default thumbnail'), '#default_value' => variable_get('video_use_default_thumb', FALSE), '#description' => t('Override auto thumbnails with default thumbnail.') ); diff --git a/plugins/.cvsignore b/plugins/.cvsignore deleted file mode 100644 index e43b0f9..0000000 --- a/plugins/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -.DS_Store diff --git a/transcoders/video_ffmpeg.inc b/transcoders/video_ffmpeg.inc index 791b5ca..14f40c5 100644 --- a/transcoders/video_ffmpeg.inc +++ b/transcoders/video_ffmpeg.inc @@ -296,6 +296,12 @@ class video_ffmpeg implements transcoder_interface { '#collapsible' => TRUE, '#collapsed' => TRUE, ); + $form['autothumb']['video_thumb_save_all'] = array( + '#type' => 'checkbox', + '#title' => t('Save all thumbnails in file_manged table'), + '#description' => t('Save all auto created thumbnails to the file_managed table.'), + '#default_value' => variable_get('video_thumb_save_all', TRUE), + ); $form['autothumb']['video_thumb_path'] = array( '#type' => 'textfield', '#title' => t('Path to save thumbnails'), diff --git a/video.field.inc b/video.field.inc index 8e819d9..a60e3b2 100644 --- a/video.field.inc +++ b/video.field.inc @@ -143,33 +143,8 @@ function video_field_presave($entity_type, $entity, $field, $instance, $langcode */ function video_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) { file_field_insert($entity_type, $entity, $field, $instance, $langcode, $items); - // Create entry for video conversion if auto converison is enabled - if ($field['settings']['autoconversion'] == 1) { - $nid = $entity->vid; - module_load_include('inc', 'video', '/includes/conversion'); - $video_conversion = new video_conversion; - foreach ($items as $delta => $item) { - // skip adding entry if bypass conversion is checked - if ($item['bypass_autoconversion'] == 1 || variable_get('video_bypass_conversion', FALSE)) { - // delete the conversion job if any - $video_conversion->delete_job($item); - return; - } - // Lets verify that we haven't added this video already. Multiple validation fails will cause this to be ran more than once - if (!$video = $video_conversion->load_job($item['fid'])) { - if (!($video_conversion->create_job($item, $nid))) - drupal_set_message(t('Something went wrong with your video job creation. Please check your recent log entries for further debugging.'), 'error'); - } - // if convert on save is checked - if ($item['convert_video_on_save'] == 1 || variable_get('video_convert_on_save', FALSE)) { - if (!$video_conversion->process($item['fid'])) { - drupal_set_message(t('Something went wrong with your video conversion. Please check your recent log entries for further debugging.'), 'error'); - } else { - drupal_set_message(t('Successfully converted your video.')); - } - } - } - } + // calling function to handle conversion when auto conversion is enabled + _video_field_file_autoconversion($entity_type, $entity, $field, $instance, $langcode, $items); } /** @@ -177,6 +152,14 @@ function video_field_insert($entity_type, $entity, $field, $instance, $langcode, */ function video_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) { file_field_update($entity_type, $entity, $field, $instance, $langcode, $items); + // calling function to handle conversion when auto conversion is enabled + _video_field_file_autoconversion($entity_type, $entity, $field, $instance, $langcode, $items); +} + +/** + * Video file save to the video_files table for conversions + */ +function _video_field_file_autoconversion($entity_type, $entity, $field, $instance, $langcode, &$items) { // Create entry for video conversion if auto converison is enabled if ($field['settings']['autoconversion'] == 1) { $nid = $entity->vid; @@ -189,6 +172,10 @@ function video_field_update($entity_type, $entity, $field, $instance, $langcode, $video_conversion->delete_job($item); return; } + // re queue for video conversion + if ($item['re_convert_video'] == 1) { + $video_conversion->change_status($item['fid'], VIDEO_RENDERING_PENDING); + } // Lets verify that we haven't added this video already. Multiple validation fails will cause this to be ran more than once if (!$video = $video_conversion->load_job($item['fid'])) { if (!($video_conversion->create_job($item, $nid))) diff --git a/video.module b/video.module index 6e38cab..d9035c1 100644 --- a/video.module +++ b/video.module @@ -38,6 +38,9 @@ function video_permission() { 'use default thumb' => array( 'title' => t('Use default thumbnail'), ), + 're convert video' => array( + 'title' => t('Re queue video'), + ), 'administer video presets' => array( 'title' => t('Administer video presets'), 'description' => t('Perform administration tasks for the video presets.'), @@ -363,6 +366,18 @@ function video_widget_element_settings(&$element, &$form_state) { // only in preview mode and then create thumbnails if ($field['settings']['autoconversion']) { + // check if already converted + module_load_include('inc', 'video', '/includes/conversion'); + $video_conversion = new video_conversion; + $video = $video_conversion->load_job($file['fid']); + if (user_access('re convert video') && $video->video_status == VIDEO_RENDERING_COMPLETE) { + $element['re_convert_video'] = array( + '#type' => 'checkbox', + '#title' => t('Re-queue video for conversion.'), + '#description' => t('This will re-convert your video to output formats when you save, or scheduling it for cron.'), + '#attributes' => array('class' => array('video-re-convert')), + ); + } if (user_access('bypass conversion video')) { $element['bypass_autoconversion'] = array( '#type' => 'checkbox', @@ -372,7 +387,7 @@ function video_widget_element_settings(&$element, &$form_state) { '#attributes' => array('class' => array('video-bypass-auto-conversion')), ); } -// check this to convert the video on save + // check this to convert the video on save $convert = isset($file['convert_video_on_save']) ? $file['convert_video_on_save'] : variable_get('video_convert_on_save', FALSE); if (user_access('convert on submission')) { $element['convert_video_on_save'] = array( @@ -382,15 +397,6 @@ function video_widget_element_settings(&$element, &$form_state) { '#description' => t('This will convert your video to flv format when you save, instead of scheduling it for cron.'), '#attributes' => array('class' => array('video-convert-video-on-save')), ); - - if ($convert) { - $element['convert_video_on_save']['#attributes']['checked'] = 'checked'; - } - } else { - $element['convert_video_on_save'] = array( - '#type' => 'value', - '#value' => $convert, - ); } } -- cgit v1.2.3