aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohamed Mujahid <muja_dd@494418.no-reply.drupal.org>2010-07-23 10:01:23 +0000
committerMohamed Mujahid <muja_dd@494418.no-reply.drupal.org>2010-07-23 10:01:23 +0000
commitef4365879413eab6a0d2be64374a9840c7eed804 (patch)
treef32097751575177f2245b68b412f55cd95cbc70a
parente8f0a0d58a73a0d3e5877d9cd433e5c191fd93d2 (diff)
downloadvideo-ef4365879413eab6a0d2be64374a9840c7eed804.tar.gz
video-ef4365879413eab6a0d2be64374a9840c7eed804.tar.bz2
function replacements
-rw-r--r--cdn/video_s3/includes/S3.php4
-rw-r--r--cdn/video_s3/includes/amazon_s3.inc2
-rw-r--r--includes/conversion.inc2
-rw-r--r--plugins/ffmpeg.inc6
-rw-r--r--plugins/ffmpeg_wrapper.inc8
-rw-r--r--plugins/video_zencoder/includes/zencoder.inc2
-rw-r--r--plugins/zencoder.inc6
-rw-r--r--transcoders/video_ffmpeg.inc2
-rw-r--r--transcoders/video_ffmpeg_wrapper.inc2
-rw-r--r--types/uploadfield/uploadfield.module2
-rw-r--r--types/uploadfield/uploadfield_widget.inc2
-rw-r--r--types/videoftp/videoftp_widget.inc2
-rw-r--r--video.module1252
13 files changed, 651 insertions, 641 deletions
diff --git a/cdn/video_s3/includes/S3.php b/cdn/video_s3/includes/S3.php
index 70d3ad8..77af0f6 100644
--- a/cdn/video_s3/includes/S3.php
+++ b/cdn/video_s3/includes/S3.php
@@ -749,7 +749,7 @@ class S3 {
* @return string
*/
public static function getAuthenticatedURL($bucket, $uri, $lifetime, $hostBucket = false, $https = false) {
- $expires = time() + $lifetime;
+ $expires = REQUEST_TIME + $lifetime;
$uri = str_replace('%2F', '/', rawurlencode($uri)); // URI should be encoded (thanks Sean O'Dea)
return sprintf(($https ? 'https' : 'http').'://%s/%s?AWSAccessKeyId=%s&Expires=%u&Signature=%s',
$hostBucket ? $bucket : $bucket.'.s3.amazonaws.com', $uri, self::$__accessKey, $expires,
@@ -773,7 +773,7 @@ class S3 {
public static function getHttpUploadPostParams($bucket, $uriPrefix = '', $acl = self::ACL_PRIVATE, $lifetime = 3600, $maxFileSize = 5242880, $successRedirect = "201", $amzHeaders = array(), $headers = array(), $flashVars = false) {
// Create policy object
$policy = new stdClass;
- $policy->expiration = gmdate('Y-m-d\TH:i:s\Z', (time() + $lifetime));
+ $policy->expiration = gmdate('Y-m-d\TH:i:s\Z', (REQUEST_TIME + $lifetime));
$policy->conditions = array();
$obj = new stdClass; $obj->bucket = $bucket; array_push($policy->conditions, $obj);
$obj = new stdClass; $obj->acl = $acl; array_push($policy->conditions, $obj);
diff --git a/cdn/video_s3/includes/amazon_s3.inc b/cdn/video_s3/includes/amazon_s3.inc
index 53f5ff9..f53b087 100644
--- a/cdn/video_s3/includes/amazon_s3.inc
+++ b/cdn/video_s3/includes/amazon_s3.inc
@@ -69,7 +69,7 @@ class video_amazon_s3 {
*/
public function update($video) {
$result = db_query("UPDATE {video_s3} SET bucket='%s', filename='%s', filepath='%s', filemime='%s', filesize='%s', status=%d, completed=%d WHERE vid=%d",
- $video->bucket, $video->filename, $video->filepath, $video->filemime, $video->filesize, VIDEO_S3_ACTIVE, time(), $video->vid);
+ $video->bucket, $video->filename, $video->filepath, $video->filemime, $video->filesize, VIDEO_S3_ACTIVE, REQUEST_TIME, $video->vid);
return $result;
}
diff --git a/includes/conversion.inc b/includes/conversion.inc
index 3f1165e..4f66bfa 100644
--- a/includes/conversion.inc
+++ b/includes/conversion.inc
@@ -111,7 +111,7 @@ class video_conversion {
$video->converted->filemime = file_get_mimetype($converted);
$video->converted->filesize = filesize($converted);
$video->converted->status = VIDEO_RENDERING_COMPLETE;
- $video->converted->completed = time();
+ $video->converted->completed = REQUEST_TIME;
//clear our cache so our video path is updated.
cache_clear_all('*', 'cache_content', true);
// Update our video_files table with the converted video information.
diff --git a/plugins/ffmpeg.inc b/plugins/ffmpeg.inc
index e8e0057..a83653a 100644
--- a/plugins/ffmpeg.inc
+++ b/plugins/ffmpeg.inc
@@ -188,7 +188,7 @@ function ffmpeg_auto_thumbnail($vidfile) {
$file->filepath = $thumbfile;
$file->filemime = file_get_mimetype("video-thumb-for-$fid-$i.png");
$file->filesize = filesize($thumbfile);
- $file->timestamp = time();
+ $file->timestamp = REQUEST_TIME;
$files[] = $file;
}
return $files;
@@ -236,7 +236,7 @@ function ffmpeg_auto_convert(&$job) {
//print('executing ' . $command); die;
watchdog('video_render', 'executing: ' . $command, array(), WATCHDOG_DEBUG);
-// watchdog('video_render', 'Starting : ' . time());
+// watchdog('video_render', 'Starting : ' . REQUEST_TIME);
//execute the command
ob_start();
passthru($command." 2>&1", $command_return);
@@ -259,7 +259,7 @@ function ffmpeg_auto_convert(&$job) {
$file->filepath = $job->convfile;
$file->filemime = file_get_mimetype($file_name);
$file->filesize = filesize($job->convfile);
- $file->timestamp = time();
+ $file->timestamp = REQUEST_TIME;
$job->converted = $file;
}
diff --git a/plugins/ffmpeg_wrapper.inc b/plugins/ffmpeg_wrapper.inc
index 228d8ce..fd98e64 100644
--- a/plugins/ffmpeg_wrapper.inc
+++ b/plugins/ffmpeg_wrapper.inc
@@ -190,7 +190,7 @@ function ffmpeg_wrapper_auto_thumbnail($vidfile) {
$file->filepath = $thumbfile;
$file->filemime = file_get_mimetype("video-thumb-for-$fid-$i.png");
$file->filesize = filesize($thumbfile);
- $file->timestamp = time();
+ $file->timestamp = REQUEST_TIME;
$files[] = $file;
}
return $files;
@@ -233,7 +233,7 @@ function ffmpeg_wrapper_check_exe_path($path = NULL) {
//
// //print('executing ' . $command); die;
// watchdog('video_render', 'executing: ' . $options);
-//// watchdog('video_render', 'Starting : ' . time());
+//// watchdog('video_render', 'Starting : ' . REQUEST_TIME);
// //execute the command
//// ob_start();
//// passthru($command." 2>&1", $command_return);
@@ -256,7 +256,7 @@ function ffmpeg_wrapper_check_exe_path($path = NULL) {
// $file->filepath = $job->convfile;
// $file->filemime = file_get_mimetype($file_name);
// $file->filesize = filesize($job->convfile);
-// $file->timestamp = time();
+// $file->timestamp = REQUEST_TIME;
//
// $job->converted = $file;
// }
@@ -399,7 +399,7 @@ function ffmpeg_wrapper_auto_convert(&$job) {
$file->filepath = $output_file;
$file->filemime = file_get_mimetype($file_name);
$file->filesize = filesize($output_file);
- $file->timestamp = time();
+ $file->timestamp = REQUEST_TIME;
$job->converted = $file;
}
diff --git a/plugins/video_zencoder/includes/zencoder.inc b/plugins/video_zencoder/includes/zencoder.inc
index 1269505..fcf7e48 100644
--- a/plugins/video_zencoder/includes/zencoder.inc
+++ b/plugins/video_zencoder/includes/zencoder.inc
@@ -181,7 +181,7 @@ class video_zencoder_api {
*/
public function update($video) {
$result = db_query("UPDATE {video_zencoder} SET jobid = %d, outputid = %d, bucket='%s', filename='%s', filepath='%s', filemime='%s', filesize='%s', status=%d, completed=%d WHERE vid=%d",
- $video->jobid, $video->outputid, $video->bucket, $video->filename, $video->filepath, $video->filemime, $video->filesize, VIDEO_ZC_ACTIVE, time(), $video->vid);
+ $video->jobid, $video->outputid, $video->bucket, $video->filename, $video->filepath, $video->filemime, $video->filesize, VIDEO_ZC_ACTIVE, REQUEST_TIME, $video->vid);
return $result;
}
diff --git a/plugins/zencoder.inc b/plugins/zencoder.inc
index 29d6b7c..989222b 100644
--- a/plugins/zencoder.inc
+++ b/plugins/zencoder.inc
@@ -196,7 +196,7 @@ function zencoder_auto_thumbnail($vidfile) {
$file->filepath = $thumbfile;
$file->filemime = file_get_mimetype("video-thumb-for-$fid-$i.png");
$file->filesize = filesize($thumbfile);
- $file->timestamp = time();
+ $file->timestamp = REQUEST_TIME;
$files[] = $file;
}
return $files;
@@ -244,7 +244,7 @@ function zencoder_auto_convert(&$job) {
//print('executing ' . $command); die;
watchdog('video_render', 'executing: ' . $command, array(), WATCHDOG_DEBUG);
-// watchdog('video_render', 'Starting : ' . time());
+// watchdog('video_render', 'Starting : ' . REQUEST_TIME);
//execute the command
ob_start();
passthru($command." 2>&1", $command_return);
@@ -267,7 +267,7 @@ function zencoder_auto_convert(&$job) {
$file->filepath = $job->convfile;
$file->filemime = file_get_mimetype($file_name);
$file->filesize = filesize($job->convfile);
- $file->timestamp = time();
+ $file->timestamp = REQUEST_TIME;
$job->converted = $file;
}
diff --git a/transcoders/video_ffmpeg.inc b/transcoders/video_ffmpeg.inc
index 7a52dad..713693a 100644
--- a/transcoders/video_ffmpeg.inc
+++ b/transcoders/video_ffmpeg.inc
@@ -97,7 +97,7 @@ class video_ffmpeg implements transcoder_interface {
$file->filepath = $thumbfile;
$file->filemime = file_get_mimetype($filename);
$file->filesize = filesize($thumbfile);
- $file->timestamp = time();
+ $file->timestamp = REQUEST_TIME;
$files[] = $file;
}
return $files;
diff --git a/transcoders/video_ffmpeg_wrapper.inc b/transcoders/video_ffmpeg_wrapper.inc
index 8d5861d..2661fd9 100644
--- a/transcoders/video_ffmpeg_wrapper.inc
+++ b/transcoders/video_ffmpeg_wrapper.inc
@@ -79,7 +79,7 @@ class video_ffmpeg_wrapper implements transcoder_interface {
$file->filepath = $thumbfile;
$file->filemime = file_get_mimetype($filename);
$file->filesize = filesize($thumbfile);
- $file->timestamp = time();
+ $file->timestamp = REQUEST_TIME;
$files[] = $file;
}
return $files;
diff --git a/types/uploadfield/uploadfield.module b/types/uploadfield/uploadfield.module
index 73d4247..a76f112 100644
--- a/types/uploadfield/uploadfield.module
+++ b/types/uploadfield/uploadfield.module
@@ -500,7 +500,7 @@ function uploadfield_v_video($op, &$element) {
$file->filepath = $vid_path;
$file->filemime = file_get_mimetype($vid_name);
$file->filesize = filesize($vid_path);
- $file->timestamp = time();
+ $file->timestamp = REQUEST_TIME;
if($op == 'update') {
$old_fid = $element['#default_value']['data']['video_thumb_fid'];
diff --git a/types/uploadfield/uploadfield_widget.inc b/types/uploadfield/uploadfield_widget.inc
index 41d89d6..fafdb5e 100644
--- a/types/uploadfield/uploadfield_widget.inc
+++ b/types/uploadfield/uploadfield_widget.inc
@@ -136,7 +136,7 @@ function _uploadfield_widget_settings_default_validate($element, &$form_state) {
// Make the file permanent and store it in the form.
file_set_status($file, FILE_STATUS_PERMANENT);
- $file->timestamp = time();
+ $file->timestamp = REQUEST_TIME;
$form_state['values']['default_video_thumb'] = (array)$file;
}
diff --git a/types/videoftp/videoftp_widget.inc b/types/videoftp/videoftp_widget.inc
index d674660..893be77 100644
--- a/types/videoftp/videoftp_widget.inc
+++ b/types/videoftp/videoftp_widget.inc
@@ -283,7 +283,7 @@ function videoftp_save_upload($element) {
$file->filemime = file_get_mimetype($file->filename);
$file->filesize = filesize($file->filepath);
$file->status = FILE_STATUS_TEMPORARY;
- $file->timestamp = time();
+ $file->timestamp = REQUEST_TIME;
//lets move our file from the ftp folder to the files directory
if(file_move($file, $dest)) {
diff --git a/video.module b/video.module
index 677404a..0aef51f 100644
--- a/video.module
+++ b/video.module
@@ -1,17 +1,18 @@
<?php
+
//$Id$
+
/**
*
* @file video.module
*
*/
-
/*
* Implementation of hook_init().
-*/
+ */
function video_init() {
- drupal_add_css(drupal_get_path('module', 'video'). '/css/video.css');
- drupal_add_js(drupal_get_path('module', 'video'). '/js/video.js');
+ drupal_add_css(drupal_get_path('module', 'video') . '/css/video.css');
+ drupal_add_js(drupal_get_path('module', 'video') . '/js/video.js');
}
/**
@@ -28,282 +29,286 @@ function video_init() {
* be passed by reference.
*/
function video_module_invoke($action, &$array, &$video = NULL, $other = NULL) {
- foreach (module_list() as $module) {
- $function = $module . '_video_' . $action;
- if (function_exists($function)) {
- $function($array, $video, $other);
+ foreach (module_list () as $module) {
+ $function = $module . '_video_' . $action;
+ if (function_exists($function)) {
+ $function($array, $video, $other);
+ }
}
- }
}
/**
* Implementation of hook_perm().
*/
-
-function video_perm() {
- return array('bypass conversion video', 'convert on submission', 'override player dimensions', 'use default thumb');
+function video_permission() {
+ return array(
+ 'bypass conversion video' => array('title' => t('Bypass conversion video')),
+ 'convert on submission' => array('title' => t('Convert on submission')),
+ 'override player dimensions' => array('title' => t('Override player dimensions')),
+ 'use default thumb' => array('title' => t('Use default thumb'))
+ );
}
/**
* Implementation of hook_menu().
*/
function video_menu() {
- $items = array();
- $items['admin/settings/video'] = array(
- 'title' => 'Video',
- 'description' => 'Configure different aspects of the video module and its plugins',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('video_general_admin_settings'),
- 'file' => 'video.admin.inc',
- '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.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('video_players_admin_settings'),
- 'access arguments' => array('administer site configuration'),
- 'file' => 'video.admin.inc',
- '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.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('video_transcoder_admin_settings'),
- 'access arguments' => array('administer site configuration'),
- 'file' => 'video.admin.inc',
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2,
- );
- $items['admin/settings/video/metadata'] = array(
- 'title' => 'Metadata',
- 'description' => 'Configure your metadata settings.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('video_metadata_admin_settings'),
- 'access arguments' => array('administer site configuration'),
- 'file' => 'video.admin.inc',
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 3,
- );
- $items['admin/settings/video/cron'] = array(
- 'title' => 'Cron Settings',
- 'description' => 'Configure your cron settings.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('video_cron_admin_settings'),
- 'access arguments' => array('administer site configuration'),
- 'file' => 'video.admin.inc',
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 4,
- );
- return $items;
+ $items = array();
+ $items['admin/settings/video'] = array(
+ 'title' => 'Video',
+ 'description' => 'Configure different aspects of the video module and its plugins',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('video_general_admin_settings'),
+ 'file' => 'video.admin.inc',
+ '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.',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('video_players_admin_settings'),
+ 'access arguments' => array('administer site configuration'),
+ 'file' => 'video.admin.inc',
+ '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.',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('video_transcoder_admin_settings'),
+ 'access arguments' => array('administer site configuration'),
+ 'file' => 'video.admin.inc',
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
+ );
+ $items['admin/settings/video/metadata'] = array(
+ 'title' => 'Metadata',
+ 'description' => 'Configure your metadata settings.',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('video_metadata_admin_settings'),
+ 'access arguments' => array('administer site configuration'),
+ 'file' => 'video.admin.inc',
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 3,
+ );
+ $items['admin/settings/video/cron'] = array(
+ 'title' => 'Cron Settings',
+ 'description' => 'Configure your cron settings.',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('video_cron_admin_settings'),
+ 'access arguments' => array('administer site configuration'),
+ 'file' => 'video.admin.inc',
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 4,
+ );
+ return $items;
}
/**
* Implementation of hook_theme().
*/
function video_theme() {
- $theme = array();
- $theme['video_thumbnails'] = array(
- 'arguments' => 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',
- );
- $theme['video_image'] = array(
- 'arguments' => 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',
- );
- $theme['video_formatter_video_plain'] = array(
- 'arguments' => array('element' => NULL),
- 'file' => 'video_formatter.inc',
- );
- $theme['video_formatter_video_nodelink'] = array(
- 'arguments' => 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',
- );
- $theme['video_encoding_failed'] = array(
- 'arguments' => array(),
- 'file' => 'video_formatter.inc',
- );
- $theme['video_inprogress'] = array(
- 'arguments' => array(),
- 'file' => 'video_formatter.inc',
- );
-
- $path = drupal_get_path('module', 'video'). '/theme';
- //Lets setup our themes for our players
- $players = video_video_players();
- foreach($players as $tpl => $value) {
- $theme[$tpl] = array(
+ $theme = array();
+ $theme['video_thumbnails'] = array(
+ 'arguments' => 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',
+ );
+ $theme['video_image'] = array(
+ 'arguments' => 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',
+ );
+ $theme['video_formatter_video_plain'] = array(
+ 'arguments' => array('element' => NULL),
+ 'file' => 'video_formatter.inc',
+ );
+ $theme['video_formatter_video_nodelink'] = array(
+ 'arguments' => 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',
+ );
+ $theme['video_encoding_failed'] = array(
+ 'arguments' => array(),
+ 'file' => 'video_formatter.inc',
+ );
+ $theme['video_inprogress'] = array(
+ 'arguments' => array(),
+ 'file' => 'video_formatter.inc',
+ );
+
+ $path = drupal_get_path('module', 'video') . '/theme';
+ //Lets setup our themes for our players
+ $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,
- );
- }
- //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),
- 'file' => 'video_formatter.inc'
- );
-
- //setup our imagecache presets
- if(module_exists('imagecache')) {
- //we need formatters for each of our thumbnails.
- //@todo create a function to check for our colorbox module and only add theme elements that could be used.
- $thumb_types = array('video_nodelink'); //array('video_colorbox', 'video_nodelink');
- foreach($thumb_types as $types) {
- foreach (imagecache_presets() as $preset) {
- $theme['video_formatter_'. $preset['presetname'] .'__'. $types] = array(
- 'arguments' => array('element' => NULL),
- 'function' => 'theme_video_formatter_imagecache',
- 'file' => 'video_formatter.inc'
);
- }
}
- }
- return $theme;
+ //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),
+ 'file' => 'video_formatter.inc'
+ );
+
+ //setup our imagecache presets
+ if (module_exists('imagecache')) {
+ //we need formatters for each of our thumbnails.
+ //@todo create a function to check for our colorbox module and only add theme elements that could be used.
+ $thumb_types = array('video_nodelink'); //array('video_colorbox', 'video_nodelink');
+ foreach ($thumb_types as $types) {
+ foreach (imagecache_presets () as $preset) {
+ $theme['video_formatter_' . $preset['presetname'] . '__' . $types] = array(
+ 'arguments' => array('element' => NULL),
+ 'function' => 'theme_video_formatter_imagecache',
+ 'file' => 'video_formatter.inc'
+ );
+ }
+ }
+ }
+ return $theme;
}
/**
* Implementation of CCK's 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.'),
- ),
- '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.'),
- ),
- //'video_colorbox' => array(
- // 'label' => t('Video Thumbnail to Colorbox'),
- // 'field types' => array('filefield'),
- // '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.'),
- ),
- );
- //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'),
- );
- }
+ $formatters = array(
+ 'video_plain' => array(
+ 'label' => t('Video'),
+ 'field types' => array('filefield'),
+ '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.'),
+ ),
+ //'video_colorbox' => array(
+ // 'label' => t('Video Thumbnail to Colorbox'),
+ // 'field types' => array('filefield'),
+ // '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.'),
+ ),
+ );
+ //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'),
+ );
+ }
+ }
}
- }
- return $formatters;
+ return $formatters;
}
/*
* Implmentation of hook_cron().
-*/
+ */
+
function video_cron() {
- if (variable_get('video_cron', FALSE)) {
- module_load_include('inc', 'video', '/includes/conversion');
- $video_conversion = new video_conversion;
- $video_conversion->run_queue();
- }
+ if (variable_get('video_cron', FALSE)) {
+ module_load_include('inc', 'video', '/includes/conversion');
+ $video_conversion = new video_conversion;
+ $video_conversion->run_queue();
+ }
}
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);
+ }
}
- }
}
/*
* Utility function that will add a preview of thumbnails for you to select when uploading videos.
-*/
+ */
+
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);
+ // 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(
+ $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),
- );
+ '#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);
+ // 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>';
}
- // @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>';
- }
}
/**
@@ -316,101 +321,99 @@ 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'];
- }
- $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;
+ $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;
+ } 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.'));
+ // 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.'));
+ }
}
- }
}
/**
* Implementation of hook_file_delete().
*/
function video_file_delete($file) {
- //lets get all our videos and unlink them
- $sql = db_query("SELECT filepath FROM {video_files} WHERE fid=%d", $file->fid);
- //we loop here as future development will include multiple video types (HTML 5)
- while($row = db_fetch_object($sql)) {
- if(file_exists($row->filepath)) unlink($row->filepath);
- }
- //now delete our rows.
- db_query('DELETE FROM {video_files} WHERE fid = %d', $file->fid);
- //now lets delete our video thumbnails and folder.
- $video_thumb_path = variable_get('video_thumb_path', 'video_thumbs');
- $thumb_folder = file_directory_path(). '/' . $video_thumb_path . '/' . $file->fid;
- // Recursively delete our folder and files
- rmdirr($thumb_folder);
- // Let other modules to know about the file delete
- video_module_invoke('delete', $file);
+ //lets get all our videos and unlink them
+ $sql = db_query("SELECT filepath FROM {video_files} WHERE fid=%d", $file->fid);
+ //we loop here as future development will include multiple video types (HTML 5)
+ while ($row = db_fetch_object($sql)) {
+ if (file_exists($row->filepath))
+ unlink($row->filepath);
+ }
+ //now delete our rows.
+ db_query('DELETE FROM {video_files} WHERE fid = %d', $file->fid);
+ //now lets delete our video thumbnails and folder.
+ $video_thumb_path = variable_get('video_thumb_path', 'video_thumbs');
+ $thumb_folder = file_directory_path() . '/' . $video_thumb_path . '/' . $file->fid;
+ // Recursively delete our folder and files
+ rmdirr($thumb_folder);
+ // Let other modules to know about the file delete
+ video_module_invoke('delete', $file);
}
/**
* Compares passed extensions with normal video web extensions.
*/
function video_web_extensions($ext) {
- $extensions = array_filter(explode(' ', $ext));
- $web_extensions = array(
- 'mov', 'mp4', '3gp', '3g2', 'mpg', 'mpeg', // quicktime
- 'divx', //divx
- 'rm', // realplayer
- 'flv', 'f4v', //flash player
- 'swf', // swf player
- 'dir', 'dcr', // dcr player
- 'asf', 'wmv', 'avi', 'mpg', 'mpeg', // windows media
- 'ogg',
- 'ogv', // ogg/ogv theora
- );
- if (count(array_diff($extensions, $web_extensions))) {
- return FALSE;
- }
- return TRUE;
+ $extensions = array_filter(explode(' ', $ext));
+ $web_extensions = array(
+ 'mov', 'mp4', '3gp', '3g2', 'mpg', 'mpeg', // quicktime
+ 'divx', //divx
+ 'rm', // realplayer
+ 'flv', 'f4v', //flash player
+ 'swf', // swf player
+ 'dir', 'dcr', // dcr player
+ 'asf', 'wmv', 'avi', 'mpg', 'mpeg', // windows media
+ 'ogg',
+ 'ogv', // ogg/ogv theora
+ );
+ if (count(array_diff($extensions, $web_extensions))) {
+ return FALSE;
+ }
+ return TRUE;
}
/**
* Implementation of hook_views_api().
*/
function video_views_api() {
- return array(
- 'api' => 2.0,
- 'path' => drupal_get_path('module', 'video') . '/views',
- );
+ return array(
+ 'api' => 2.0,
+ 'path' => drupal_get_path('module', 'video') . '/views',
+ );
}
/**
@@ -418,93 +421,92 @@ function video_views_api() {
* @param <type> $element
*/
function video_widget_element_settings(&$element) {
- $file = $element['#value'];
- $delta = $element['#delta'];
- $field = content_fields($element['#field_name'], $element['#type_name']);
- // Check if using the default width and replace tokens.
- $default_dimensions = user_access('override player dimensions');
- $description = t('Set your video dimensions. This will create your player with these dimensions.');
- //setup our default dimensions.
- $dimensions = $field['widget']['default_dimensions'];
- $player_dimensions = $field['widget']['default_player_dimensions'];
- // Lets figure out our dimensions for our video and add astericks next to our options.
- $options = video_explode("\n", variable_get("video_metadata_dimensions", video_default_dimensions()));
- if ($field['widget']['autoconversion'] && isset($element['preview']) && $file['fid'] != 0 && $default_dimensions) {
- $video_info = _video_dimensions_options($options, $file['filepath']);
- $description = t('Set your video dimensions. This will create your player and transcode your video with these dimensions. Your video size is !size, if you choose a higher resolution, this could cause video distortion. You are shown dimensions that match your aspect ratio, if you choose dimensions that do not match your ratio, we will pad your video by adding black bars on either the top or bottom while maintaining your videos original aspect ratio.', array('!size' => $video_info['width'] .'x'. $video_info['height']));
- //setup our default display of dimensions.
- //lets go through our options looking for a matching resolution
- foreach($options as $key => $value) {
- if(stristr($value, t('(Matches Resolution)')) == TRUE) {
- $dimensions = $key;
- break;
- }
+ $file = $element['#value'];
+ $delta = $element['#delta'];
+ $field = content_fields($element['#field_name'], $element['#type_name']);
+ // Check if using the default width and replace tokens.
+ $default_dimensions = user_access('override player dimensions');
+ $description = t('Set your video dimensions. This will create your player with these dimensions.');
+ //setup our default dimensions.
+ $dimensions = $field['widget']['default_dimensions'];
+ $player_dimensions = $field['widget']['default_player_dimensions'];
+ // Lets figure out our dimensions for our video and add astericks next to our options.
+ $options = video_explode("\n", variable_get("video_metadata_dimensions", video_default_dimensions()));
+ if ($field['widget']['autoconversion'] && isset($element['preview']) && $file['fid'] != 0 && $default_dimensions) {
+ $video_info = _video_dimensions_options($options, $file['filepath']);
+ $description = t('Set your video dimensions. This will create your player and transcode your video with these dimensions. Your video size is !size, if you choose a higher resolution, this could cause video distortion. You are shown dimensions that match your aspect ratio, if you choose dimensions that do not match your ratio, we will pad your video by adding black bars on either the top or bottom while maintaining your videos original aspect ratio.', array('!size' => $video_info['width'] . 'x' . $video_info['height']));
+ //setup our default display of dimensions.
+ //lets go through our options looking for a matching resolution
+ foreach ($options as $key => $value) {
+ if (stristr($value, t('(Matches Resolution)')) == TRUE) {
+ $dimensions = $key;
+ break;
+ }
+ }
}
- }
- // Override our dimensions to the user selected.
- if (isset($file['data']['dimensions']) && !empty($file['data']['dimensions'])) {
- $dimensions = $file['data']['dimensions'];
- }
-
- // Override our player dimensions to the user selected.
- if (isset($file['data']['player_dimensions']) && !empty($file['data']['player_dimensions'])) {
- $player_dimensions = $file['data']['player_dimensions'];
- }
-
- $element['data']['dimensions'] = array(
- '#type' => 'select',
- '#title' => t('Dimensions for Video Transcoding'),
- '#default_value' => $dimensions,
- '#description' => $description,
- '#options' => $options,
- );
- $element['data']['player_dimensions'] = array(
- '#type' => 'select',
- '#title' => t('Dimensions for Video Player'),
- '#default_value' => $player_dimensions,
- '#description' => t('WxH of your video player.'),
- '#options' => $options,
- );
- // If users cannot change the default dimensions, lets change this to a value.
- if (!$default_dimensions) {
- $element['data']['dimensions']['#type'] = 'value';
- $element['data']['dimensions']['#value'] = $dimensions;
- $element['data']['player_dimensions']['#type'] = 'value';
- $element['data']['player_dimensions']['#value'] = $player_dimensions;
- }
-
- // only in preview mode and then create thumbnails
- if ($field['widget']['autoconversion']) {
- if (user_access('bypass conversion video')) {
- $element['data']['bypass_autoconversion'] = array(
- '#type' => 'checkbox',
- '#title' => t('Bypass auto conversion'),
- '#default_value' => isset($file['data']['bypass_autoconversion']) ? $file['data']['bypass_autoconversion'] : variable_get('video_bypass_conversion', FALSE),
- '#description' => t('This will bypass your auto conversion of videos.'),
- '#attributes' => array('class' => 'video-bypass-auto-conversion'),
- );
+ // Override our dimensions to the user selected.
+ if (isset($file['data']['dimensions']) && !empty($file['data']['dimensions'])) {
+ $dimensions = $file['data']['dimensions'];
}
- $convert_on_submission = user_access('convert on submission');
- $element['data']['convert_video_on_save'] = array(
- '#type' => $convert_on_submission ? 'checkbox' : 'value',
- '#title' => t('Convert video on save'),
- '#default_value' => isset($file['data']['convert_video_on_save']) ? $file['data']['convert_video_on_save'] : variable_get('video_convert_on_save', FALSE),
- '#description' => t('This will convert your video to flv format when you save, instead of scheduling it for cron.'),
- '#attributes' => array('class' => 'video-convert-video-on-save'),
- );
- $use_default_thumb = user_access('use default thumb');
- if ($use_default_thumb) {
- $element['data']['use_default_video_thumb'] = array(
- '#type' => $use_default_thumb ? 'checkbox' : 'value',
- '#title' => t('Use the default thumbnail for this video?'),
- '#default_value' => isset($file['data']['use_default_video_thumb']) ? $file['data']['use_default_video_thumb'] : variable_get('video_use_default_thumb', FALSE),
- '#description' => t('This will set a flag for this video to use the default video thumbnail when outputed..'),
- '#attributes' => array('class' => 'video-use-default-video-thumb'),
- );
+
+ // Override our player dimensions to the user selected.
+ if (isset($file['data']['player_dimensions']) && !empty($file['data']['player_dimensions'])) {
+ $player_dimensions = $file['data']['player_dimensions'];
+ }
+
+ $element['data']['dimensions'] = array(
+ '#type' => 'select',
+ '#title' => t('Dimensions for Video Transcoding'),
+ '#default_value' => $dimensions,
+ '#description' => $description,
+ '#options' => $options,
+ );
+ $element['data']['player_dimensions'] = array(
+ '#type' => 'select',
+ '#title' => t('Dimensions for Video Player'),
+ '#default_value' => $player_dimensions,
+ '#description' => t('WxH of your video player.'),
+ '#options' => $options,
+ );
+ // If users cannot change the default dimensions, lets change this to a value.
+ if (!$default_dimensions) {
+ $element['data']['dimensions']['#type'] = 'value';
+ $element['data']['dimensions']['#value'] = $dimensions;
+ $element['data']['player_dimensions']['#type'] = 'value';
+ $element['data']['player_dimensions']['#value'] = $player_dimensions;
}
- }
-}
+ // only in preview mode and then create thumbnails
+ if ($field['widget']['autoconversion']) {
+ if (user_access('bypass conversion video')) {
+ $element['data']['bypass_autoconversion'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Bypass auto conversion'),
+ '#default_value' => isset($file['data']['bypass_autoconversion']) ? $file['data']['bypass_autoconversion'] : variable_get('video_bypass_conversion', FALSE),
+ '#description' => t('This will bypass your auto conversion of videos.'),
+ '#attributes' => array('class' => 'video-bypass-auto-conversion'),
+ );
+ }
+ $convert_on_submission = user_access('convert on submission');
+ $element['data']['convert_video_on_save'] = array(
+ '#type' => $convert_on_submission ? 'checkbox' : 'value',
+ '#title' => t('Convert video on save'),
+ '#default_value' => isset($file['data']['convert_video_on_save']) ? $file['data']['convert_video_on_save'] : variable_get('video_convert_on_save', FALSE),
+ '#description' => t('This will convert your video to flv format when you save, instead of scheduling it for cron.'),
+ '#attributes' => array('class' => 'video-convert-video-on-save'),
+ );
+ $use_default_thumb = user_access('use default thumb');
+ if ($use_default_thumb) {
+ $element['data']['use_default_video_thumb'] = array(
+ '#type' => $use_default_thumb ? 'checkbox' : 'value',
+ '#title' => t('Use the default thumbnail for this video?'),
+ '#default_value' => isset($file['data']['use_default_video_thumb']) ? $file['data']['use_default_video_thumb'] : variable_get('video_use_default_thumb', FALSE),
+ '#description' => t('This will set a flag for this video to use the default video thumbnail when outputed..'),
+ '#attributes' => array('class' => 'video-use-default-video-thumb'),
+ );
+ }
+ }
+}
/**
* Video_widgi_process for API handlers for any video types.
@@ -512,236 +514,239 @@ function video_widget_element_settings(&$element) {
* @param <type> $form_state
*/
function video_widget_process($element, &$form_state) {
- $item = $element['#value'];
- switch($form_state['clicked_button']['#submit'][0]) {
- case 'node_form_submit':
- // Auto convert our video file
- if($field['widget']['autoconversion']) {
- video_convert_process($element);
- //lets set our node status to unpublished if our video is not converted.
- if ($element['#unpublish']) {
- //unpublish the node
- $form_state['values']['status'] = 0;
- }
- }
- // Call hook_video_submit API
- video_module_invoke('insert', $element, $form_state);
- //
- //queue up the file id to update the node id in the video rendering / cdn tables.
- $form_state['values']['video_id'][] = $item['fid'];
- break;
- case 'node_form_build_preview':
- // Call hook_video_preview API
- video_module_invoke('preview', &$element, &$form_state);
- break;
- case 'node_form_delete_submit':
- //moved to hook_file_delete in video module.
- break;
- }
+ $item = $element['#value'];
+ switch ($form_state['clicked_button']['#submit'][0]) {
+ case 'node_form_submit':
+ // Auto convert our video file
+ if ($field['widget']['autoconversion']) {
+ video_convert_process($element);
+ //lets set our node status to unpublished if our video is not converted.
+ if ($element['#unpublish']) {
+ //unpublish the node
+ $form_state['values']['status'] = 0;
+ }
+ }
+ // Call hook_video_submit API
+ video_module_invoke('insert', $element, $form_state);
+ //
+ //queue up the file id to update the node id in the video rendering / cdn tables.
+ $form_state['values']['video_id'][] = $item['fid'];
+ break;
+ case 'node_form_build_preview':
+ // Call hook_video_preview API
+ video_module_invoke('preview', &$element, &$form_state);
+ break;
+ case 'node_form_delete_submit':
+ //moved to hook_file_delete in video module.
+ break;
+ }
}
/*
* Function updates our options list to show matching aspect ratios and if we have a matching resolution.
*
* We will update the options array by reference and return the aspect ratio of the file.
-*/
+ */
+
function _video_dimensions_options(&$options, $video) {
- $aspect_ratio = _video_aspect_ratio($video);
- //loop through our options and find matching ratio's and also the exact width/height
- foreach($options as $key => $value) {
- $wxh = explode('x', $value);
- //lets check our width and height first
- if($aspect_ratio['width'] == $wxh[0] && $aspect_ratio['height'] == $wxh[1]) {
- $options[$key] = $value .' '.t('(Matches Resolution)');
- }
- else {
- //now lets check our ratio's
- $ratio = number_format($wxh[0] / $wxh[1], 4);
- if($ratio == $aspect_ratio['ratio']) {
- $options[$key] = $value .' '.t('(Matches Ratio)');
- }
+ $aspect_ratio = _video_aspect_ratio($video);
+ //loop through our options and find matching ratio's and also the exact width/height
+ foreach ($options as $key => $value) {
+ $wxh = explode('x', $value);
+ //lets check our width and height first
+ if ($aspect_ratio['width'] == $wxh[0] && $aspect_ratio['height'] == $wxh[1]) {
+ $options[$key] = $value . ' ' . t('(Matches Resolution)');
+ } else {
+ //now lets check our ratio's
+ $ratio = number_format($wxh[0] / $wxh[1], 4);
+ if ($ratio == $aspect_ratio['ratio']) {
+ $options[$key] = $value . ' ' . t('(Matches Ratio)');
+ }
+ }
}
- }
- return $aspect_ratio;
+ return $aspect_ratio;
}
/*
* Returns the width/height and aspect ratio of the video
*
* @todo: move this to the transcoder class instead?
-*/
+ */
+
function _video_aspect_ratio($video) {
- //lets get our video dimensions from the file
- module_load_include('inc', 'video', '/includes/transcoder');
- $transcoder = new video_transcoder;
- $wxh = $transcoder->get_dimensions($video);
- $width = $wxh['width'];
- $height = $wxh['height'];
-
- if(!$width || !$height) {
- //no width and height found just return.
- watchdog('video_conversion', 'We could not determine the height and width of the video: '.$video, array(), WATCHDOG_DEBUG);
- drupal_set_message(t('The system counld not determine the width and height of your video: !video. If transcoding, the system could have problems.', array('!video' => $video)));
- return;
- }
-
- //now lets get aspect ratio and compare our options in the select dropdown then add an asterick if any to each option representing a matching aspect ratio.
- $ratio = number_format($width / $height, 4);
- $aspect_ratio = array(
- 'width' => $width,
- 'height' => $height,
- 'ratio' => $ratio,
- );
- return $aspect_ratio;
+ //lets get our video dimensions from the file
+ module_load_include('inc', 'video', '/includes/transcoder');
+ $transcoder = new video_transcoder;
+ $wxh = $transcoder->get_dimensions($video);
+ $width = $wxh['width'];
+ $height = $wxh['height'];
+
+ if (!$width || !$height) {
+ //no width and height found just return.
+ watchdog('video_conversion', 'We could not determine the height and width of the video: ' . $video, array(), WATCHDOG_DEBUG);
+ drupal_set_message(t('The system counld not determine the width and height of your video: !video. If transcoding, the system could have problems.', array('!video' => $video)));
+ return;
+ }
+
+ //now lets get aspect ratio and compare our options in the select dropdown then add an asterick if any to each option representing a matching aspect ratio.
+ $ratio = number_format($width / $height, 4);
+ $aspect_ratio = array(
+ 'width' => $width,
+ 'height' => $height,
+ 'ratio' => $ratio,
+ );
+ return $aspect_ratio;
}
/*
* Return our list of video extensions and their associated player.
-*/
+ */
+
function video_video_extensions() {
- $extensions = array(
- 'divx' => 'video_play_divx',
- 'mov' => 'video_play_quicktime',
- '3gp' => 'video_play_quicktime',
- '3g2' => 'video_play_quicktime',
- 'mp4' => 'video_play_quicktime',
- 'rm' => 'video_play_realmedia',
- 'f4v' => 'video_play_flv',
- 'flv' => 'video_play_flv',
- 'swf' => 'video_play_flash',
- 'dir' => 'video_play_dcr',
- 'dcr' => 'video_play_dcr',
- 'asf' => 'video_play_windowsmedia',
- 'wmv' => 'video_play_windowsmedia',
- 'avi' => 'video_play_windowsmedia',
- 'mpg' => 'video_play_windowsmedia',
- 'mpeg' => 'video_play_windowsmedia',
- 'ogg' => 'video_play_theora',
- 'ogv' => 'video_play_theora',
- );
- return $extensions;
+ $extensions = array(
+ 'divx' => 'video_play_divx',
+ 'mov' => 'video_play_quicktime',
+ '3gp' => 'video_play_quicktime',
+ '3g2' => 'video_play_quicktime',
+ 'mp4' => 'video_play_quicktime',
+ 'rm' => 'video_play_realmedia',
+ 'f4v' => 'video_play_flv',
+ 'flv' => 'video_play_flv',
+ 'swf' => 'video_play_flash',
+ 'dir' => 'video_play_dcr',
+ 'dcr' => 'video_play_dcr',
+ 'asf' => 'video_play_windowsmedia',
+ 'wmv' => 'video_play_windowsmedia',
+ 'avi' => 'video_play_windowsmedia',
+ 'mpg' => 'video_play_windowsmedia',
+ 'mpeg' => 'video_play_windowsmedia',
+ 'ogg' => 'video_play_theora',
+ 'ogv' => 'video_play_theora',
+ );
+ return $extensions;
}
/*
* Return our supported video players.
-*/
+ */
+
function video_video_players() {
- $players = array(
- 'video_play_divx' => t('Divx Player'),
- 'video_play_quicktime' => t('Quicktime'),
- 'video_play_realmedia' => t('Real Media Player'),
- 'video_play_flv' => t('FLV Flash Players'),
- 'video_play_flash' => t('SWF Flash Player'),
- 'video_play_dcr' => t('Director/Shockwave'),
- 'video_play_windowsmedia' => t('Windows Media Player'),
- 'video_play_theora' => t('Theora Player'),
- );
- return $players;
+ $players = array(
+ 'video_play_divx' => t('Divx Player'),
+ 'video_play_quicktime' => t('Quicktime'),
+ 'video_play_realmedia' => t('Real Media Player'),
+ 'video_play_flv' => t('FLV Flash Players'),
+ 'video_play_flash' => t('SWF Flash Player'),
+ 'video_play_dcr' => t('Director/Shockwave'),
+ 'video_play_windowsmedia' => t('Windows Media Player'),
+ 'video_play_theora' => t('Theora Player'),
+ );
+ return $players;
}
/*
* Return our possible flash players.
-*/
+ */
+
function video_video_flv_players() {
- $options = array();
- if(module_exists('swftools')) {
- $options['swftools'] = t('SWF Tools');
- }
- if(module_exists('flowplayer')) {
- $options['flowplayer'] = t('Flowplayer');
- }
- return $options;
+ $options = array();
+ if (module_exists('swftools')) {
+ $options['swftools'] = t('SWF Tools');
+ }
+ if (module_exists('flowplayer')) {
+ $options['flowplayer'] = t('Flowplayer');
+ }
+ return $options;
}
/**
* Get the object for the suitable player for the parameter resource
*/
function video_get_player($element) {
- // Setup our node object to be passed along with the player.
- $node = $element['#node'];
- // Setup our video object
- module_load_include('inc', 'video', '/includes/video_helper');
- $video_helper = new video_helper;
- $video = $video_helper->video_object($element);
- // Lets spit out our theme based on the extension
- $defaults = video_video_extensions();
- $theme_function = variable_get('video_extension_'. $video->extension, $defaults[$video->extension]);
- // Lets do some special handling for our flv files to accomdate multiple players.
- if($theme_function == 'video_play_flv') {
- return theme('video_flv', $video, $node);
- }
- else {
- return theme($theme_function, $video, $node);
- }
+ // Setup our node object to be passed along with the player.
+ $node = $element['#node'];
+ // Setup our video object
+ module_load_include('inc', 'video', '/includes/video_helper');
+ $video_helper = new video_helper;
+ $video = $video_helper->video_object($element);
+ // Lets spit out our theme based on the extension
+ $defaults = video_video_extensions();
+ $theme_function = variable_get('video_extension_' . $video->extension, $defaults[$video->extension]);
+ // Lets do some special handling for our flv files to accomdate multiple players.
+ if ($theme_function == 'video_play_flv') {
+ return theme('video_flv', $video, $node);
+ } else {
+ return theme($theme_function, $video, $node);
+ }
}
function video_default_widget_settings($widget) {
- $form = array();
- // Default video settings.
- $form['plugins'] = array(
- '#type' => 'fieldset',
- '#title' => t('Video Advanced Settings'),
- '#collapsible' => TRUE,
- '#collapsed' => FALSE,
- '#weight' => 10
- );
- $form['plugins']['default_dimensions'] = array(
- '#type' => 'select',
- '#title' => t('Default Video Resolution Dimensions'),
- '#default_value' => !empty($widget['default_dimensions']) ? $widget['default_dimensions'] : '',
- '#options' => video_explode("\n", variable_get("video_metadata_dimensions", video_default_dimensions())),
- '#description' => t('Default transcoding resolution WIDTHxHEIGHT, in px, that FFMPEG will use to transcode your video files.')
- );
- $form['plugins']['default_player_dimensions'] = array(
- '#type' => 'select',
- '#title' => t('Default Video Player Dimensions'),
- '#default_value' => !empty($widget['default_player_dimensions']) ? $widget['default_player_dimensions'] : '',
- '#options' => video_explode("\n", variable_get("video_metadata_dimensions", video_default_dimensions())),
- '#description' => t('Default player WIDTHxHEIGHT in px. This is your actual player dimensions that your video will be playing in.')
- );
- $form['plugins']['autoconversion'] = array(
- '#type' => 'checkbox',
- '#title' => t('Enable video conversion.'),
- '#description' => t('Use ffmpeg(Default) to automatically convert videos to web compatible types eg. FLV, Please make sure to configure your transcoder settings.'),
- '#default_value' => $widget['autoconversion'],
- );
- $form['plugins']['autothumbnail'] = array(
- '#type' => 'checkbox',
- '#title' => t('Enable thumbnail creation.'),
- '#description' => t('Use ffmpeg(Default) to create thumbnails, Please make sure to configure your transcoder settings.'),
- '#default_value' => $widget['autothumbnail'],
- );
- // Default thumbnail settings.
- $form['default'] = array(
- '#type' => 'fieldset',
- '#title' => t('Video Thumbnail Settings'),
- '#element_validate' => array('video_default_widget_settings_validate'),
- '#collapsible' => TRUE,
- '#collapsed' => FALSE,
- '#weight' => 11
- );
- // @TODO: Move this to the actual upload/attach when creating a node to allow the user to upload their own thumbnail for each video.
- // Present a video image of the current default image.
- if (!empty($widget['default_video_thumb'])) {
- $form['default']['default_video_thumbnail'] = array(
- '#type' => 'markup',
- '#value' => theme('video_image', $widget['default_video_thumb'], '', '', array('width' => '150'), FALSE),
- '#prefix' => '<div class="video_thumbnail">',
- '#suffix' => '</div>'
- );
- }
- $form['default']['default_video_thumb_upload'] = array(
- '#type' => 'file',
- '#title' => empty($widget['default_video_thumb']) ? t('Upload default video thumbnail') : t('Replace default video thumbnail with'),
- '#description' => t('Choose a image that will be used as video thumbnail when you don\'t have video thumbnails for videos.'),
- );
- // We set this value on 'validate' so we can get CCK to add it
- // as a standard field setting.
- $form['default_video_thumb'] = array(
- '#type' => 'value',
- '#value' => $widget['default_video_thumb'],
- );
- return $form;
+ $form = array();
+ // Default video settings.
+ $form['plugins'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Video Advanced Settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+ '#weight' => 10
+ );
+ $form['plugins']['default_dimensions'] = array(
+ '#type' => 'select',
+ '#title' => t('Default Video Resolution Dimensions'),
+ '#default_value' => !empty($widget['default_dimensions']) ? $widget['default_dimensions'] : '',
+ '#options' => video_explode("\n", variable_get("video_metadata_dimensions", video_default_dimensions())),
+ '#description' => t('Default transcoding resolution WIDTHxHEIGHT, in px, that FFMPEG will use to transcode your video files.')
+ );
+ $form['plugins']['default_player_dimensions'] = array(
+ '#type' => 'select',
+ '#title' => t('Default Video Player Dimensions'),
+ '#default_value' => !empty($widget['default_player_dimensions']) ? $widget['default_player_dimensions'] : '',
+ '#options' => video_explode("\n", variable_get("video_metadata_dimensions", video_default_dimensions())),
+ '#description' => t('Default player WIDTHxHEIGHT in px. This is your actual player dimensions that your video will be playing in.')
+ );
+ $form['plugins']['autoconversion'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable video conversion.'),
+ '#description' => t('Use ffmpeg(Default) to automatically convert videos to web compatible types eg. FLV, Please make sure to configure your transcoder settings.'),
+ '#default_value' => $widget['autoconversion'],
+ );
+ $form['plugins']['autothumbnail'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable thumbnail creation.'),
+ '#description' => t('Use ffmpeg(Default) to create thumbnails, Please make sure to configure your transcoder settings.'),
+ '#default_value' => $widget['autothumbnail'],
+ );
+ // Default thumbnail settings.
+ $form['default'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Video Thumbnail Settings'),
+ '#element_validate' => array('video_default_widget_settings_validate'),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+ '#weight' => 11
+ );
+ // @TODO: Move this to the actual upload/attach when creating a node to allow the user to upload their own thumbnail for each video.
+ // Present a video image of the current default image.
+ if (!empty($widget['default_video_thumb'])) {
+ $form['default']['default_video_thumbnail'] = array(
+ '#type' => 'markup',
+ '#value' => theme('video_image', $widget['default_video_thumb'], '', '', array('width' => '150'), FALSE),
+ '#prefix' => '<div class="video_thumbnail">',
+ '#suffix' => '</div>'
+ );
+ }
+ $form['default']['default_video_thumb_upload'] = array(
+ '#type' => 'file',
+ '#title' => empty($widget['default_video_thumb']) ? t('Upload default video thumbnail') : t('Replace default video thumbnail with'),
+ '#description' => t('Choose a image that will be used as video thumbnail when you don\'t have video thumbnails for videos.'),
+ );
+ // We set this value on 'validate' so we can get CCK to add it
+ // as a standard field setting.
+ $form['default_video_thumb'] = array(
+ '#type' => 'value',
+ '#value' => $widget['default_video_thumb'],
+ );
+ return $form;
}
/**
@@ -749,79 +754,84 @@ function video_default_widget_settings($widget) {
*
*/
function video_default_widget_settings_validate($element, &$form_state) {
- // Verify the destination exists
- $destination = file_directory_path() .'/video_thumbs';
- if (!field_file_check_directory($destination, FILE_CREATE_DIRECTORY)) {
- form_set_error('default_video_thumb', t('The default image could not be uploaded. The destination %destination does not exist or is not writable by the server.', array('%destination' => dirname($destination))));
- return;
- }
-
- $validators = array (
- 'file_validate_is_image' => array(),
- );
-
- // We save the upload here because we can't know the correct path until the file is saved.
- if (!$file = file_save_upload('default_video_thumb_upload', $validators, $destination)) {
- // No upload to save we hope... or file_save_upload() reported an error on its own.
- return;
- }
-
- // Remove old image (if any) & clean up database.
- $old_default = $form_state['values']['default_video_thumb'];
- if (!empty($old_default['fid'])) {
- if (file_delete(file_create_path($old_default['filepath']))) {
- db_query('DELETE FROM {files} WHERE fid=%d', $old_default['fid']);
+ // Verify the destination exists
+ $destination = file_directory_path() . '/video_thumbs';
+ if (!field_file_check_directory($destination, FILE_CREATE_DIRECTORY)) {
+ form_set_error('default_video_thumb', t('The default image could not be uploaded. The destination %destination does not exist or is not writable by the server.', array('%destination' => dirname($destination))));
+ return;
}
- }
- // Make the file permanent and store it in the form.
- file_set_status($file, FILE_STATUS_PERMANENT);
- $file->timestamp = time();
- $form_state['values']['default_video_thumb'] = (array)$file;
+ $validators = array(
+ 'file_validate_is_image' => array(),
+ );
+
+ // We save the upload here because we can't know the correct path until the file is saved.
+ if (!$file = file_save_upload('default_video_thumb_upload', $validators, $destination)) {
+ // No upload to save we hope... or file_save_upload() reported an error on its own.
+ return;
+ }
+
+ // Remove old image (if any) & clean up database.
+ $old_default = $form_state['values']['default_video_thumb'];
+ if (!empty($old_default['fid'])) {
+ if (file_delete(file_create_path($old_default['filepath']))) {
+ db_query('DELETE FROM {files} WHERE fid=%d', $old_default['fid']);
+ }
+ }
+
+ // Make the file permanent and store it in the form.
+ file_set_status($file, FILE_STATUS_PERMANENT);
+ $file->timestamp = REQUEST_TIME;
+ $form_state['values']['default_video_thumb'] = (array) $file;
}
function video_widget_settings_file_path_validate($element, &$form_state) {
- //lets prepend our video folder to the path settings. first truncate videos/ off the end if it exists.
- $form_state['values']['file_path'] = 'videos/'. $form_state['values']['file_path'];
+ //lets prepend our video folder to the path settings. first truncate videos/ off the end if it exists.
+ $form_state['values']['file_path'] = 'videos/' . $form_state['values']['file_path'];
}
/*
* #options helper function to set our key=value for the form api.
-*/
+ */
+
function video_explode($delimeter, $dimensions) {
- $options = array();
- $values = explode($delimeter, $dimensions);
- foreach($values as $value) {
- //lets check we have a value and its in the right format
- if(!empty($value) && video_format_right($value)) {
- $options[trim($value)] = trim($value);
+ $options = array();
+ $values = explode($delimeter, $dimensions);
+ foreach ($values as $value) {
+ //lets check we have a value and its in the right format
+ if (!empty($value) && video_format_right($value)) {
+ $options[trim($value)] = trim($value);
+ }
}
- }
- return $options;
+ return $options;
}
function video_format_right($value) {
- $format = explode("x", $value);
- if(!isset($format[0]) || !is_numeric(trim($format[0]))) return false;
- if(!isset($format[1]) || !is_numeric(trim($format[1]))) return false;
- return true;
+ $format = explode("x", $value);
+ if (!isset($format[0]) || !is_numeric(trim($format[0])))
+ return false;
+ if (!isset($format[1]) || !is_numeric(trim($format[1])))
+ return false;
+ return true;
}
/*
* Default video dimensions.
-*/
+ */
+
function video_default_dimensions() {
- return "176x144\n352x288\n704x576\n1408x1152\n128x96\n160x120\n320x240\n640x480\n800x600\n1024x768\n1600x1200\n2048x1024\n1280x1024\n2560x2048\n5120x4096\n852x480\n1366x768\n1600x1024\n1920x1200\n2560x1600\n3200x2048\n3840x2400\n6400x4096\n7680x4800\n320x200\n640x350\n852x480\n1280x720\n1920x1080";
+ return "176x144\n352x288\n704x576\n1408x1152\n128x96\n160x120\n320x240\n640x480\n800x600\n1024x768\n1600x1200\n2048x1024\n1280x1024\n2560x2048\n5120x4096\n852x480\n1366x768\n1600x1024\n1920x1200\n2560x1600\n3200x2048\n3840x2400\n6400x4096\n7680x4800\n320x200\n640x350\n852x480\n1280x720\n1920x1080";
}
/*
* Utility function to remove all files and directories recursively.
-*/
+ */
+
function rmdirr($dir) {
- if($objs = glob($dir."/*")) {
- foreach($objs as $obj) {
- is_dir($obj)? rmdirr($obj) : unlink($obj);
+ if ($objs = glob($dir . "/*")) {
+ foreach ($objs as $obj) {
+ is_dir($obj) ? rmdirr($obj) : unlink($obj);
+ }
}
- }
- @rmdir($dir);
+ @rmdir($dir);
}