diff options
author | Tushar Mahajan <chia.tushar@gmail.com> | 2010-09-08 23:43:39 +0000 |
---|---|---|
committer | Tushar Mahajan <chia.tushar@gmail.com> | 2010-09-08 23:43:39 +0000 |
commit | 07e453e2ff2f66017eb49cc0374aa1531805a043 (patch) | |
tree | daed69ad388a73ff56078643a0ec779f35606f4f | |
parent | ef4365879413eab6a0d2be64374a9840c7eed804 (diff) | |
download | video-07e453e2ff2f66017eb49cc0374aa1531805a043.tar.gz video-07e453e2ff2f66017eb49cc0374aa1531805a043.tar.bz2 |
Porting video module port for D7
-rw-r--r-- | video.info | 4 | ||||
-rw-r--r-- | video.install | 8 | ||||
-rw-r--r-- | video.module | 282 | ||||
-rw-r--r-- | video.theme.inc | 8 |
4 files changed, 163 insertions, 139 deletions
@@ -1,10 +1,8 @@ ;$Id$ name = Video -description = Allows Creation of CCK Video Fields. +description = Allows Creation of Video Fields. package = "Video" -dependencies[] = content -dependencies[] = filefield core = 7.x files[]=video.module files[]=video.install diff --git a/video.install b/video.install index 5d2ea92..7e66988 100644 --- a/video.install +++ b/video.install @@ -98,17 +98,9 @@ function video_schema() { } /** - * Implementation of hook_install(). - */ -function video_install() { - drupal_install_schema('video'); -} - -/** * Implementation of hook_uninstall(). */ function video_uninstall() { - drupal_uninstall_schema('video'); //@todo Need to drop all variables used in this module here. } diff --git a/video.module b/video.module index 0aef51f..52f1f8f 100644 --- a/video.module +++ b/video.module @@ -54,6 +54,7 @@ function video_permission() { */ function video_menu() { $items = array(); + $items['admin/settings/video'] = array( 'title' => 'Video', 'description' => 'Configure different aspects of the video module and its plugins', @@ -63,11 +64,13 @@ function video_menu() { 'access arguments' => array('administer site configuration'), 'type' => MENU_NORMAL_ITEM, ); + $items['admin/settings/video/general'] = array( 'title' => 'General', 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => 0, ); + $items['admin/settings/video/players'] = array( 'title' => 'Players', 'description' => 'Configure your player settings for each video extension.', @@ -78,6 +81,7 @@ function video_menu() { 'type' => MENU_LOCAL_TASK, 'weight' => 1, ); + $items['admin/settings/video/transcoders'] = array( 'title' => 'Transcoders', 'description' => 'Configure your transcoder to convert your videos or extra thumbnails.', @@ -88,6 +92,7 @@ function video_menu() { 'type' => MENU_LOCAL_TASK, 'weight' => 2, ); + $items['admin/settings/video/metadata'] = array( 'title' => 'Metadata', 'description' => 'Configure your metadata settings.', @@ -98,6 +103,7 @@ function video_menu() { 'type' => MENU_LOCAL_TASK, 'weight' => 3, ); + $items['admin/settings/video/cron'] = array( 'title' => 'Cron Settings', 'description' => 'Configure your cron settings.', @@ -108,6 +114,7 @@ function video_menu() { 'type' => MENU_LOCAL_TASK, 'weight' => 4, ); + return $items; } @@ -117,44 +124,44 @@ function video_menu() { function video_theme() { $theme = array(); $theme['video_thumbnails'] = array( - 'arguments' => array('file' => NULL, 'alt' => '', 'title' => '', 'attributes' => NULL, 'getsize' => TRUE), - 'file' => 'video.theme.inc', + 'variables' => array('file' => NULL, 'alt' => '', 'title' => '', 'attributes' => NULL, 'getsize' => TRUE), + 'file' => 'video.theme.inc', ); $theme['video_widget_preview'] = array( - 'arguments' => array('item' => TRUE), - 'file' => 'video.theme.inc', + 'variables' => array('item' => TRUE), + 'file' => 'video.theme.inc', ); $theme['video_image'] = array( - 'arguments' => array('file' => NULL, 'alt' => '', 'title' => '', 'attributes' => NULL, 'getsize' => TRUE, 'imagecache' => NULL), - 'file' => 'video.theme.inc', + 'variables' => array('file' => NULL, 'alt' => '', 'title' => '', 'attributes' => NULL, 'getsize' => TRUE, 'imagecache' => NULL), + 'file' => 'video.theme.inc', ); $theme['video_widget_video_thumb'] = array( - 'arguments' => array('item' => TRUE), - 'file' => 'video.theme.inc', + 'variables' => array('item' => TRUE), + 'file' => 'video.theme.inc', ); $theme['video_formatter_video_plain'] = array( - 'arguments' => array('element' => NULL), - 'file' => 'video_formatter.inc', + 'variables' => array('element' => NULL), + 'file' => 'video_formatter.inc', ); $theme['video_formatter_video_nodelink'] = array( - 'arguments' => array('element' => NULL, 'imagecache' => NULL), - 'file' => 'video_formatter.inc', + 'variables' => array('element' => NULL, 'imagecache' => NULL), + 'file' => 'video_formatter.inc', ); //$theme['video_formatter_video_colorbox'] = array( // 'arguments' => array('element' => NULL, 'imagecache' => NULL), // 'file' => 'video_formatter.inc', //); $theme['video_formatter_video_media_js'] = array( - 'arguments' => array('element' => NULL), - 'file' => 'video_formatter.inc', + 'variables' => array('element' => NULL), + 'file' => 'video_formatter.inc', ); $theme['video_encoding_failed'] = array( 'arguments' => array(), 'file' => 'video_formatter.inc', ); $theme['video_inprogress'] = array( - 'arguments' => array(), - 'file' => 'video_formatter.inc', + 'variables' => array(), + 'file' => 'video_formatter.inc', ); $path = drupal_get_path('module', 'video') . '/theme'; @@ -162,16 +169,16 @@ function video_theme() { $players = video_video_players(); foreach ($players as $tpl => $value) { $theme[$tpl] = array( - 'arguments' => array('video' => NULL, 'node' => NULL, 'themed_output' => NULL), - 'file' => 'video_formatter.inc', - 'template' => str_replace('_', '-', $tpl), - 'path' => $path, + 'variables' => array('video' => NULL, 'node' => NULL, 'themed_output' => NULL), + 'file' => 'video_formatter.inc', + 'template' => str_replace('_', '-', $tpl), + 'path' => $path, ); } //We need to add an flv theme buffer to allow users to override in their own module to add in extra parameters before //calling our flv template file. $theme['video_flv'] = array( - 'arguments' => array('video' => NULL, 'node' => NULL), + 'variables' => array('video' => NULL, 'node' => NULL), 'file' => 'video_formatter.inc' ); @@ -183,7 +190,7 @@ function video_theme() { foreach ($thumb_types as $types) { foreach (imagecache_presets () as $preset) { $theme['video_formatter_' . $preset['presetname'] . '__' . $types] = array( - 'arguments' => array('element' => NULL), + 'variables' => array('element' => NULL), 'function' => 'theme_video_formatter_imagecache', 'file' => 'video_formatter.inc' ); @@ -194,19 +201,19 @@ function video_theme() { } /** - * Implementation of CCK's hook_field_formatter_info(). + * Implementation of hook_field_formatter_info(). */ function video_field_formatter_info() { $formatters = array( 'video_plain' => array( - 'label' => t('Video'), - 'field types' => array('filefield'), - 'description' => t('Displays video files with player embedded.'), + 'label' => t('Video'), + 'field types' => array('file'), + 'description' => t('Displays video files with player embedded.'), ), 'video_nodelink' => array( - 'label' => t('Video Thumbnail linked to node'), - 'field types' => array('filefield'), - 'description' => t('Displays the video thumbnail and links to the node.'), + 'label' => t('Video Thumbnail linked to node'), + 'field types' => array('file'), + 'description' => t('Displays the video thumbnail and links to the node.'), ), //'video_colorbox' => array( // 'label' => t('Video Thumbnail to Colorbox'), @@ -214,23 +221,23 @@ function video_field_formatter_info() { // 'description' => t('Displays the video thumbnail and adds colorbox support.'), //), 'video_media_js' => array( - 'label' => t('Video inject with jMedia'), - 'field types' => array('filefield'), - 'description' => t('Displays the video by using jmedia javascript.'), + 'label' => t('Video inject with jMedia'), + 'field types' => array('file'), + 'description' => t('Displays the video by using jmedia javascript.'), ), ); //setup our imagecache presets if (module_exists('imagecache')) { - //we need formatters for each of our thumbnails. - $thumb_types = array('video_nodelink'); //array('video_colorbox', 'video_nodelink'); - foreach ($thumb_types as $types) { - foreach (imagecache_presets () as $preset) { - $formatters[$preset['presetname'] . '__' . $types] = array( - 'label' => t('@preset @label', array('@preset' => $preset['presetname'], '@label' => $formatters[$types]['label'])), - 'field types' => array('filefield'), - ); - } + //we need formatters for each of our thumbnails. + $thumb_types = array('video_nodelink'); //array('video_colorbox', 'video_nodelink'); + foreach ($thumb_types as $types) { + foreach (imagecache_presets () as $preset) { + $formatters[$preset['presetname'] . '__' . $types] = array( + 'label' => t('@preset @label', array('@preset' => $preset['presetname'], '@label' => $formatters[$types]['label'])), + 'field types' => array('file'), + ); } + } } return $formatters; } @@ -248,21 +255,21 @@ function video_cron() { } function video_form_alter(&$form, &$form_state, $form_id) { - if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] . '_node_form' == $form_id) { - $form['buttons']['submit']['#submit'][] = 'video_node_update_submit'; - } + if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] . '_node_form' == $form_id) { + $form['buttons']['submit']['#submit'][] = 'video_node_update_submit'; + } } function video_node_update_submit($form, &$form_state) { - //lets update our video rending table to include the node id created - if (isset($form_state['nid']) && isset($form_state['values']['video_id']) && is_array($form_state['values']['video_id'])) { - foreach ($form_state['values']['video_id'] as $fid) { - //lets update our table to include the nid - db_query("UPDATE {video_files} SET nid=%d WHERE fid=%d", $form_state['nid'], $fid); - // Lets other module to know to update - video_module_invoke('update', $form, $form_state); - } + //lets update our video rending table to include the node id created + if (isset($form_state['nid']) && isset($form_state['values']['video_id']) && is_array($form_state['values']['video_id'])) { + foreach ($form_state['values']['video_id'] as $fid) { + //lets update our table to include the nid + db_query("UPDATE {video_files} SET nid=%d WHERE fid=%d", $form_state['nid'], $fid); + // Lets other module to know to update + video_module_invoke('update', $form, $form_state); } + } } /* @@ -270,45 +277,47 @@ function video_node_update_submit($form, &$form_state) { */ function video_thumb_process(&$element) { - // Developed for ffmpeg support - $file = $element['#value']; - $delta = $file['fid']; - if (isset($element['preview']) && $file['fid'] != 0) { - module_load_include('inc', 'video', '/includes/transcoder'); - $transcoder = new video_transcoder; - if ($thumbs = $transcoder->generate_thumbnails($file)) { - $default_thumb = ''; - $rnd_img = rand(0, variable_get('no_of_video_thumbs', 5) - 1); - $default_thumb = $thumbs[$rnd_img]->filepath; - - if (is_array($thumbs)) { - foreach ($thumbs as $fid => $img) { - $thumbss[$img->filepath] = theme('video_thumbnails', $img, '', '', array('width' => '50'), FALSE); - } - } - } - - $element['data']['video_thumb'] = array( - '#type' => 'radios', - '#title' => t('Video Thumbnails'), - '#options' => $thumbss, - '#default_value' => !empty($file['data']['video_thumb']) ? $file['data']['video_thumb'] : $default_thumb, - '#weight' => 10, - '#attributes' => array('class' => 'video-thumbnails', 'onchange' => 'videoftp_thumbnail_change()', 'rel' => 'video_large_thumbnail-' . $delta), - ); - - // Setup our large thumbnail that is on the left. - // @todo Add smaller video preview instead of thumbnail? - if (isset($file['data']['video_thumb']) && !empty($file['data']['video_thumb'])) { - $large_thumb = array('filepath' => $file['data']['video_thumb']); - } elseif (!empty($field['widget']['default_video_thumb'])) { - $large_thumb = $field['widget']['default_video_thumb']; - } else { - $large_thumb = array('filepath' => $default_thumb); + // Developed for ffmpeg support + $file = $element['#value']; + $delta = $file['fid']; + if (isset($element['preview']) && $file['fid'] != 0) { + module_load_include('inc', 'video', '/includes/transcoder'); + $transcoder = new video_transcoder; + if ($thumbs = $transcoder->generate_thumbnails($file)) { + $default_thumb = ''; + $rnd_img = rand(0, variable_get('no_of_video_thumbs', 5) - 1); + $default_thumb = $thumbs[$rnd_img]->filepath; + + if (is_array($thumbs)) { + foreach ($thumbs as $fid => $img) { + $thumbss[$img->filepath] = theme('video_thumbnails', $img, '', '', array('width' => '50'), FALSE); } - // @todo Integrate the thumbnails with imagecache. - $element['preview']['#suffix'] = '<div class="video_large_thumbnail-' . $delta . '">' . theme('video_thumbnails', $large_thumb, '', '', array('width' => '150'), FALSE) . '</div>'; - } + } + } + + $element['data']['video_thumb'] = array( + '#type' => 'radios', + '#title' => t('Video Thumbnails'), + '#options' => $thumbss, + '#default_value' => !empty($file['data']['video_thumb']) ? $file['data']['video_thumb'] : $default_thumb, + '#weight' => 10, + '#attributes' => array('class' => 'video-thumbnails', 'onchange' => 'videoftp_thumbnail_change()', 'rel' => 'video_large_thumbnail-' . $delta), + ); + + // Setup our large thumbnail that is on the left. + // @todo Add smaller video preview instead of thumbnail? + if (isset($file['data']['video_thumb']) && !empty($file['data']['video_thumb'])) { + $large_thumb = array('filepath' => $file['data']['video_thumb']); + } + elseif (!empty($field['widget']['default_video_thumb'])) { + $large_thumb = $field['widget']['default_video_thumb']; + } + else { + $large_thumb = array('filepath' => $default_thumb); + } + // @todo Integrate the thumbnails with imagecache. + $element['preview']['#suffix'] = '<div class="video_large_thumbnail-' . $delta . '">' . theme('video_thumbnails', $large_thumb, '', '', array('width' => '150'), FALSE) . '</div>'; + } } /** @@ -321,45 +330,48 @@ function video_thumb_process(&$element) { * Form element to get the video file from. */ function video_convert_process(&$element) { - $file = $element['#value']; - // Add default dimensions from our default_value if needed - if (!isset($file['data']['dimensions'])) { - $file['data']['dimensions'] = $element['data']['dimensions']['#value']; + $file = $element['#value']; + // Add default dimensions from our default_value if needed + if (!isset($file['data']['dimensions'])) { + $file['data']['dimensions'] = $element['data']['dimensions']['#value']; + } + $convert = false; + //we need to check if this fid has already been added to the database AND that there is in fact a fid + if (is_array($file) && isset($file['fid']) && !empty($file['fid']) && !$file['data']['bypass_autoconversion']) { + $fid = $file['fid']; + //setup our conversion class and check for the fid existence. + module_load_include('inc', 'video', '/includes/conversion'); + $video_conversion = new video_conversion; + // 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_video($fid)) { + // Video has not been added to the queue yet so lets add it. + db_query("INSERT INTO {video_files} (fid, status, dimensions) VALUES (%d, %d, '%s')", $fid, VIDEO_RENDERING_PENDING, $file['data']['dimensions']); + $convert = true; + //lets queue our node status to unpublished. + $element['#unpublish'] = true; + } + else if ($video->video_status != VIDEO_RENDERING_COMPLETE) { + // lets queue our node status to unpublished. + $element['#unpublish'] = true; + } + + // Our video should be in the database pending, lets see if we need to convert it now. + // Check if we are going from unselected to selected or if this is a new video and we have checked the checkbox + if (((!isset($element['#default_value']['data']['convert_video_on_save']) || !$element['#default_value']['data']['convert_video_on_save']) && $file['data']['convert_video_on_save']) || ($convert && $file['data']['convert_video_on_save'])) { + $return = $video_conversion->process($fid); + if ($return === FALSE) { + drupal_set_message(t('Something went wrong with your video conversion. Please check your recent log entries for further debugging.'), 'error'); + } + else if ($return === TRUE) { + //we are always unpublished until we are converted. + unset($element['#unpublish']); + drupal_set_message(t('Successfully converted your video.')); } - $convert = false; - //we need to check if this fid has already been added to the database AND that there is in fact a fid - if (is_array($file) && isset($file['fid']) && !empty($file['fid']) && !$file['data']['bypass_autoconversion']) { - $fid = $file['fid']; - //setup our conversion class and check for the fid existence. - module_load_include('inc', 'video', '/includes/conversion'); - $video_conversion = new video_conversion; - // 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_video($fid)) { - // Video has not been added to the queue yet so lets add it. - db_query("INSERT INTO {video_files} (fid, status, dimensions) VALUES (%d, %d, '%s')", $fid, VIDEO_RENDERING_PENDING, $file['data']['dimensions']); - $convert = true; - //lets queue our node status to unpublished. - $element['#unpublish'] = true; - } elseif ($video->video_status != VIDEO_RENDERING_COMPLETE) { - //lets queue our node status to unpublished. - $element['#unpublish'] = true; - } - - // Our video should be in the database pending, lets see if we need to convert it now. - // Check if we are going from unselected to selected or if this is a new video and we have checked the checkbox - if (((!isset($element['#default_value']['data']['convert_video_on_save']) || !$element['#default_value']['data']['convert_video_on_save']) && $file['data']['convert_video_on_save']) || ($convert && $file['data']['convert_video_on_save'])) { - $return = $video_conversion->process($fid); - if ($return === FALSE) { - drupal_set_message(t('Something went wrong with your video conversion. Please check your recent log entries for further debugging.'), 'error'); - } elseif ($return === TRUE) { - //we are always unpublished until we are converted. - unset($element['#unpublish']); - drupal_set_message(t('Successfully converted your video.')); - } - } elseif ($convert) { - drupal_set_message(t('Video submission queued for processing. Please wait: our servers are preparing your video for display.')); - } + } + else if ($convert) { + drupal_set_message(t('Video submission queued for processing. Please wait: our servers are preparing your video for display.')); } + } } /** @@ -835,3 +847,19 @@ function rmdirr($dir) { } @rmdir($dir); } + +/** + * Implementation of hook_element_info() + */ +function video_element_info() { + $types = array(); + + // Support HTML5 video tag for rendering videos + $types['video'] = array( + '#input' => TRUE, + '#theme' => 'video', + '#size' => 60, + ); + + return $types; +}
\ No newline at end of file diff --git a/video.theme.inc b/video.theme.inc index dfa36e5..f76edc9 100644 --- a/video.theme.inc +++ b/video.theme.inc @@ -7,7 +7,13 @@ * */ -function theme_video_thumbnails($file, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) { +function theme_video_thumbnails($variables) { + $file = $variables['file']; + $alt = $variables['alt']; + $title = $variables['title']; + $attributes = $variables['attributes']; + $getsize = $variables['getsize']; + $file = (array)$file; // return $file['filepath']; if (!is_file($file['filepath'])) { |