? .pc ? 6.x.patch ? LICENSE.txt ? add_translation.patch ? patches ? rm_po.patch ? translations ? plugins/video_image/video_image.install ? types/video_upload/video_upload.install Index: hooks.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/hooks.php,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 hooks.php --- hooks.php 18 Feb 2008 10:08:37 -0000 1.1.4.2 +++ hooks.php 16 Dec 2008 05:24:33 -0000 @@ -1,6 +1,51 @@ 'image_button', + '#title' => t('My button'), + '#return_value' => 'my_data', + '#src' => 'my/image/path.jpg', +); */ + +/* TODO New user_mail_tokens() method may be useful. + user.module now provides a user_mail_tokens() function to return an array + of the tokens available for the email notification messages it sends when + accounts are created, activated, blocked, etc. Contributed modules that + wish to make use of the same tokens for their own needs are encouraged + to use this function. */ + +/* TODO + There is a new hook_watchdog in core. This means that contributed modules + can implement hook_watchdog to log Drupal events to custom destinations. + Two core modules are included, dblog.module (formerly known as watchdog.module), + and syslog.module. Other modules in contrib include an emaillog.module, + included in the logging_alerts module. See syslog or emaillog for an + example on how to implement hook_watchdog. +function example_watchdog($log = array()) { + if ($log['severity'] == WATCHDOG_ALERT) { + mysms_send($log['user']->uid, + $log['type'], + $log['message'], + $log['variables'], + $log['severity'], + $log['referer'], + $log['ip'], + format_date($log['timestamp'])); + } +} */ + +/* TODO Implement the hook_theme registry. Combine all theme registry entries + into one hook_theme function in each corresponding module file. +function hooks_theme() { + return array( + ); +} */ + /** * @file * The video module has some hooks which should make adding Index: video.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/video.info,v retrieving revision 1.2 diff -u -r1.2 video.info --- video.info 11 Nov 2006 03:58:40 -0000 1.2 +++ video.info 16 Dec 2008 05:24:33 -0000 @@ -2,3 +2,11 @@ name = Video description = Allows video nodes. package = "Video" + +; Information added by drupal.org packaging script on 2008-04-09 +version = "5.x-1.x-dev" +project = "video" +datestamp = "1207700333" + + +core = 6.x \ No newline at end of file Index: video.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/video.install,v retrieving revision 1.3.2.5 diff -u -r1.3.2.5 video.install --- video.install 5 Mar 2008 14:31:52 -0000 1.3.2.5 +++ video.install 16 Dec 2008 05:24:33 -0000 @@ -1,70 +1,177 @@ t('Video module table'), + 'fields' => array( + 'vid' => array( + 'description' => t('node version id'), + 'type' => 'int', + 'unsigned' => 1, + 'not null' => TRUE, + 'default' => 0, + ), + 'nid' => array( + 'description' => t('node id'), + 'type' => 'int', + 'unsigned' => 1, + 'not null' => TRUE, + 'default' => 0, + ), + 'vtype' => array( + 'description' => t('video type'), + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE, + 'default' => '', + ), + 'vidfile' => array( + 'description' => t('video file uri'), + 'type' => 'text', + 'not null' => TRUE, + 'default' => '', + ), + 'videox' => array( + 'description' => t('video width in pixels'), + 'type' => 'int', + 'size' => 'small', + 'unsigned' => 1, + 'not null' => TRUE, + 'default' => 0, + ), + 'videoy' => array( + 'description' => t('video height in pixels'), + 'type' => 'int', + 'size' => 'small', + 'unsigned' => 1, + 'not null' => TRUE, + 'default' => 0, + ), + 'size' => array( + 'description' => t('video file size'), + 'type' => 'int', + 'size' => 'big', + 'unsigned' => 1, + 'not null' => FALSE, + ), + 'download_counter' => array( + 'description' => t('number of downloads'), + 'type' => 'int', + 'unsigned' => 1, + 'not null' => TRUE, + 'default' => 0, + ), + 'play_counter' => array( + 'description' => t('times played'), + 'type' => 'int', + 'unsigned' => 1, + 'not null' => TRUE, + 'default' => 0, + ), + 'video_bitrate' => array( + 'description' => t('video bitrate'), + 'type' => 'int', + 'unsigned' => 1, + 'not null' => FALSE, + ), + 'audio_bitrate' => array( + 'description' => t('audio bitrate'), + 'type' => 'int', + 'unsigned' => 1, + 'not null' => FALSE, + ), + 'audio_sampling_rate' => array( + 'description' => t('audio sampling rate'), + 'type' => 'int', + 'unsigned' => 1, + 'not null' => FALSE, + ), + 'audio_channels' => array( + 'description' => t('number of audio channels'), + 'type' => 'int', + 'not null' => FALSE, + ), + 'playtime_seconds' => array( + 'description' => t('playtime in seconds'), + 'type' => 'int', + 'unsigned' => 1, + 'not null' => FALSE, + ), + 'download_folder' => array( + 'description' => t('download folder'), + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'disable_multidownload' => array( + 'description' => t('allow multiple ways to download'), + 'type' => 'int', + 'size' => 'tiny', + 'unsigned' => 1, + 'not null' => TRUE, + 'default' => 0, + ), + 'use_play_folder' => array( + 'description' => t('use play folder'), + 'type' => 'int', + 'size' => 'tiny', + 'unsigned' => 1, + 'not null' => TRUE, + 'default' => 0, + ), + 'custom_field_1' => array( + 'description' => t('custom field 1'), + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'custom_field_2' => array( + 'description' => t('custom field 2'), + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'custom_field_3' => array( + 'description' => t('custom field 3'), + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'custom_field_4' => array( + 'description' => t('custom field 4'), + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'custom_field_5' => array( + 'description' => t('custom field 5'), + 'type' => 'text', + 'not null' => FALSE, + ), + 'custom_field_6' => array( + 'description' => t('custom field 6'), + 'type' => 'text', + 'not null' => FALSE, + ), + 'serialized_data' => array( + 'description' => t('serialized data'), + 'type' => 'text', + 'not null' => FALSE, + ), + ), + 'primary key' => array('vid'), + ); + + return $schema; +} + // ex: set syntax=php tabstop=2 expandtab shiftwidth=2 softtabstop=2: function video_install() { - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - db_query("CREATE TABLE {video} ( - vid int(10) unsigned NOT NULL default '0', - nid int(10) unsigned NOT NULL default '0', - vtype varchar(32) NOT NULL default '', - vidfile text NOT NULL default '', - videox smallint(4) unsigned NOT NULL default '0', - videoy smallint(4) unsigned NOT NULL default '0', - size bigint(13) unsigned default NULL, - download_counter int(10) unsigned NOT NULL default '0', - play_counter int(10) unsigned NOT NULL default '0', - video_bitrate int(10) unsigned default NULL, - audio_bitrate int(10) unsigned default NULL, - audio_sampling_rate int(10) unsigned default NULL, - audio_channels enum('','5.1','stereo','mono') default NULL, - playtime_seconds int(10) unsigned default NULL, - download_folder varchar(255) NULL default NULL, - disable_multidownload tinyint(1) unsigned NOT NULL default '0', - use_play_folder tinyint(1) unsigned NOT NULL default '0', - custom_field_1 varchar(255) NULL default NULL, - custom_field_2 varchar(255) NULL default NULL, - custom_field_3 varchar(255) NULL default NULL, - custom_field_4 varchar(255) NULL default NULL, - custom_field_5 text NULL default NULL, - custom_field_6 text NULL default NULL, - serialized_data text NULL default NULL, - PRIMARY KEY (vid) - ) TYPE=MyISAM COMMENT='size is in bytes' /*!40100 DEFAULT CHARACTER SET utf8 */;"); - break; - case 'pgsql': - db_query("CREATE TABLE {video} ( - vid integer NOT NULL default '0', - nid integer NOT NULL default '0', - vtype varchar(32) NOT NULL default '', - vidfile text NOT NULL default '', - videox smallint NOT NULL default '0', - videoy smallint NOT NULL default '0', - size bigint default NULL, - download_counter integer NOT NULL default '0', - play_counter integer NOT NULL default '0', - video_bitrate integer default NULL, - audio_bitrate integer default NULL, - audio_sampling_rate integer default NULL, - audio_channels varchar(10) default NULL, - playtime_seconds integer default NULL, - download_folder varchar(255) NULL default NULL, - disable_multidownload smallint NOT NULL default '0', - use_play_folder smallint NOT NULL default '0', - custom_field_1 varchar(255) NULL default NULL, - custom_field_2 varchar(255) NULL default NULL, - custom_field_3 varchar(255) NULL default NULL, - custom_field_4 varchar(255) NULL default NULL, - custom_field_5 text NULL default NULL, - custom_field_6 text NULL default NULL, - serialized_data text NULL default NULL, - PRIMARY KEY (vid) - );"); - - } - + drupal_install_schema('video'); // default values for some variables use for resolution stuff variable_set('video_resolution_1_name', '4:3 - Television'); variable_set('video_resolution_1_value', '400x300'); @@ -77,113 +184,27 @@ * * @return array */ -function video_update_1() { - $ret = array(); - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - $ret[] = update_sql("ALTER TABLE {video} CHANGE videox videox smallint(4) NOT NULL default '0'"); - $ret[] = update_sql("ALTER TABLE {video} CHANGE videoy videoy smallint(4) NOT NULL default '0'"); - $ret[] = update_sql('ALTER TABLE {video} CHANGE size size bigint(13) default NULL'); - $ret[] = update_sql('ALTER TABLE {video} ADD video_bitrate int(11) default NULL'); - $ret[] = update_sql('ALTER TABLE {video} ADD audio_bitrate int(11) default NULL'); - $ret[] = update_sql('ALTER TABLE {video} ADD audio_sampling_rate int(11) default NULL'); - $ret[] = update_sql("ALTER TABLE {video} ADD audio_channels enum('','stereo','mono') default NULL"); - $ret[] = update_sql('ALTER TABLE {video} ADD playtime_seconds int(11) default NULL'); - } - return $ret; -} - /** * Rename counter, add custom fields, for video.module version 1.9 * * @return array */ -function video_update_2() { - $ret = array(); - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - $ret[] = update_sql("ALTER TABLE {video} CHANGE clicks download_counter int(10) unsigned NOT NULL default '0'"); - $ret[] = update_sql("ALTER TABLE {video} ADD play_counter int(10) unsigned NOT NULL default '0' AFTER download_counter"); - $ret[] = update_sql("ALTER TABLE {video} CHANGE audio_channels audio_channels enum('','5.1','stereo','mono') default NULL"); - $ret[] = update_sql('ALTER TABLE {video} ADD download_folder varchar(255) NULL default NULL'); - $ret[] = update_sql("ALTER TABLE {video} ADD disable_multidownload tinyint(1) NOT NULL default '0'"); - $ret[] = update_sql("ALTER TABLE {video} ADD use_play_folder tinyint(1) NOT NULL default '0'"); - $ret[] = update_sql('ALTER TABLE {video} ADD custom_field_1 varchar(255) NULL default NULL'); - $ret[] = update_sql('ALTER TABLE {video} ADD custom_field_2 varchar(255) NULL default NULL'); - $ret[] = update_sql('ALTER TABLE {video} ADD custom_field_3 varchar(255) NULL default NULL'); - $ret[] = update_sql('ALTER TABLE {video} ADD custom_field_4 varchar(255) NULL default NULL'); - $ret[] = update_sql('ALTER TABLE {video} ADD custom_field_5 text NULL default NULL'); - $ret[] = update_sql('ALTER TABLE {video} ADD custom_field_6 text NULL default NULL'); - } - return $ret; -} - /** * Add unsigned to all int fields * * @return array */ -function video_update_3() { - $ret = array(); - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - $ret[] = update_sql("ALTER TABLE {video} CHANGE videox videox smallint(4) unsigned NOT NULL default '0'"); - $ret[] = update_sql("ALTER TABLE {video} CHANGE videoy videoy smallint(4) unsigned NOT NULL default '0'"); - $ret[] = update_sql('ALTER TABLE {video} CHANGE size size bigint(13) unsigned default NULL'); - $ret[] = update_sql('ALTER TABLE {video} CHANGE video_bitrate video_bitrate int(11) unsigned default NULL'); - $ret[] = update_sql('ALTER TABLE {video} CHANGE audio_bitrate audio_bitrate int(11) unsigned default NULL'); - $ret[] = update_sql('ALTER TABLE {video} CHANGE audio_sampling_rate audio_sampling_rate int(11) unsigned default NULL'); - $ret[] = update_sql('ALTER TABLE {video} CHANGE playtime_seconds playtime_seconds int(11) unsigned default NULL'); - $ret[] = update_sql("ALTER TABLE {video} CHANGE disable_multidownload disable_multidownload tinyint(1) unsigned NOT NULL default '0'"); - $ret[] = update_sql("ALTER TABLE {video} CHANGE use_play_folder use_play_folder tinyint(1) unsigned NOT NULL default '0'"); - } - return $ret; -} - /** * Start of Drupal 4.7 support in video.module issue #40005, version 1.25 * updated revisions, db schema, forms api, form validation, permissions, added .swf and image support * * @return array */ -function video_update_4() { - $ret = array(); - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - $ret[] = update_sql("ALTER TABLE {video} ADD vid int(10) unsigned NOT NULL default '0' FIRST"); - $ret[] = update_sql('UPDATE {video} SET vid = nid'); - $ret[] = update_sql('ALTER TABLE {video} CHANGE video_bitrate video_bitrate int(10) unsigned default NULL'); - $ret[] = update_sql('ALTER TABLE {video} CHANGE audio_bitrate audio_bitrate int(10) unsigned default NULL'); - $ret[] = update_sql('ALTER TABLE {video} CHANGE audio_sampling_rate audio_sampling_rate int(10) unsigned default NULL'); - $ret[] = update_sql('ALTER TABLE {video} CHANGE playtime_seconds playtime_seconds int(10) unsigned default NULL'); - $ret[] = update_sql('ALTER TABLE {video} ADD serialized_data text NULL default NULL'); - $ret[] = update_sql('ALTER TABLE {video} DROP PRIMARY KEY, ADD PRIMARY KEY ( `vid` )'); - } - return $ret; -} - /** * Add the vtype field for video module subtypes * * @return array */ -function video_update_5() { - $ret = array(); - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - case 'pgsql': - $ret[] = update_sql("ALTER TABLE {video} ADD vtype varchar(32) NOT NULL default ''"); - } - return $ret; -} - - -/* used for update 6 */ function _video_update_6_get_vtype($node) { $file_type = ''; $vidfile = $node->vidfile; @@ -209,69 +230,17 @@ /** * Set vtype for all the videos */ -function video_update_6() { - /* this function should be able to be run again and again until - * all the videos have been updated */ - $videos = db_query("SELECT nid,vidfile FROM {video} WHERE vtype=''"); - while ($video = db_fetch_object($videos)) { - db_query("UPDATE {video} SET vtype='%s' WHERE nid=%d", - _video_update_6_get_vtype($video), $video->nid); - } - - return array(); -} - /** * Set default values of resolutions */ -function video_update_7() { - variable_set('video_resolution_1_name', '4:3 - Television'); - variable_set('video_resolution_1_value', '400x300'); - variable_set('video_resolution_2_name', '16:9 - Widescreen'); - variable_set('video_resolution_2_value', '400x226'); - - return array(); -} - /** * Video_upload changes from relying on files table to locate * video file to saving it in serialized_data as video_fid */ -function video_update_8() { - /* select all the video upload video nodes */ - $vnodes = db_query("SELECT n.nid,n.vid,serialized_data FROM {node} n INNER JOIN {video} v on n.nid = v.nid WHERE n.type = 'video' AND v.vtype = 'upload' AND v.serialized_data NOT LIKE '%video_fid%'"); - - while ($node = db_fetch_object($vnodes)) { - /* load the video file info */ - if ($node->vid) { - $result = db_query('SELECT * FROM {files} f INNER JOIN {file_revisions} r ON f.fid = r.fid WHERE r.vid = %d ORDER BY f.fid DESC', $node->vid); - if (!$result) { - continue; - } - $result = db_fetch_object($result); - /* save the new serialized_data */ - $data = unserialize($node->serialized_data); - $data['video_fid'] = $result->fid; - $data = serialize($data); - $res = db_query("UPDATE {video} SET serialized_data='%s' WHERE nid=%d", $data, $node->nid); - } - } - return array(); -} - /** * Update the vidfile for youtube videos so they will work again */ -function video_update_9() { - $res[] = update_sql("UPDATE {video} SET vidfile=CONCAT('http://www.youtube.com/watch?v=',vidfile) WHERE vtype='youtube' AND vidfile NOT LIKE '%youtube.com/watch%'"); - return $res; -} - /** * Update vidfile for google videos -- they play, but they are not editable * in the current form because validation fails upon submit */ -function video_update_10() { - $res[] = update_sql("UPDATE {video} SET vidfile=CONCAT('http://video.google.com/videoplay?docid=',SUBSTR(vidfile,8)) WHERE vtype='google' AND vidfile LIKE 'google:%'"); - return $res; -} Index: video.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/video.module,v retrieving revision 1.68.2.17 diff -u -r1.68.2.17 video.module --- video.module 16 Mar 2008 11:39:14 -0000 1.68.2.17 +++ video.module 16 Dec 2008 05:24:34 -0000 @@ -15,7 +15,7 @@ * Let's include views logic if views module is enabled */ if (module_exists('views')) { - include(drupal_get_path('module', 'video') .'/views_video.inc'); + module_load_include('inc', 'video', 'views_video'); } /******************************************************************** @@ -31,32 +31,25 @@ * @return * string of help information */ -function video_help($section = 'admin/help#video') { - switch ($section) { - case 'admin/help#video': - $output = '

' . t('The video module (4.7 or with backport patch to 4.6) allows users to post video content to their site. The emergence of portable phones with video capture capabilities has made video capture ubiquitous. Video logging, or vlogging as a medium for personal video broadcasting has proven to be popular and is following the blogging, and podcasting phenomena\'s. Videos are useful for creative collaboration among community members. If community members can not meet in person videos of meetings are valuable for enhancing the interaction between community members.', array('%elink-en-wikipedia-org' => 'http://en.wikipedia.org/wiki/Vlog')) . '

'; - $output .= '

' . t('The video module can be administered to flash player settings. There are a number of page and menu links which can be added to play and download video content on the site. Other configurable options include play and download counters. Multi-file downloads can also be configured under settings. There are also up to six custom fields and a group name which can be added.') . '

'; - $output .= t('

You can:

- -', array('%admin-block' => url('admin/settings/block'), '%node-add-video' => url('node/add/video'), '%admin-settings-video' => url('admin/content/video'))); - $output .= '

'. t('For more information please read the configuration and customization handbook Video page.', array('%video' => 'http://www.drupal.org/handbook/modules/video/')) .'

'; - return $output; - case 'admin/settings/modules#description': - return t('Allows video nodes.'); - case 'node/add#video': - return t('Allows you to insert videos as nodes.'); - case 'video/help': - - // Get the video-type-specific help contents - $help_items = array(); - - return theme('item_list',module_invoke_all('v_help')); //$help_items); - } +function video_node_load($nid) { + $node = null; + if (!is_numeric($nid) || !$nid) { + if (function_exists('trace_msg')) { + trace_msg(); + } + return $node; + } + $node = node_load(array('nid' => $nid)); + if ($node->type == 'video') { + return $node; + } + $node = null; + return $node; +} + +function video_node_access(&$node) { + return user_access('access video') && node_access('view', $node); } /** @@ -68,57 +61,51 @@ * @return * array of menu information */ -function video_menu($may_cache) { +function video_menu() { global $user; $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'video', - 'title' => t('videos'), - 'callback' => 'video_page', - 'access' => user_access('access video'), + $items['video'] = array( + 'title' => 'videos', + 'page callback' => 'video_page', + 'access arguments' => array('access video'), 'type' => MENU_SUGGESTED_ITEM); - $items[] = array( - 'path' => 'video/feed', - 'title' => t('videos feed'), - 'callback' => 'video_feed', - 'access' => user_access('access video'), + $items['video/feed'] = array( + 'title' => 'videos feed', + 'page callback' => 'video_feed', + 'access arguments' => array('access video'), 'type' => MENU_CALLBACK); - $items[] = array( - 'path' => 'node/add/video', - 'title' => t('Video'), - 'callback' => 'video_add', - 'access' => user_access('create video')); - $items[] = array( - 'path' => 'admin/settings/video', - 'title' => t('Video'), - 'description' => t('Configure different aspects of the video module and its plugins'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('video_settings_form'), - 'access' => user_access('administer video'), - 'type' => MENU_NORMAL_ITEM, - ); - } - else { //If $may_cache is false. - if (arg(0) == 'node' && is_numeric(arg(1))) { - if ($node = node_load(arg(1)) and $node->type == 'video') { - - //enable the download tab only if it is supported - if (video_support_download($node)) { - - $menu_type = (variable_get('video_displaydownloadmenutab', 1)) ? MENU_LOCAL_TASK : MENU_CALLBACK; - $items[] = array('path' => 'node/'.$node->nid.'/download', - 'title' => t('Download'), - 'callback' => 'video_download', - 'callback arguments' => array($node), - 'access' => user_access('access video') && node_access('view', $node, $user->uid), - 'weight' => 5, - 'type' => $menu_type); - } - } - } - } + +/* TODO + The node/add/$type menu items are now auto-generated by the menu system. + You should not declare them in your menu hook. This means that you can + use hook_menu_alter to change the visibility of an item or change the + access callback. */ +/* + $items['node/add/video'] = array( + 'title' => 'Video', + 'page callback' => 'video_add', + 'access arguments' => array('create video')); +*/ + $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_settings_form'), + 'access arguments' => array('administer video'), + 'type' => MENU_NORMAL_ITEM, + ); + $menu_type = (variable_get('video_displaydownloadmenutab', 1)) ? MENU_LOCAL_TASK : MENU_CALLBACK; + $items['node/%video_node/download'] = array( + 'title' => 'Download', + 'page callback' => 'video_download', + 'page arguments' => array(1), + 'access arguments' => array(1), + 'access callback' => 'video_node_access', + 'weight' => 5, + 'type' => $menu_type, + ); + return $items; } @@ -220,7 +207,7 @@ $channel = array( 'title' => variable_get('site_name', 'drupal') . ' ' . t('videos'), 'description' => t('Latest videos on') . ' ' . variable_get('site_name', 'drupal'), - 'link' => url('video', NULL, NULL, TRUE) + 'link' => url('video', array('absolute' => TRUE)) ); $result = db_query('SELECT n.nid FROM {node} n WHERE n.type = "video" AND n.status = 1 ORDER BY n.created DESC'); @@ -389,19 +376,17 @@ * form values from the settings page * */ -function video_settings_form_validate($form_id, $form_values){ - //print_r($form_values); die; +function video_settings_form_validate($form, &$form_state){ + //print_r($form_state['values']); die; // if admin set a name for a resolution he also have to set its value - while($i <= 4) { - if($form_values["video_resolution_{$i}_name"] != '' && $form_values["video_resolution_{$i}_value"] == '') { + for ($i=1; $i<5; $i++) { + if($form_state['values']["video_resolution_{$i}_name"] != '' && $form_state['values']["video_resolution_{$i}_value"] == '') { form_set_error("video_resolution_{$i}_value", t('You have to set a value for resolution %res_num if you want to enable it.', array('%res_num' => $i))); } - if($form_values["video_resolution_{$i}_value"] != '' && !preg_match('/^[0-9]{2,4}x[0-9]{2,4}$/',$form_values["video_resolution_{$i}_value"])) { // check valid resolution value + if($form_state['values']["video_resolution_{$i}_value"] != '' && !preg_match('/^[0-9]{2,4}x[0-9]{2,4}$/',$form_state['values']["video_resolution_{$i}_value"])) { // check valid resolution value form_set_error("video_resolution_{$i}_value", t('You have to set valid value for resolution %res_num if you want to enable it. A valid value is 400x300', array('%res_num' => $i))); } - - $i++; } ; // for future use } @@ -429,15 +414,15 @@ /** * access hook */ -function video_access($op, $node) { - global $user; +function video_access($op, $node, $account) { + if ($op == 'create') { - return user_access('create video'); + return user_access('create video', $account); } if ($op == 'update' || $op == 'delete') { - return (user_access('edit own video') && ($user->uid == $node->uid)) || user_access('edit all video nodes'); + return (user_access('edit own video', $account) && ($account->uid == $node->uid)) || user_access('edit all video nodes', $account); } } @@ -554,7 +539,11 @@ else { $items = array(); foreach ($vtypes as $vtype => $infos) { - $out = '
'. l($infos['#name'], "node/add/video/$vtype", array('title' => t('Add a !s.', array('!s' => $infos['#name'])))) .'
'; + $out = '
'. /* TODO + Please manually fix the parameters on the l() or url() function on the next line. + Typically, this was not changed because of a function call inside an array call like + array('title' => t('View user profile.')).*/ +l($infos['#name'], "node/add/video/$vtype", array('title' => t('Add a !s.', array('!s' => $infos['#name'])))) .'
'; $out .= '
'. $infos['#description'] .'
'; $items[$vtype] = $out; } @@ -564,6 +553,16 @@ } } +function video_form_system_modules_alter(&$form, &$info) { + if (count($_POST)) { + return; + } + $vtypes = video_get_types_infos(); + if(!$vtypes) { // no vtype available + form_set_error('video', t('There are no Video types enabled. (Google Video, Upload Video, etc.)')); + } +} + /** * Return an array containing enabled Video Types @@ -602,6 +601,28 @@ return $info[$node->vtype]['#downloadable']; } +function video_default_vtype() { + $vtypes = video_get_types(); + // check the path (default to user specified type first) + $q = explode('/', $_GET['q']); + $qlen = count($q); + if ($qlen > 3 && + $q[0] == 'node' && $q[1] == 'add' && $q[2] == 'video') { + if (in_array($q[3], $vtypes)) { + return $q[3]; + } + if ($qlen > 4 && in_array($q[4], $vtypes)) { + return $q[4]; + } + } + $vtype = variable_get('video_default_video_type', ''); + if (!in_array($vtype, $vtypes)) { + return $vtypes[0]; + // no default set, return NULL + return NULL; + } + return $vtype; +} /** @@ -613,13 +634,26 @@ * @return * string value of form content */ -function video_form($node) { +function video_form(&$node, $form_state) { + $default_type = video_default_vtype(); + if ($default_type == NULL) { + return video_types_page(); + } + if(!isset($node->vtype)) { + $node->vtype = video_default_vtype(); + $node->serial_data = null; + $node->videox = 0; + $node->videoy = 0; + $node->playtime_seconds = 0; + } //We must unserialize the array for display in the forms. if($node->serial_data) { $node->serial_data = unserialize($node->serialized_data); } $form = array(); + $form['#submit'][] = 'video_submit'; + // default node stuff $type = node_get_types('type', $node); @@ -697,7 +731,8 @@ } // Get the video-type-specific bits. - $form = module_invoke('video_' . $node->vtype, 'v_form', $node, $form); + # FIXME: this sounds like form_alter stuff... axe this + #$form = module_invoke('video_' . $node->vtype, 'v_form', $node, $form); return $form; } @@ -707,46 +742,41 @@ * Implementation of hook_validate */ function video_validate($node) { - if(!video_support_autoresolution($node) || $node->vresolution) { // we have some resolution value // form api checked for good values of vresolution if(variable_get("video_{$node->vresolution}_value", '') == '') { } } - - module_invoke('video_'.$node->vtype, 'v_validate', $node); - - } /** * Implementation of hook submit */ -function video_submit(&$node) { - +function video_submit($form, &$form_state) { + $node = (object)$form_state['values']; if(video_support_autoresolution($node)) { // vtype support autoresolution getting - $xy = module_invoke('video_' . $node->vtype, 'v_auto_resolution', $node); + $xy = module_invoke('video_' . $form_state['values']['vtype'], 'v_auto_resolution', $node); if ($xy) { - $node->videox = $xy[0]; - $node->videoy = $xy[1]; + $form_state['values']['videox'] = $xy[0]; + $form_state['values']['videoy'] = $xy[1]; } } else { // we should have a good value (checked by Form API) - if($node->vresolution) { - $res = explode('x', variable_get('video_resolution_' . $node->vresolution . '_value', '')); - $node->videox = $res[0]; - $node->videoy = $res[1]; + if($form_state['values']['vresolution']) { + $res = explode('x', variable_get('video_resolution_' . $form_state['values']['vresolution'] . '_value', '')); + $form_state['values']['videox'] = $res[0]; + $form_state['values']['videoy'] = $res[1]; } } if(video_support_autoplaytime($node)) { // vtype support auto playtime - $node->playtime_seconds = module_invoke('video_' . $node->vtype, 'v_auto_playtime', $node); + $form_state['values']['playtime_seconds'] = module_invoke('video_' . $form_state['values']['vtype'], 'v_auto_playtime', $node); } else { // vtype does not support auto_playtime - $node->playtime_seconds += ($node->playtime_hours * 3600) + ($node->playtime_minutes * 60); + $form_state['values']['playtime_seconds'] += ($form_state['values']['playtime_hours'] * 3600) + ($form_state['values']['playtime_minutes'] * 60); } } @@ -759,7 +789,11 @@ * TRUE on success, FALSE on error */ function video_insert($node) { - + foreach (array('vid', 'nid', 'vtype', 'vidfile', 'size', 'videox', 'videoy', 'video_bitrate', 'audio_bitrate', 'audio_sampling_rate', 'audio_channels', 'playtime_seconds', 'disable_multidownload', 'download_folder', 'use_play_folder', 'custom_field_1', 'custom_field_2', 'custom_field_3', 'custom_field_4', 'custom_field_5', 'custom_field_6', 'serialized_data', 'serial_data') as $f) { + if (!isset($node->$f)) { + $node->$f = null; + } + } $node->serialized_data = serialize($node->serial_data); //Serialize the data for insertion into the database. return db_query("INSERT INTO {video} (vid, nid, vtype, vidfile, size, videox, videoy, video_bitrate, audio_bitrate, audio_sampling_rate, audio_channels, playtime_seconds, disable_multidownload, download_folder, use_play_folder, custom_field_1, custom_field_2, custom_field_3, custom_field_4, custom_field_5, custom_field_6, serialized_data) VALUES (%d, %d, '%s', '%s', %d, %d, %d, %d, %d, %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')", @@ -778,6 +812,11 @@ return video_insert($node); } else { + foreach (array('vid', 'nid', 'vtype', 'vidfile', 'size', 'videox', 'videoy', 'video_bitrate', 'audio_bitrate', 'audio_sampling_rate', 'audio_channels', 'playtime_seconds', 'disable_multidownload', 'download_folder', 'use_play_folder', 'custom_field_1', 'custom_field_2', 'custom_field_3', 'custom_field_4', 'custom_field_5', 'custom_field_6', 'serialized_data', 'serial_data') as $f) { + if (!isset($node->$f)) { + $node->$f = null; + } + } $node->serialized_data = serialize($node->serial_data); //Serialize the data for insertion into the database. @@ -820,10 +859,10 @@ * Implementation of hook_view(). */ function video_view(&$node, $teaser = FALSE, $page = FALSE) { - + // include the video css file drupal_add_css(drupal_get_path('module', 'video').'/video.css'); - + //Run the body through the standard filters. $node = node_prepare($node, $teaser); @@ -837,11 +876,19 @@ $node->content['video_player'] = array('#value' => theme('video_player', $node), '#weight' => -1); } else { - $output .= l(t('login'), "user/login", array('class' => 'outgoing', 'title' => t('login to your account'))); + $output .= /* TODO + Please manually fix the parameters on the l() or url() function on the next line. + Typically, this was not changed because of a function call inside an array call like + array('title' => t('View user profile.')).*/ +l(t('login'), "user/login", array('class' => 'outgoing', 'title' => t('login to your account'))); $output .= ' ' . t('or') . ' '; - $output .= l(t('register'), "user/register", array('class' => 'outgoing', 'title' => t('create a new account'))); + $output .= /* TODO + Please manually fix the parameters on the l() or url() function on the next line. + Typically, this was not changed because of a function call inside an array call like + array('title' => t('View user profile.')).*/ +l(t('register'), "user/register", array('class' => 'outgoing', 'title' => t('create a new account'))); $output .= ' ' . t('to play video'); - + $node->content['video_player'] = array('#value' => $output, '#weight' => -1); } } @@ -1005,6 +1052,102 @@ return true; } +/* Implement the hook_theme registry. Combine all theme registry entries + into one hook_theme function in each corresponding module file. +*/ +function video_theme() { + return array( + 'video_teaser' => array( + 'file' => 'video.module', + 'arguments' => array( + 'node' => NULL, + 'teaser' => FALSE, + 'page' => FALSE, + ), + ), + 'video_view' => array( + 'file' => 'video.module', + 'arguments' => array( + 'node' => NULL, + 'teaser' => FALSE, + 'page' => FALSE, + ), + ), + 'video_player' => array( + 'file' => 'video.module', + 'arguments' => array( + 'node' => NULL, + ), + ), + 'video_format_play' => array( + 'file' => 'video.module', + 'arguments' => array( + 'output' => NULL, + 'url' => NULL, + 'title' => NULL, + 'link_text' => NULL, + ), + ), + 'video_fields' => array( + 'file' => 'video.module', + 'arguments' => array( + 'fields' => NULL, + ), + ), + 'video_get_script' => array( + 'file' => 'video.module', + 'arguments' => array(), + ), + 'video_play_flash' => array( + 'file' => 'includes/common.inc', + 'arguments' => array( + 'node' => NULL, + ), + ), + 'video_play_swf' => array( + 'file' => 'includes/common.inc', + 'arguments' => array( + 'node' => NULL, + ), + ), + 'video_play_dcr' => array( + 'file' => 'includes/common.inc', + 'arguments' => array( + 'node' => NULL, + ), + ), + 'video_play_divx' => array( + 'file' => 'includes/common.inc', + 'arguments' => array( + 'node' => NULL, + ), + ), + 'video_play_quicktime' => array( + 'file' => 'includes/common.inc', + 'arguments' => array( + 'node' => NULL, + ), + ), + 'video_play_realmedia' => array( + 'file' => 'includes/common.inc', + 'arguments' => array( + 'node' => NULL, + ), + ), + 'video_play_windowsmedia' => array( + 'file' => 'includes/common.inc', + 'arguments' => array( + 'node' => NULL, + ), + ), + 'video_play_ogg_theora' => array( + 'file' => 'includes/common.inc', + 'arguments' => array( + 'node' => NULL, + ), + ), + ); +} /** * Theme the teaser @@ -1087,7 +1230,7 @@ $output = "\n
\n" . $output; $output .= "

\n". t('Problems viewing videos?'); $output .= "
\n"; - $output .= l($link_text, $url, array('title' => $title), NULL, NULL, TRUE); + $output .= l($link_text, $url, array('attributes' => array('title' => $title), 'absolute' => TRUE)); return $output ."\n

\n
\n"; } Index: views_video.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/views_video.inc,v retrieving revision 1.2.2.5 diff -u -r1.2.2.5 views_video.inc --- views_video.inc 17 Mar 2008 18:03:27 -0000 1.2.2.5 +++ views_video.inc 16 Dec 2008 05:24:34 -0000 @@ -181,7 +181,7 @@ **/ function video_views_handler_field_download($fieldinfo, $fielddata, $value, $data) { $nid = $data->nid; - return l(t('Download'), "node/$nid/download", NULL); + return l(t('Download'), "node/$nid/download", array()); } @@ -190,7 +190,7 @@ **/ function video_views_handler_field_play($fieldinfo, $fielddata, $value, $data) { $nid = $data->nid; - return l(t('Play'), "node/$nid/play", NULL); + return l(t('Play'), "node/$nid/play", array()); } Index: includes/apiclient.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/includes/Attic/apiclient.inc,v retrieving revision 1.1.2.1 diff -u -r1.1.2.1 apiclient.inc --- includes/apiclient.inc 11 Feb 2008 06:00:22 -0000 1.1.2.1 +++ includes/apiclient.inc 16 Dec 2008 05:24:34 -0000 @@ -1,4 +1,5 @@ $v){ - $arghash .= $k . $v; - } - - // build the url - foreach ($args as $k => $v){ - $encoded_params[] = urlencode($k).'='.urlencode($v); - } - $url .= '?'. implode('&', $encoded_params); - - // if it's a cachable request, try to load a cached value - if ($cacheable) { - if ($cache = cache_get($arghash, 'cache')) { - return unserialize($cache->data); - } - } - - // connect and fetch a value - $result = drupal_http_request($url); + $url = url($url, array('absolute'=>True, 'query'=>$args)); + // build an argument hash that we'll use for the cache id and api signing + $arghash = $provider.":".md5($url); + + // if it's a cachable request, try to load a cached value + if ($cacheable) { + if ($cache = cache_get($arghash, 'cache')) { + here(); + return unserialize($cache->data); + } + } - if ($result->code == 200) { - $parser = drupal_xml_parser_create($result->data); - $vals = array(); - $index = array(); - xml_parse_into_struct($parser, $result->data, $vals, $index); - xml_parser_free($parser); - - $params = array(); - $level = array(); - $start_level = 1; - foreach ($vals as $xml_elem) { - if ($xml_elem['type'] == 'open') { - if (array_key_exists('attributes',$xml_elem)) { - list($level[$xml_elem['level']],$extra) = array_values($xml_elem['attributes']); - } else { - $level[$xml_elem['level']] = $xml_elem['tag']; - } - } - if ($xml_elem['type'] == 'complete') { - $php_stmt = '$params'; - while($start_level < $xml_elem['level']) { - $php_stmt .= '[$level['.$start_level.']]'; - $start_level ++; + here(); + // connect and fetch a value + $result = drupal_http_request($url); + + if ($result->code == 200) { + $parser = drupal_xml_parser_create($result->data); + $vals = array(); + $index = array(); + xml_parse_into_struct($parser, $result->data, $vals, $index); + xml_parser_free($parser); + + $params = array(); + $level = array(); + $start_level = 1; + foreach ($vals as $xml_elem) { + if ($xml_elem['type'] == 'open') { + if (array_key_exists('attributes',$xml_elem)) { + list($level[$xml_elem['level']],$extra) = array_values($xml_elem['attributes']); + } else { + $level[$xml_elem['level']] = $xml_elem['tag']; + } + } + if ($xml_elem['type'] == 'complete') { + $php_stmt = '$params'; + while($start_level < $xml_elem['level']) { + $php_stmt .= '[$level['.$start_level.']]'; + $start_level ++; + } + if (!isset($xml_elem['value']) && isset($xml_elem['attributes'])) { + $php_stmt .= '[$xml_elem[\'tag\']][] = $xml_elem[\'attributes\'];'; + } elseif (!isset($xml_elem['value']) && isset($xml_elem['attributes'])) { + $php_stmt .= '[$xml_elem[\'tag\']][] = $xml_elem[\'value\'];'; + } else { + $php_stmt = ''; } - $php_stmt .= '[$xml_elem[\'tag\']][] = $xml_elem[\'value\'];'; eval($php_stmt); $start_level--; } } // save a cacheable result for future use - if ($cacheable) { - cache_set($arghash, 'cache', serialize($params), time() + 3600); - } - return $params; - } - return array(); + if ($cacheable) { + cache_set($arghash, serialize($params), 'cache', time() + 3600); + } + return $params; + } + return array(); } Index: includes/common.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/includes/Attic/common.inc,v retrieving revision 1.1.2.5 diff -u -r1.1.2.5 common.inc --- includes/common.inc 5 Mar 2008 16:23:38 -0000 1.1.2.5 +++ includes/common.inc 16 Dec 2008 05:24:34 -0000 @@ -1,6 +1,99 @@ 'image_button', + '#title' => t('My button'), + '#return_value' => 'my_data', + '#src' => 'my/image/path.jpg', +); */ + +/* TODO New user_mail_tokens() method may be useful. + user.module now provides a user_mail_tokens() function to return an array + of the tokens available for the email notification messages it sends when + accounts are created, activated, blocked, etc. Contributed modules that + wish to make use of the same tokens for their own needs are encouraged + to use this function. */ + +/* TODO + There is a new hook_watchdog in core. This means that contributed modules + can implement hook_watchdog to log Drupal events to custom destinations. + Two core modules are included, dblog.module (formerly known as watchdog.module), + and syslog.module. Other modules in contrib include an emaillog.module, + included in the logging_alerts module. See syslog or emaillog for an + example on how to implement hook_watchdog. +function example_watchdog($log = array()) { + if ($log['severity'] == WATCHDOG_ALERT) { + mysms_send($log['user']->uid, + $log['type'], + $log['message'], + $log['variables'], + $log['severity'], + $log['referer'], + $log['ip'], + format_date($log['timestamp'])); + } +} */ + +/* TODO Implement the hook_theme registry. Combine all theme registry entries + into one hook_theme function in each corresponding module file. +function common_theme() { + return array( + 'video_play_flash' => array( + 'file' => 'common.inc', + 'arguments' => array( + 'node' => NULL, + ), + ), + 'video_play_swf' => array( + 'file' => 'common.inc', + 'arguments' => array( + 'node' => NULL, + ), + ), + 'video_play_dcr' => array( + 'file' => 'common.inc', + 'arguments' => array( + 'node' => NULL, + ), + ), + 'video_play_divx' => array( + 'file' => 'common.inc', + 'arguments' => array( + 'node' => NULL, + ), + ), + 'video_play_quicktime' => array( + 'file' => 'common.inc', + 'arguments' => array( + 'node' => NULL, + ), + ), + 'video_play_realmedia' => array( + 'file' => 'common.inc', + 'arguments' => array( + 'node' => NULL, + ), + ), + 'video_play_windowsmedia' => array( + 'file' => 'common.inc', + 'arguments' => array( + 'node' => NULL, + ), + ), + 'video_play_ogg_theora' => array( + 'file' => 'common.inc', + 'arguments' => array( + 'node' => NULL, + ), + ), + ); +} */ + /** * @file * Add some common functions for the various video types supported Index: plugins/video_customfields/video_customfields.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/plugins/video_customfields/video_customfields.info,v retrieving revision 1.2 diff -u -r1.2 video_customfields.info --- plugins/video_customfields/video_customfields.info 11 Nov 2006 03:58:40 -0000 1.2 +++ plugins/video_customfields/video_customfields.info 16 Dec 2008 05:24:34 -0000 @@ -1,5 +1,13 @@ ; $Id: video_customfields.info,v 1.2 2006/11/11 03:58:40 fax8 Exp $ name = Video Custom Fields description = Enable addition of custom fileds on video nodes created by video module. -dependencies = video +dependencies[] = video package = "Video" + +; Information added by drupal.org packaging script on 2008-04-09 +version = "5.x-1.x-dev" +project = "video" +datestamp = "1207700333" + + +core = 6.x \ No newline at end of file Index: plugins/video_customfields/video_customfields.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/plugins/video_customfields/video_customfields.module,v retrieving revision 1.7.2.1 diff -u -r1.7.2.1 video_customfields.module --- plugins/video_customfields/video_customfields.module 11 Feb 2008 06:00:22 -0000 1.7.2.1 +++ plugins/video_customfields/video_customfields.module 16 Dec 2008 05:24:34 -0000 @@ -1,6 +1,66 @@ 'image_button', + '#title' => t('My button'), + '#return_value' => 'my_data', + '#src' => 'my/image/path.jpg', +); */ + +/* TODO New user_mail_tokens() method may be useful. + user.module now provides a user_mail_tokens() function to return an array + of the tokens available for the email notification messages it sends when + accounts are created, activated, blocked, etc. Contributed modules that + wish to make use of the same tokens for their own needs are encouraged + to use this function. */ + +/* TODO + There is a new hook_watchdog in core. This means that contributed modules + can implement hook_watchdog to log Drupal events to custom destinations. + Two core modules are included, dblog.module (formerly known as watchdog.module), + and syslog.module. Other modules in contrib include an emaillog.module, + included in the logging_alerts module. See syslog or emaillog for an + example on how to implement hook_watchdog. +function example_watchdog($log = array()) { + if ($log['severity'] == WATCHDOG_ALERT) { + mysms_send($log['user']->uid, + $log['type'], + $log['message'], + $log['variables'], + $log['severity'], + $log['referer'], + $log['ip'], + format_date($log['timestamp'])); + } +} */ + +/* TODO Implement the hook_theme registry. Combine all theme registry entries + into one hook_theme function in each corresponding module file. +function video_customfields_theme() { + return array( + 'video_customfields' => array( + 'file' => 'video_customfields.module', + 'arguments' => array( + 'node' => NULL, + ), + ), + ); +} */ + +/* TODO You may want to take advantage of new form-specific alter hooks. + The hook_form_alter() is complemented by hook_form_$form-id_alter(). + Optionally, modules can implement form-specific alteration functions rather + than a single hook_form_alter() with many conditional switch statements. + This is optional, and is most useful for tidying the code of modules that + alter many forms to customize a site's operations. + The new function names are built using the following format: + [your-module-name]_form_[$form_id]_alter. */ + /** * @file * Enable addition of custom fileds on video nodes created by video module. @@ -12,8 +72,8 @@ /** * Implementation of hook_help(). */ -function video_customfields_help($section) { - switch ($section) { +function video_customfields_help($path, $arg) { + switch ($path) { case 'admin/settings/modules#description': return t('Enable addition of custom fileds on video nodes created by video module.'); } @@ -30,19 +90,16 @@ /** * Implementation of hook_menu(). */ -function video_customfields_menu($may_cache) { +function video_customfields_menu() { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'admin/content/video/customfields', - 'title' => t('Customfields'), - 'description' => t('Administer video_customfields module settings'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('video_customfields_settings_form'), - 'access' => user_access('administer site configuration'), + $items['admin/content/video/customfields'] = array( + 'title' => 'Customfields', + 'description' => 'Administer video_customfields module settings', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('video_customfields_settings_form'), + 'access arguments' => array('administer site configuration'), 'type' => MENU_NORMAL_ITEM, - ); - } + ); return $items; } @@ -116,7 +173,7 @@ * We use this to add some custom fields to the video creation form. * Fields will be displayed only if field title is set on settings page. */ -function video_customfields_form_alter($form_id, &$form) { +function video_customfields_form_alter(&$form, &$form_state, $form_id) { if($form_id == 'video_node_form' && isset($form['video']) && user_access('insert custom fields')) { Index: plugins/video_ffmpeg_helper/video_ffmpeg_helper.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/plugins/video_ffmpeg_helper/video_ffmpeg_helper.info,v retrieving revision 1.2 diff -u -r1.2 video_ffmpeg_helper.info --- plugins/video_ffmpeg_helper/video_ffmpeg_helper.info 12 Jan 2007 16:35:40 -0000 1.2 +++ plugins/video_ffmpeg_helper/video_ffmpeg_helper.info 16 Dec 2008 05:24:34 -0000 @@ -1,5 +1,13 @@ ; $Id: video_ffmpeg_helper.info,v 1.2 2007/01/12 16:35:40 fax8 Exp $ name = Video ffmpeg Helper description = Provide apis for ffmpeg. Simplify video nodes creation. -dependencies = video video_upload +dependencies[] = video package = "Video" + +; Information added by drupal.org packaging script on 2008-04-09 +version = "5.x-1.x-dev" +project = "video" +datestamp = "1207700333" + + +core = 6.x Index: plugins/video_ffmpeg_helper/video_ffmpeg_helper.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/plugins/video_ffmpeg_helper/video_ffmpeg_helper.install,v retrieving revision 1.1 diff -u -r1.1 video_ffmpeg_helper.install --- plugins/video_ffmpeg_helper/video_ffmpeg_helper.install 12 Jan 2007 15:18:55 -0000 1.1 +++ plugins/video_ffmpeg_helper/video_ffmpeg_helper.install 16 Dec 2008 05:24:34 -0000 @@ -3,6 +3,60 @@ /** + * Implementation of hook_schema(). + */ +function video_ffmpeg_helper_schema() { + $schema = array(); + $schema['video_rendering'] = array( + 'description' => t('keeps track of video to flv transcode requests'), + 'fields' => array( + 'vid' => array( + 'description' => t('version id'), + 'type' => 'int', + 'unsigned' => 1, + 'not null' => TRUE, + 'default' => 0, + ), + 'origfile' => array( + 'description' => t('path to original video file'), + 'type' => 'text', + 'not null' => TRUE, + 'default' => '', + ), + 'pid' => array( + 'description' => t('process id of transcoder'), + 'type' => 'int', + 'unsigned' => 1, + 'not null' => TRUE, + 'default' => 0, + ), + 'status' => array( + 'description' => t('status of transcode process'), + 'type' => 'int', + 'unsigned' => 1, + 'not null' => TRUE, + 'default' => 0, + ), + 'started' => array( + 'description' => t('has started transcode yet'), + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'completed' => array( + 'description' => t('has finished transcode yet'), + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'primary key' => array('vid'), + ); + + return $schema; +} + +/** * @file * Provide installation functions for video_ffmpeg_helper.module . * @@ -11,30 +65,7 @@ function video_ffmpeg_helper_install() { - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - db_query("CREATE TABLE {video_rendering} ( - vid int(10) unsigned NOT NULL default '0', - nid int(10) unsigned NOT NULL default '0', - origfile text NOT NULL default '', - pid int(10) unsigned NOT NULL default '0', - status int(1) unsigned NOT NULL default '0', - started int NOT NULL default '0', - completed int NOT NULL default '0', - PRIMARY KEY (vid) - ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;"); - break; - case 'pgsql': - db_query("CREATE TABLE {video_rendering} ( - vid integer NOT NULL default '0', - nid integer NOT NULL default '0', - origfile text NOT NULL default '', - pid integer NOT NULL default '0', - status integer NOT NULL default '1', - PRIMARY KEY (vid) - );"); - break; - } + // Create tables. + drupal_install_schema('video_ffmpeg_helper'); } Index: plugins/video_ffmpeg_helper/video_ffmpeg_helper.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/plugins/video_ffmpeg_helper/video_ffmpeg_helper.module,v retrieving revision 1.7.2.8 diff -u -r1.7.2.8 video_ffmpeg_helper.module --- plugins/video_ffmpeg_helper/video_ffmpeg_helper.module 18 Mar 2008 02:15:26 -0000 1.7.2.8 +++ plugins/video_ffmpeg_helper/video_ffmpeg_helper.module 16 Dec 2008 05:24:34 -0000 @@ -39,8 +39,8 @@ /** * Implementation of hook_help(). */ -function video_ffmpeg_helper_help($section) { - switch ($section) { +function video_ffmpeg_helper_help($path, $arg) { + switch ($path) { case 'admin/modules#description': return t('Enable ffmpeg support for video module.'); } @@ -49,34 +49,48 @@ /** * Implementation of hook_menu() */ -function video_ffmpeg_helper_menu($may_cache) { +function video_ffmpeg_helper_menu() { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'admin/settings/video/ffmpeg_helper', - 'title' => t('Video ffmpeg Helper'), - 'description' => t('Administer video_ffmpeg_helper module settings'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('video_ffmpeg_helper_admin_settings'), - 'access' => user_access('administer site configuration'), + $items['admin/settings/video/ffmpeg_helper'] = array( + 'title' => 'Video ffmpeg Helper', + 'description' => 'Administer video_ffmpeg_helper module settings', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('video_ffmpeg_helper_admin_settings'), + 'access arguments' => array('administer site configuration'), 'type' => MENU_NORMAL_ITEM, ); - } return $items; } +function video_ffmpeg_helper_theme() { + return array( + 'video_ffmpeg_helper_inprogress' => array( + 'file' => 'video_ffmpeg_helper.module', + 'arguments' => array( + 'node' => NULL, + ), + ), + 'video_ffmpeg_helper_encoding_failed' => array( + 'file' => 'video_ffmpeg_helper.module', + 'arguments' => array( + 'node' => NULL, + ), + ), + ); +} + /** * Validation for settings form */ -function video_ffmpeg_helper_admin_settings_validate($form_id, &$form_values, &$form) { +function video_ffmpeg_helper_admin_settings_validate($form, &$form_state) { if (variable_get('video_image_auto_thumbnail', 0)) { - if (!_video_ffmpeg_helper_check_exe_path($form_values['video_ffmpeg_helper_ffmpeg_path'])) { + if (!_video_ffmpeg_helper_check_exe_path($form_state['values']['video_ffmpeg_helper_ffmpeg_path'])) { form_set_error('video_ffmpeg_helper_ffmpeg_path', t('Set correct path for ffmpeg')); } - if (!is_numeric($form_values['video_ffmpeg_helper_auto_thumbnail_seek'])) { + if (!is_numeric($form_state['values']['video_ffmpeg_helper_auto_thumbnail_seek'])) { form_set_error('video_ffmpeg_helper_auto_thumbnail_seek', t('Seek time must be an integer')); } - $options = $form_values['video_ffmpeg_helper_thumbnailer_options']; + $options = $form_state['values']['video_ffmpeg_helper_thumbnailer_options']; if (!strstr($options, '%videofile') || !strstr($options, '%thumbfile')) { form_set_error('video_ffmpeg_helper_thumbnailer_options', t('Thumbnail options must contain mandatory arguments %videofile and %thumbfile')); } @@ -194,7 +208,7 @@ '
  • '.t('%convertfile (a newly created file to store the converted file)'). '
  • '.t('%size (video resolution of the converted file)'). ''. - t('For further informations refer to the !ffmpegdoc', array('!ffmpegdoc' => l(t('Official FFMpeg documentation.'), 'http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html', NULL, NULL, TRUE))), + t('For further informations refer to the !ffmpegdoc', array('!ffmpegdoc' => l(t('Official FFMpeg documentation.'), 'http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html', array('fragment' => TRUE)))), '#default_value' => variable_get('video_ffmpeg_helper_auto_cvr_options', '-y -i %videofile -f flv -ar 22050 -ab %audiobitrate -s %size -b %videobitrate -qscale 1 %convertfile'), ); return system_settings_form($form); @@ -204,28 +218,24 @@ /** * Implementation of hook_form_alter() */ -function video_ffmpeg_helper_form_alter($form_id, &$form) { +function video_ffmpeg_helper_form_video_node_form_alter(&$form, &$form_state) { $node = $form['#node']; - //print_r($form); - if($form_id == 'video_node_form') { - - if (function_exists('_image_check_settings')) { - _image_check_settings(); - $form['#attributes'] = array("enctype" => "multipart/form-data"); + if (function_exists('_image_check_settings')) { + _image_check_settings(); + $form['#attributes'] = array("enctype" => "multipart/form-data"); - } + } - if($node->vtype == 'upload' && user_access('bypass automatic video conversion') && variable_get('video_ffmpeg_helper_auto_conversion', false)) { - $form['video']['video_ffmpeg_helper_convertion_bypass'] = array( - '#type' => 'checkbox', - '#title' => t('Bypass automatic video conversion'), - '#description' => t('Check this if you want that your video is submitted as it is, without being converted.'), - '#default_value' => $node->video_ffmpeg_helper_convertion_bypass, // for node previews - ); - } + if($node->vtype == 'upload' && user_access('bypass automatic video conversion') && variable_get('video_ffmpeg_helper_auto_conversion', false)) { + $form['video']['video_ffmpeg_helper_convertion_bypass'] = array( + '#type' => 'checkbox', + '#title' => t('Bypass automatic video conversion'), + '#description' => t('Check this if you want that your video is submitted as it is, without being converted.'), + '#default_value' => $node->video_ffmpeg_helper_convertion_bypass, // for node previews + ); } } @@ -237,6 +247,9 @@ * NOTE: video_ffmpeg nodeapi is executed after video_player rendering */ function video_ffmpeg_helper_nodeapi(&$node, $op, $teaser) { + if (!isset($node->vtype)) { + return; + } if($node->type == 'video' && $node->vtype == 'upload') { switch ($op) { case 'load': @@ -267,7 +280,7 @@ case 'update': /* delete the already existing batch script, we'll recreate it below */ if(variable_get('video_ffmpeg_helper_auto_conversion', false)) { - db_query('DELETE FROM {video_rendering} WHERE vid = %d AND nid = %d', $node->vid, $node->nid); + db_query('DELETE FROM {video_rendering} WHERE vid = %d', $node->vid); } /* FALLTHROUGH */ case 'insert': @@ -300,7 +313,7 @@ break; case 'delete': - db_query('DELETE FROM {video_rendering} WHERE vid = %d AND nid = %d', $node->vid, $node->nid); + db_query('DELETE FROM {video_rendering} WHERE vid = %d', $node->vid); if($node->serial_data['video_encoded_fid'] > 0) { $file = _video_upload_get_file($node->serial_data['video_encoded_fid']); _video_upload_delete_file($file); @@ -318,13 +331,13 @@ function _video_ffmpeg_helper_add_rendering(&$node) { $file = _video_upload_get_file($node->new_video_upload_file_fid); //print_r($node); die; - db_query('INSERT INTO {video_rendering} (vid, nid, origfile, pid, status, started, completed) VALUES (%d, %d, "%s", %d, %d, %d, %d)', $node->vid, $node->nid, $file->filepath, 0, VIDEO_RENDERING_PENDING, 0, 0); + db_query('INSERT INTO {video_rendering} (vid, origfile, pid, status, started, completed) VALUES (%d, %d, "%s", %d, %d, %d, %d)', $node->vid, $file->filepath, 0, VIDEO_RENDERING_PENDING, 0, 0); drupal_set_message(t('Video submission queued for processing. Please wait: our servers are preparing your video for web displaying.')); // let's add the rendering in progress video $node->vidfile = variable_get('video_ffmpeg_helper_auto_cvr_busy_video_path', 'busy.flv'); - db_query('UPDATE {video} SET vidfile = "%s" WHERE nid=%d AND vid=%d', $node->vidfile, $node->nid, $node->vid); + db_query('UPDATE {video} SET vidfile = "%s" WHERE vid=%d', $node->vidfile, $node->vid); } @@ -333,7 +346,7 @@ * Returns true if the video is being encoded or queeded */ function _video_ffmpeg_helper_is_being_processed($node) { - $result = db_query("SELECT status FROM {video_rendering} WHERE vid = %d AND nid = %d", $node->vid, $node->nid); + $result = db_query("SELECT status FROM {video_rendering} WHERE vid = %d", $node->vid); $status = db_result($result); if($status == VIDEO_RENDERING_PENDING || $status == VIDEO_RENDERING_ACTIVE) { // video is still being converted return TRUE; @@ -346,26 +359,24 @@ /** * Get some informations from the video file */ -function _video_ffmpeg_helper_get_video_info(&$node, $value=null) { +function _video_ffmpeg_helper_get_video_info(&$file, $value=null) { static $ffmpeg_info; if (isset($value)) { - $ffmpeg_info[$node->nid] = $value; + $ffmpeg_info[$file->fid] = $value; return; } - $fileobj = $node->new_video_upload_file ? $node->new_video_upload_file : _video_upload_get_file($node->new_video_upload_file_fid); - // check if we have some info in the cache for the given node - if(isset($ffmpeg_info[$fileobj->filename])) { - return $ffmpeg_info[$fileobj->filename]; + if(isset($ffmpeg_info[$file->fid])) { + return $ffmpeg_info[$file->fid]; } // escape file name for safety - $file = escapeshellarg($fileobj->filepath); + $sfile = escapeshellarg($file->filepath); // create the full command to execute - $command = variable_get('video_ffmpeg_helper_ffmpeg_path', '/usr/bin/ffmpeg') . ' -i ' . $file; + $command = variable_get('video_ffmpeg_helper_ffmpeg_path', '/usr/bin/ffmpeg') . ' -i ' . $sfile; //execute the command ob_start(); @@ -374,7 +385,7 @@ ob_end_clean(); // cache the result for further calls - $ffmpeg_info[$node->nid] = $command_output; + $ffmpeg_info[$file->fid] = $command_output; return $command_output; } @@ -383,15 +394,11 @@ /** * Return the video resolution */ -function _video_ffmpeg_helper_auto_resolution(&$node) { - if(!$node->new_video_upload_file && !$node->new_video_upload_file_fid) { // no new files uploaded. skipping auto resolution process - return null; - } - +function _video_ffmpeg_helper_auto_resolution(&$file) { if(variable_get('video_ffmpeg_helper_auto_resolution', false)) { // call ffmpeg -i - $ffmpeg_output = _video_ffmpeg_helper_get_video_info($node); + $ffmpeg_output = _video_ffmpeg_helper_get_video_info($file); // get resolution $pattern = '/Video: .*, ([0-9]{2,4}x[0-9]{2,4})/'; @@ -407,12 +414,12 @@ /** * Return the playtime seconds of a video */ -function _video_ffmpeg_helper_auto_playtime(&$node) { +function _video_ffmpeg_helper_auto_playtime(&$file) { if(variable_get('video_ffmpeg_helper_auto_playtime', false)) { // call ffmpeg -i - $ffmpeg_output = _video_ffmpeg_helper_get_video_info($node); + $ffmpeg_output = _video_ffmpeg_helper_get_video_info($file); // get playtime $pattern = '/Duration: ([0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9])/'; @@ -441,19 +448,7 @@ * @return * a drupal file object */ -function _video_ffmpeg_helper_auto_thumbnail(&$node) { - if (!$node->new_video_upload_file || - ($node->new_video_upload_file && count($_POST) && $_POST['new_video_upload_file_fid'])) { - // we have already thumbnailed this new upload file - return NULL; - } - if (!$node->new_video_upload_file && $node->current_video_upload_file_fid) { // no new files uploaded. skipping thumnailing stuff - _video_image_thumbnail_debug(t('No new files to thumbnail')); - return NULL; - } - // gets the newly uploaded file object - $uploaded_file = $node->new_video_upload_file; - +function _video_ffmpeg_helper_auto_thumbnail($uploaded_file) { // are we debugging? // escape the filename for safety $videofile = escapeshellarg($uploaded_file->filepath); @@ -470,7 +465,7 @@ passthru($command." 2>&1", $tnail_return); $tnail_output = ob_get_contents(); ob_end_clean(); - _video_ffmpeg_helper_get_video_info($node, $tnail_output); + _video_ffmpeg_helper_get_video_info($uploaded_file, $tnail_output); _video_image_thumbnail_debug(t('Thumbnailer command: ').$command); _video_image_thumbnail_debug(t('Thumbnailer output: ')."
    \n$tnail_output\n
    "); @@ -490,7 +485,6 @@ 'filemime' => 'image/jpeg', 'filesize' => filesize($thumbfile), 'filepath' => $thumbfile, - 'nid' => $node->nid, ); if ($tnail_return) { Index: plugins/video_ffmpeg_helper/video_render.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/plugins/video_ffmpeg_helper/video_render.php,v retrieving revision 1.7.2.3 diff -u -r1.7.2.3 video_render.php --- plugins/video_ffmpeg_helper/video_render.php 15 Mar 2008 18:37:16 -0000 1.7.2.3 +++ plugins/video_ffmpeg_helper/video_render.php 16 Dec 2008 05:24:34 -0000 @@ -1,6 +1,64 @@ 'image_button', + '#title' => t('My button'), + '#return_value' => 'my_data', + '#src' => 'my/image/path.jpg', +); */ + +/* TODO {files} table changed + The files table has been changed to make it easier to preview uploaded files. + Two fields, status and timestamp, have been added so that temporary files + can be stored and cleaned automatically removed during a cron job. Use + file_set_status() to change a files status and make it a permanent file. */ + +/* TODO New user_mail_tokens() method may be useful. + user.module now provides a user_mail_tokens() function to return an array + of the tokens available for the email notification messages it sends when + accounts are created, activated, blocked, etc. Contributed modules that + wish to make use of the same tokens for their own needs are encouraged + to use this function. */ + +/* TODO + There is a new hook_watchdog in core. This means that contributed modules + can implement hook_watchdog to log Drupal events to custom destinations. + Two core modules are included, dblog.module (formerly known as watchdog.module), + and syslog.module. Other modules in contrib include an emaillog.module, + included in the logging_alerts module. See syslog or emaillog for an + example on how to implement hook_watchdog. +function example_watchdog($log = array()) { + if ($log['severity'] == WATCHDOG_ALERT) { + mysms_send($log['user']->uid, + $log['type'], + $log['message'], + $log['variables'], + $log['severity'], + $log['referer'], + $log['ip'], + format_date($log['timestamp'])); + } +} */ + +/* TODO Implement the hook_theme registry. Combine all theme registry entries + into one hook_theme function in each corresponding module file. +function video_render_theme() { + return array( + ); +} */ + /** * @file * Renders a video. This script is called concurrently by video_scheduler.php @@ -51,7 +109,7 @@ $_SERVER['HTTP_HOST'] = $url['host']; } -include_once './includes/bootstrap.inc'; +module_load_include('/includes/bootstrap.inc', 'video_render', 'includes/bootstrap'); // disable error reporting for bootstrap process error_reporting(E_ERROR); // let's bootstrap: we will be able to use drupal apis @@ -63,7 +121,7 @@ // allow execution only from the command line! if(empty($_SERVER['REQUEST_METHOD'])) { if($_SERVER['argc'] < 3) { // check for command line arguments - watchdog('video_render', t('Incorrect parameters to the video_render.php script.', WATCHDOG_ERROR)); + watchdog('video_render', 'Incorrect parameters to the video_render.php script.', WATCHDOG_ERROR); print t('Incorrect parameters'); } else { @@ -89,13 +147,13 @@ $job = _video_render_load_job($nid, $vid, VIDEO_RENDERING_ACTIVE); if($job == NULL) { - watchdog('video_render', t('video_render.php has been called with an invalid job resource. exiting.')); + watchdog('video_render', 'video_render.php has been called with an invalid job resource. exiting.'); die; } $command = _video_render_get_command($job); //print('executing ' . $command); die; - watchdog('video_render', t('executing: ') . $command); + watchdog('video_render', 'executing: ' . $command); //execute the command ob_start(); @@ -106,7 +164,7 @@ //print $command_output; if (!file_exists($job->convfile) || !filesize($job->convfile)) { - watchdog('video_render', t('video conversion failed. ffmpeg reported the following output: ' . $command_output, WATCHDOG_ERROR)); + watchdog('video_render', 'video conversion failed. ffmpeg reported the following output: ' . $command_output, WATCHDOG_ERROR); _video_render_set_video_encoded_fid($job->nid, $job->vid, -1); _video_render_job_change_status($job->nid, $job->vid, VIDEO_RENDERING_FAILED); } @@ -132,7 +190,7 @@ //print_r($file); db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize) VALUES (%d, %d, '%s', '%s', '%s', %d)", $file->fid, $job->nid, $file->filename, $file->filepath, $file->filemime, $file->filesize); - db_query("INSERT INTO {file_revisions} (fid, vid, list, description) VALUES (%d, %d, %d, '%s')", $file->fid, $job->vid, $file->list, $file->description); + db_query("INSERT INTO {upload} (fid, vid, list, description) VALUES (%d, %d, %d, '%s')", $file->fid, $job->vid, $file->list, $file->description); // update the video table db_query('UPDATE {video} SET vidfile = "%s", videox = %d, videoy = %d WHERE nid=%d AND vid=%d', "", $job->calculatedx, $job->calculatedy, $job->nid, $job->vid); @@ -142,7 +200,7 @@ _video_render_job_change_status($job->nid, $job->vid, VIDEO_RENDERING_COMPLETE); - watchdog('video_render', t('successfully converted %orig to %dest', array('%orig' => $job->origfile, '%dest' => $file->filepath))); + watchdog('video_render', 'successfully converted %orig to %dest', array('%orig' => $job->origfile, '%dest' => $file->filepath)); // delete the temp file unlink($job->convfile); @@ -156,7 +214,7 @@ $fowner=$fownerarray['name']; // get destination folder permissions $perms = substr(sprintf('%o', fileperms($dest_dir)), -4); - watchdog('video_render', t('error moving video %vid_file with nid = %nid to %dir the final directory. Check folder permissions.
    The script was run by %uname .
    The folder owner is %fowner .
    The folder permissions are %perms .', array('%vid_file' => $job->origfile, '%nid' => $job->nid, '%dir' => $dest_dir, '%uname' => $owner, '%fowner' => $fowner, '%perms' => $perms)), WATCHDOG_ERROR); + watchdog('video_render', 'error moving video %vid_file with nid = %nid to %dir the final directory. Check folder permissions.
    The script was run by %uname .
    The folder owner is %fowner .
    The folder permissions are %perms .', array('%vid_file' => $job->origfile, '%nid' => $job->nid, '%dir' => $dest_dir, '%uname' => $owner, '%fowner' => $fowner, '%perms' => $perms), WATCHDOG_ERROR); _video_render_set_video_encoded_fid($job->nid, $job->vid, -1); _video_render_job_change_status($job->nid, $job->vid, VIDEO_RENDERING_FAILED); Index: plugins/video_ffmpeg_helper/video_scheduler.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/plugins/video_ffmpeg_helper/video_scheduler.php,v retrieving revision 1.4.2.2 diff -u -r1.4.2.2 video_scheduler.php --- plugins/video_ffmpeg_helper/video_scheduler.php 15 Mar 2008 18:37:16 -0000 1.4.2.2 +++ plugins/video_ffmpeg_helper/video_scheduler.php 16 Dec 2008 05:24:34 -0000 @@ -1,6 +1,56 @@ 'image_button', + '#title' => t('My button'), + '#return_value' => 'my_data', + '#src' => 'my/image/path.jpg', +); */ + +/* TODO Remove db_num_rows() method + The db_num_rows() method was removed from the database abstraction layer in + 6.x core, as it was a database dependent method. Developers need to use other + handling to replace the needs of this method. */ + +/* TODO New user_mail_tokens() method may be useful. + user.module now provides a user_mail_tokens() function to return an array + of the tokens available for the email notification messages it sends when + accounts are created, activated, blocked, etc. Contributed modules that + wish to make use of the same tokens for their own needs are encouraged + to use this function. */ + +/* TODO + There is a new hook_watchdog in core. This means that contributed modules + can implement hook_watchdog to log Drupal events to custom destinations. + Two core modules are included, dblog.module (formerly known as watchdog.module), + and syslog.module. Other modules in contrib include an emaillog.module, + included in the logging_alerts module. See syslog or emaillog for an + example on how to implement hook_watchdog. +function example_watchdog($log = array()) { + if ($log['severity'] == WATCHDOG_ALERT) { + mysms_send($log['user']->uid, + $log['type'], + $log['message'], + $log['variables'], + $log['severity'], + $log['referer'], + $log['ip'], + format_date($log['timestamp'])); + } +} */ + +/* TODO Implement the hook_theme registry. Combine all theme registry entries + into one hook_theme function in each corresponding module file. +function video_scheduler_theme() { + return array( + ); +} */ + /** * @file * Implement video rendering scheduling. @@ -46,7 +96,7 @@ $_SERVER['HTTP_HOST'] = $url['host']; } -include_once './includes/bootstrap.inc'; +module_load_include('/includes/bootstrap.inc', 'video_scheduler', 'includes/bootstrap'); // disable error reporting for bootstrap process error_reporting(E_ERROR); // let's bootstrap: we will be able to use drupal apis @@ -77,7 +127,7 @@ } } else { - watchdog('video_scheduler', t('no video conversion jobs to schedule.')); + watchdog('video_scheduler', 'no video conversion jobs to schedule.'); } } Index: plugins/video_image/video_image.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/plugins/video_image/video_image.info,v retrieving revision 1.2 diff -u -r1.2 video_image.info --- plugins/video_image/video_image.info 11 Nov 2006 03:58:40 -0000 1.2 +++ plugins/video_image/video_image.info 16 Dec 2008 05:24:34 -0000 @@ -1,5 +1,14 @@ ; $Id: video_image.info,v 1.2 2006/11/11 03:58:40 fax8 Exp $ name = Video Image description = Enable thumbnails support for video module. -dependencies = image video +dependencies[] = image +dependencies[] = video package = "Video" + +; Information added by drupal.org packaging script on 2008-04-09 +version = "5.x-1.x-dev" +project = "video" +datestamp = "1207700333" + + +core = 6.x \ No newline at end of file Index: plugins/video_image/video_image.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/plugins/video_image/video_image.module,v retrieving revision 1.14.2.7 diff -u -r1.14.2.7 video_image.module --- plugins/video_image/video_image.module 17 Mar 2008 18:03:27 -0000 1.14.2.7 +++ plugins/video_image/video_image.module 16 Dec 2008 05:24:34 -0000 @@ -1,7 +1,6 @@ 'admin/settings/video/image', - 'title' => t('Video image'), - 'description' => t('Administer video_image module settings'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('video_image_admin_settings'), - 'access' => user_access('administer site configuration'), + $items['admin/settings/video/image'] = array( + 'title' => 'Video image', + 'description' => 'Administer video_image module settings', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('video_image_admin_settings'), + 'access arguments' => array('administer site configuration'), 'type' => MENU_NORMAL_ITEM, ); - } return $items; } @@ -105,9 +101,9 @@ return system_settings_form($form); } -function video_image_admin_settings_validate($form_id, &$form_values, &$form) { +function video_image_admin_settings_validate($form, &$form_state) { if (module_exists('video_ffmpeg_helper')) { - if ($form_values['video_image_auto_thumbnail']) { + if ($form_state['values']['video_image_auto_thumbnail']) { $path_ok = _video_ffmpeg_helper_check_exe_path(); if (!$path_ok) { drupal_set_message(t('The path for \'ffmpeg\' is not valid. Please check settings on the !ffmpeg_settings_page', array('!ffmpeg_settings_page' => l(t('Video ffmpeg helper settings page'), 'admin/settings/video/ffmpeg_helper'))), 'error'); @@ -130,44 +126,49 @@ /** * Implementation of hook_form_alter() */ -function video_image_form_alter($form_id, &$form) { - - if($form_id == 'video_node_form') { - - $node = $form['#node']; - $value = ($node->new_image) ? '#value' : '#default_value'; - $form['iid'] = array('#type' => 'hidden', $value => $node->iid); - - if (!is_array($node->tempimage['fids'])) { - $fids = array('_original' => 0); - foreach (_image_get_sizes() as $size) { - $fids[$size['label']] = 0; - } - $node->tempimage['fids'] = $fids; - } - $form['tempimage']['#tree'] = true; - foreach ($node->tempimage['fids'] as $label => $fid) { - $form['tempimage']['fids'][$label] = array('#type' => 'hidden', $value => $fid); +function video_image_form_video_node_form_alter(&$form, &$form_state) { + $form['#validate'][] = 'video_image_validate'; + $form['#submit'][] = 'video_image_submit'; + + $node = $form['#node']; + if (!isset($node->nid)) { + $node->iid = null; + $node->tempimage = null; + $node->new_image = null; + $node->nid = 0; + } + $value = ($node->new_image) ? '#value' : '#default_value'; + $form['iid'] = array('#type' => 'hidden', $value => $node->iid); + + if (!is_array($node->tempimage['fids'])) { + $fids = array('_original' => 0); + foreach (_image_get_sizes() as $size) { + $fids[$size['label']] = 0; } + $node->tempimage['fids'] = $fids; + } + $form['tempimage']['#tree'] = true; + foreach ($node->tempimage['fids'] as $label => $fid) { + $form['tempimage']['fids'][$label] = array('#type' => 'hidden', $value => $fid); + } - $auto_thumbable = video_image_is_autothumbable($node); + $auto_thumbable = video_image_is_autothumbable($node); - if(!$auto_thumbable || user_access('override autothumnailing using uploaded images')) { - // let's be sure that image directories are ready - if (function_exists('_image_check_settings')) { - _image_check_settings(); - } - // needed for uploading - $form['#attributes'] = array("enctype" => "multipart/form-data"); + if(!$auto_thumbable || user_access('override autothumnailing using uploaded images')) { + // let's be sure that image directories are ready + if (function_exists('_image_check_settings')) { + _image_check_settings(); + } + // needed for uploading + $form['#attributes'] = array("enctype" => "multipart/form-data"); - $form['image'] = array('#type' => 'fieldset', '#title' => t('Image thumbnails'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => -17, '#description' => t('Upload an image to be used as the thumbnail for this video.')); + $form['image'] = array('#type' => 'fieldset', '#title' => t('Image thumbnails'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => -17, '#description' => t('Upload an image to be used as the thumbnail for this video.')); - $form['image']['image'] = array('#type' => 'file', '#title' => t('Image')); - } - if ($node->nid && $auto_thumbable) { - $form['regenerate_thumbnail'] = array('#type' => 'checkbox', '#title' => t('Auto regenerate thumbnail'), '#default_value' => 0); - } + $form['image']['image'] = array('#type' => 'file', '#title' => t('Image')); + } + if ($node->nid && $auto_thumbable) { + $form['regenerate_thumbnail'] = array('#type' => 'checkbox', '#title' => t('Auto regenerate thumbnail'), '#default_value' => 0); } } @@ -181,25 +182,45 @@ case 'load': return _video_image_load($node); - case 'prepare': - _video_image_prepare($node); - break; - - case 'submit': - _video_image_submit($node); - break; - case 'view': _video_image_view($node, $teaser); break; + case 'delete': _video_image_delete($node); break; + + case 'delete revision': + _video_image_delete_revision($node); + break; + + case 'insert': + video_image_insert($node); + break; + + case 'update': + video_image_update($node); + break; } } } +/* Implement the hook_theme registry. Combine all theme registry entries + into one hook_theme function in each corresponding module file. +*/ +function video_image_theme() { + return array( + 'video_image_teaser' => array( + 'file' => 'video_image.module', + 'arguments' => array( + 'image' => NULL, + 'video' => NULL, + ), + ), + ); +} + /** * Renders thumbnail node with a link to the video node to be used on video teasers. * @@ -216,15 +237,11 @@ $image_html = NULL; if($image != NULL && $image->type == 'image') { + $image->title = $video->title; $image_html = image_display($image, 'thumbnail', array('class' => 'video_image_teaser')); - } - else if($image_node == NULL && $video->serial_data['image_teaser']){ // only for backward compatibility - $image_html = theme('image', $video->serial_data['image_teaser'], $video->title, $video->title, array('class' => 'video_image_teaser'), FALSE); - } - - if($image) { + //Create a link with an image in it. - $output .= l($image_html, "node/$video->nid", array(), NULL, NULL, FALSE, TRUE); + $output .= l($image_html, "node/$video->nid", array('html' => TRUE)); $output .= '
    '; } return $output; @@ -233,83 +250,91 @@ /* nodeapi split out hooks */ function _video_image_load(&$node) { - $output['iid'] = $node->serial_data['iid']; + $output = db_fetch_array(db_query('SELECT iid FROM {video_image} WHERE vid=%d', $node->vid)); + + if (!is_array($output)) { + return array('iid' => null); + } return $output; } -function _video_image_prepare(&$node) { +function video_image_validate($form, &$form_state) { + $node = (object)$form_state['values']; + if (!isset($node->vtype)) { + return; + } // let's check that we have a valid image if (count($_POST)) { - $field_name = file_check_upload('image'); - if (!$field_name && video_image_is_autothumbable($node)) { - _video_image_thumbnail_debug(t('video_image_nodeapi: prepare: ready to thumbnail video')); - $field_name = module_invoke('video_' . $node->vtype, 'v_auto_thumbnail', $node); - if ($field_name === false && count($_POST)) { + $validators = array( + 'file_validate_is_image' => array(), + ); + + $file = file_save_upload('image', $validators); + if (!$file && !isset($form_state['storage']['video_image_file']) && video_image_is_autothumbable($node)) { + _video_image_thumbnail_debug(t('#validate: ready to thumbnail video')); + $file = module_invoke('video_' . $node->vtype, 'v_auto_thumbnail', $node); + if ($file === false && count($_POST)) { drupal_set_message(t('The thumbnailing process of your video failed for some reason. Video thumbnail will not be available.'), 'error'); } } - } - if ($field_name) { - $node->tempimage = _video_image_temp_image_store($field_name); - $node->new_image = TRUE; - } else if (is_array($_POST['tempimage']) && - ($_POST['op'] == 'Preview' || $_POST['op'] == 'Submit')) { - $node->tempimage = (array)_video_image_temp_image_load(array_values($_POST['tempimage']['fids'])); + if ($file) { + file_move($file, _image_filename($file->filename, IMAGE_ORIGINAL, TRUE)); + $form_state['storage']['video_image_file'] = $file; + } } } -function _video_image_submit(&$node) { +function video_image_submit($form, &$form_state) { + /* if ($node->regenerate_thumbnail) { _video_image_regenerate_thumbnail($node); } - if (is_array($node->tempimage['fids']) && $node->tempimage['fids']['_original']) { - $image = _video_image_temp_image_load(array_values($node->tempimage['fids'])); - db_query("DELETE FROM {files} WHERE fid in (%s)", - implode(',', array_values($node->tempimage['fids']))); - // initialize standard node fields - $image->uid = $node->uid; - $image->created = time(); - $image->title = t('Video thumbnail for !title', array('!title' => $node->title)); - $image = node_submit($image); - $image->uid = $node->uid; - $image->status = _video_image_publish_thumbnails(); - $image->promote = _video_image_promote_thumbnails(); - // This is a messages hack (we don't want to see what happens under the covers) - _video_image_pause_messages(true); - if ($node->iid) { - $oldimage = node_load($node->iid); - $oldimage->images = $image->images; - // delete the old images? - $oldimage->new_image = 1; - node_save($oldimage); - $node->iid = $oldimage->nid; - } else { - node_save($image); - $node->iid = $image->nid; - // store the iid into the serial_data - $node->serial_data['iid'] = $node->iid; - // needed to set the correct status and promote values even if the user does not have enough permissions. Is there a better solution??? - // db_query('UPDATE {node} SET status = %d, promote = %d WHERE nid = %d AND vid = %d', _video_image_publish_thumbnails(), _video_image_promote_thumbnails(), $image->nid, $image->vid); - } - _video_image_pause_messages(); - } - else { - $node->serial_data['iid'] = $node->iid; + */ + $form_state['values']['video_image_file'] = $form_state['storage']['video_image_file']; + // only clear storage if we are on the final submit + // This allows us to automatically forward to the newly created node + if ($form_state['clicked_button']['#value'] == t('Save') || + $form_state['clicked_button']['#value'] == t('Delete')) { + unset($form_state['storage']['video_image_file']); } } +function video_image_save(&$node) { + $file = $node->video_image_file; + db_query("DELETE FROM {files} WHERE fid = %d", $file->fid); + file_move($file, file_directory_temp($file->filename)); + + // This is a messages hack (we don't want to see what happens under the covers) + //_video_image_pause_messages(true); + $title = t('Video thumbnail for !title', array('!title' => $node->title)); + $image = image_create_node_from($file->filepath, $title); + // initialize standard node fields + $image->uid = $node->uid; + $image->status = _video_image_publish_thumbnails(); + $image->promote = _video_image_promote_thumbnails(); + db_query('UPDATE {node} SET uid=%d, status=%d, promote=%d WHERE nid=%d', + $image->uid, $image->status, $image->promote, $image->nid); + //_video_image_pause_messages(); + $node->iid = $image->nid; +} + +function video_image_insert(&$node) { + video_image_save($node); + db_query('INSERT INTO {video_image} (vid,iid) VALUES (%d,%d)', $node->vid, $node->iid); +} + function _video_image_view(&$node, $teaser) { - if (is_array($node->tempimage['fids']) && $node->tempimage['fids']['_original']) { - $image = _video_image_temp_image_load(array_values($node->tempimage['fids'])); - } else if ($node->iid) { - $image = node_load($node->iid); + if (isset($node->iid)) { + if (!$node->iid) { + $image = _video_image_temp_image_load($node); + } else { + $image = node_load($node->iid); + } } else { $image = NULL; // this is for backward compatibility } - if($teaser) { - $node->content['video_image_thumbnail'] = array('#value' => theme('video_image_teaser', $image, $node)); - } + $node->content['video_image_thumbnail'] = array('#value' => theme('video_image_teaser', $image, $node)); } function _video_image_regenerate_thumbnail(&$node) { @@ -354,43 +379,17 @@ } } -function _video_image_temp_image_store(&$file) { - $image = new stdClass(); - $image->type = 'image'; - $image->uid = 1; - $image->created = time(); - $image->title = t('video image thumbnail'); - image_prepare($image, $file); - if ($image->images) { - node_validate($image); - if (!form_get_errors()) { - // save the images in the files table - foreach ($image->images as $l => $f) { - $info = image_get_info($f); - $fid = db_next_id('{files}_fid'); - db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize) VALUES (%d, %d, '%s', '%s', '%s', '%s')", - $fid, 1, "video_image_temp.$l", $f, $info['mime_type'], $info['file_size']); - $image->fids[$l] = $fid; - } - } - } - return (array)$image; -} - /* Create a fake node object that acts like an image node * by looking up each file in the array $fids and loading * them into the images array. */ -function _video_image_temp_image_load($fids) { +function _video_image_temp_image_load($node) { $image = new stdClass(); $image->type = 'image'; $image->new_file = 1; - $fids = implode(',', $fids); - $results = db_query("SELECT fid, filename, filepath FROM {files} WHERE fid IN (%s)", $fids); - while ($file = db_fetch_object($results)) { - $label = substr($file->filename, 17); - $image->images[$label] = $file->filepath; - $image->fids[$label] = $file->fid; + $file = $node->video_image_file; + foreach (image_get_sizes() as $key => $size) { + $image->images[$key] = $file->filepath; } return $image; } @@ -431,23 +430,26 @@ */ function _video_image_get_thumb_file_object($thumbnail_url, $id) { - if($thumbnail_url && $thumbnail_url != '' && $image = image_gd_open($thumbnail_url, 'jpeg')) { - // save image to temp directory for processing - $location = file_directory_temp() .'/'. $id .'.jpg'; - image_gd_close($image, $location, 'jpeg'); - + if($thumbnail_url && $thumbnail_url != '') { + $request = drupal_http_request($thumbnail_url); + if ($request->code == 200) { + // save image to temp directory for processing + $location = file_directory_temp() .'/'. $id .'.jpg'; + file_put_contents($location, $request->data); - // get info and build a file object - $filepath = file_create_path($location, file_directory_temp()); - $info = image_get_info($filepath); + // get info and build a file object + $filepath = file_create_path($location, file_directory_temp()); + $info = image_get_info($filepath); + + $file = new stdClass(); + $file->filepath = realpath($filepath); + $file->filename = basename($file->filepath); + $file->filesize = $info['file_size']; + $file->filemime = $info['mime_type']; - $file = new stdClass(); - $file->filepath = realpath($filepath); - $file->filename = basename($file->filepath); - $file->filesize = $info['file_size']; - $file->filemime = $info['mime_type']; - - return $file; + return $file; + } + return null; } return null; Index: plugins/video_multidownload/video_multidownload.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/plugins/video_multidownload/video_multidownload.info,v retrieving revision 1.2 diff -u -r1.2 video_multidownload.info --- plugins/video_multidownload/video_multidownload.info 11 Nov 2006 03:58:41 -0000 1.2 +++ plugins/video_multidownload/video_multidownload.info 16 Dec 2008 05:24:34 -0000 @@ -1,5 +1,13 @@ ; $Id: video_multidownload.info,v 1.2 2006/11/11 03:58:41 fax8 Exp $ name = Video Multidownload description = Enable multiple file download in video module. -dependencies = video +dependencies[] = video package = "Video" + +; Information added by drupal.org packaging script on 2008-04-09 +version = "5.x-1.x-dev" +project = "video" +datestamp = "1207700333" + + +core = 6.x \ No newline at end of file Index: plugins/video_multidownload/video_multidownload.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/plugins/video_multidownload/video_multidownload.module,v retrieving revision 1.8.2.1 diff -u -r1.8.2.1 video_multidownload.module --- plugins/video_multidownload/video_multidownload.module 11 Feb 2008 06:00:22 -0000 1.8.2.1 +++ plugins/video_multidownload/video_multidownload.module 16 Dec 2008 05:24:34 -0000 @@ -1,6 +1,66 @@ 'image_button', + '#title' => t('My button'), + '#return_value' => 'my_data', + '#src' => 'my/image/path.jpg', +); */ + +/* TODO New user_mail_tokens() method may be useful. + user.module now provides a user_mail_tokens() function to return an array + of the tokens available for the email notification messages it sends when + accounts are created, activated, blocked, etc. Contributed modules that + wish to make use of the same tokens for their own needs are encouraged + to use this function. */ + +/* TODO + There is a new hook_watchdog in core. This means that contributed modules + can implement hook_watchdog to log Drupal events to custom destinations. + Two core modules are included, dblog.module (formerly known as watchdog.module), + and syslog.module. Other modules in contrib include an emaillog.module, + included in the logging_alerts module. See syslog or emaillog for an + example on how to implement hook_watchdog. +function example_watchdog($log = array()) { + if ($log['severity'] == WATCHDOG_ALERT) { + mysms_send($log['user']->uid, + $log['type'], + $log['message'], + $log['variables'], + $log['severity'], + $log['referer'], + $log['ip'], + format_date($log['timestamp'])); + } +} */ + +/* TODO Implement the hook_theme registry. Combine all theme registry entries + into one hook_theme function in each corresponding module file. +function video_multidownload_theme() { + return array( + 'video_multidownload_download' => array( + 'file' => 'video_multidownload.module', + 'arguments' => array( + 'node' => NULL, + ), + ), + ); +} */ + +/* TODO You may want to take advantage of new form-specific alter hooks. + The hook_form_alter() is complemented by hook_form_$form-id_alter(). + Optionally, modules can implement form-specific alteration functions rather + than a single hook_form_alter() with many conditional switch statements. + This is optional, and is most useful for tidying the code of modules that + alter many forms to customize a site's operations. + The new function names are built using the following format: + [your-module-name]_form_[$form_id]_alter. */ + /** * @file * Enable multiple file download in video module. @@ -12,8 +72,8 @@ /** * Implementation of hook_help(). */ -function video_multidownload_help($section) { - switch ($section) { +function video_multidownload_help($path, $arg) { + switch ($path) { case 'admin/modules#description': return t('Enable multiple file download in video module.'); } @@ -29,35 +89,30 @@ * @return * array of menu information */ -function video_multidownload_menu($may_cache) { +function video_multidownload_menu() { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'admin/content/video/multidownload', - 'title' => t('Multidownload'), - 'description' => t('Administer video_multidownload module settings'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('video_multidownload_settings_form'), - 'access' => user_access('administer site configuration'), - 'type' => MENU_NORMAL_ITEM, - ); - } - else { + $items['admin/content/video/multidownload'] = array( + 'title' => 'Multidownload', + 'description' => 'Administer video_multidownload module settings', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('video_multidownload_settings_form'), + 'access arguments' => array('administer site configuration'), + 'type' => MENU_NORMAL_ITEM, + ); if (arg(0) == 'node' && is_numeric(arg(1))) { if ($node = node_load(arg(1)) and $node->type == 'video') { if(isset($node->disable_multidownload) && !$node->disable_multidownload && ($node->use_play_folder || $node->download_folder!='') ) { - $items[] = array('path' => 'node/'.arg(1).'/multidownload', - 'title' => t('download other formats'), - 'callback' => 'video_multidownload_download', - 'access' => user_access('access video'), + $items['node/'.'%'.'/multidownload'] = array( + 'title' => 'download other formats', + 'page callback' => 'video_multidownload_download', + 'access arguments' => array('access video'), 'weight' => 7, 'type' => MENU_LOCAL_TASK); } } - } } return $items; } @@ -100,7 +155,7 @@ * Implementation of hook_form_alter() * We use this to add multidownload fields to the video creation form. */ -function video_multidownload_form_alter($form_id, &$form) { +function video_multidownload_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'video_node_form' && isset($form['video']) && user_access('create multi-file downloads')) { @@ -112,7 +167,7 @@ '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => -18, - '#description' => t('These options allow you to have multiple files shown on the download page. This is useful for allowing users to download different file sizes and video formats. ') . l(t('More information.'), 'video/help', NULL, NULL, 'multi-download') + '#description' => t('These options allow you to have multiple files shown on the download page. This is useful for allowing users to download different file sizes and video formats. ') . l(t('More information.'), 'video/help', array('fragment' => 'multi-download')) ); $form['multi-file']['disable_multidownload'] = array( '#type' => 'checkbox', Index: plugins/video_optmetadata/video_optmetadata.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/plugins/video_optmetadata/video_optmetadata.info,v retrieving revision 1.2 diff -u -r1.2 video_optmetadata.info --- plugins/video_optmetadata/video_optmetadata.info 11 Nov 2006 03:58:41 -0000 1.2 +++ plugins/video_optmetadata/video_optmetadata.info 16 Dec 2008 05:24:34 -0000 @@ -1,5 +1,13 @@ ; $Id: video_optmetadata.info,v 1.2 2006/11/11 03:58:41 fax8 Exp $ name = Video Opt Metadata description = Enable addition of optional metadata on video nodes created by video module. Optional metadata are Video Bitrate, Audio Bitrate, Audio Sampling Rate and Audio Channels. -dependencies = video +dependencies[] = video package = "Video" + +; Information added by drupal.org packaging script on 2008-04-09 +version = "5.x-1.x-dev" +project = "video" +datestamp = "1207700333" + + +core = 6.x \ No newline at end of file Index: plugins/video_optmetadata/video_optmetadata.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/plugins/video_optmetadata/video_optmetadata.module,v retrieving revision 1.1 diff -u -r1.1 video_optmetadata.module --- plugins/video_optmetadata/video_optmetadata.module 18 Jun 2006 14:41:32 -0000 1.1 +++ plugins/video_optmetadata/video_optmetadata.module 16 Dec 2008 05:24:34 -0000 @@ -1,6 +1,66 @@ 'image_button', + '#title' => t('My button'), + '#return_value' => 'my_data', + '#src' => 'my/image/path.jpg', +); */ + +/* TODO New user_mail_tokens() method may be useful. + user.module now provides a user_mail_tokens() function to return an array + of the tokens available for the email notification messages it sends when + accounts are created, activated, blocked, etc. Contributed modules that + wish to make use of the same tokens for their own needs are encouraged + to use this function. */ + +/* TODO + There is a new hook_watchdog in core. This means that contributed modules + can implement hook_watchdog to log Drupal events to custom destinations. + Two core modules are included, dblog.module (formerly known as watchdog.module), + and syslog.module. Other modules in contrib include an emaillog.module, + included in the logging_alerts module. See syslog or emaillog for an + example on how to implement hook_watchdog. +function example_watchdog($log = array()) { + if ($log['severity'] == WATCHDOG_ALERT) { + mysms_send($log['user']->uid, + $log['type'], + $log['message'], + $log['variables'], + $log['severity'], + $log['referer'], + $log['ip'], + format_date($log['timestamp'])); + } +} */ + +/* TODO Implement the hook_theme registry. Combine all theme registry entries + into one hook_theme function in each corresponding module file. +function video_optmetadata_theme() { + return array( + 'video_metadata' => array( + 'file' => 'video_optmetadata.module', + 'arguments' => array( + 'node' => NULL, + ), + ), + ); +} */ + +/* TODO You may want to take advantage of new form-specific alter hooks. + The hook_form_alter() is complemented by hook_form_$form-id_alter(). + Optionally, modules can implement form-specific alteration functions rather + than a single hook_form_alter() with many conditional switch statements. + This is optional, and is most useful for tidying the code of modules that + alter many forms to customize a site's operations. + The new function names are built using the following format: + [your-module-name]_form_[$form_id]_alter. */ + /** * @file * Enable addition of optional metadata on video nodes created by video module. @@ -12,8 +72,8 @@ /** * Implementation of hook_help(). */ -function video_optmetadata_help($section) { - switch ($section) { +function video_optmetadata_help($path, $arg) { + switch ($path) { case 'admin/modules#description': return t('Enable addition of optional metadata on video nodes created by video module. Optional metadata are Video Bitrate, Audio Bitrate, Audio Sampling Rate and Audio Channels.'); } @@ -34,7 +94,7 @@ * We use this to add some fields to the video creation form. * In those fields users will be able to insert some video metadatas. */ -function video_optmetadata_form_alter($form_id, &$form) { +function video_optmetadata_form_alter(&$form, &$form_state, $form_id) { if($form_id == 'video_node_form' && isset($form['video']) && user_access('insert optional metadata')) { Index: plugins/video_params/video_params.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/plugins/video_params/video_params.info,v retrieving revision 1.2 diff -u -r1.2 video_params.info --- plugins/video_params/video_params.info 11 Nov 2006 03:58:41 -0000 1.2 +++ plugins/video_params/video_params.info 16 Dec 2008 05:24:34 -0000 @@ -1,5 +1,13 @@ ; $Id: video_params.info,v 1.2 2006/11/11 03:58:41 fax8 Exp $ name = Video Params description = Enable addition of html params to object generated by video module. Useful if you need to use swf videos which needs params to be passed. -dependencies = video +dependencies[] = video package = "Video" + +; Information added by drupal.org packaging script on 2008-04-09 +version = "5.x-1.x-dev" +project = "video" +datestamp = "1207700333" + + +core = 6.x \ No newline at end of file Index: plugins/video_params/video_params.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/plugins/video_params/video_params.module,v retrieving revision 1.1 diff -u -r1.1 video_params.module --- plugins/video_params/video_params.module 18 Jun 2006 14:41:32 -0000 1.1 +++ plugins/video_params/video_params.module 16 Dec 2008 05:24:34 -0000 @@ -1,6 +1,71 @@ 'image_button', + '#title' => t('My button'), + '#return_value' => 'my_data', + '#src' => 'my/image/path.jpg', +); */ + +/* TODO hook_nodeapi('submit') has been replaced by op='presave' + There is no longer a 'submit' op for nodeapi. Instead you may use the newly + created 'presave' op. Note, however, that this op is invoked at the beginning + of node_save(), in contrast to op='submit' which was invoked at the end of + node_submit(). Thus 'presave' operations will be performed on nodes that are + saved programatically via node_save(), while in Drupal 5.x op='submit' was + only applied to nodes saved via the node form. Note that the node form is now, + in effect, a multistep form (for example when previewing), so if you need to + fix up the data in the node for re-building the form, use a #submit function + added to the node form's $form array. */ + +/* TODO New user_mail_tokens() method may be useful. + user.module now provides a user_mail_tokens() function to return an array + of the tokens available for the email notification messages it sends when + accounts are created, activated, blocked, etc. Contributed modules that + wish to make use of the same tokens for their own needs are encouraged + to use this function. */ + +/* TODO + There is a new hook_watchdog in core. This means that contributed modules + can implement hook_watchdog to log Drupal events to custom destinations. + Two core modules are included, dblog.module (formerly known as watchdog.module), + and syslog.module. Other modules in contrib include an emaillog.module, + included in the logging_alerts module. See syslog or emaillog for an + example on how to implement hook_watchdog. +function example_watchdog($log = array()) { + if ($log['severity'] == WATCHDOG_ALERT) { + mysms_send($log['user']->uid, + $log['type'], + $log['message'], + $log['variables'], + $log['severity'], + $log['referer'], + $log['ip'], + format_date($log['timestamp'])); + } +} */ + +/* TODO Implement the hook_theme registry. Combine all theme registry entries + into one hook_theme function in each corresponding module file. +function video_params_theme() { + return array( + ); +} */ + +/* TODO You may want to take advantage of new form-specific alter hooks. + The hook_form_alter() is complemented by hook_form_$form-id_alter(). + Optionally, modules can implement form-specific alteration functions rather + than a single hook_form_alter() with many conditional switch statements. + This is optional, and is most useful for tidying the code of modules that + alter many forms to customize a site's operations. + The new function names are built using the following format: + [your-module-name]_form_[$form_id]_alter. */ + /** * @file * Enable addition of params to object generated by video module @@ -13,8 +78,8 @@ /** * Implementation of hook_help(). */ -function video_params_help($section) { - switch ($section) { +function video_params_help($path, $arg) { + switch ($path) { case 'admin/modules#description': return t('Enable addition of html params to object generated by video module. Useful if you need to use swf videos which needs params to be passed.'); } @@ -36,7 +101,7 @@ * We use this to add a text area to the video creation form. * In the text area the user will be able to insert his param value association. */ -function video_params_form_alter($form_id, &$form) { +function video_params_form_alter(&$form, &$form_state, $form_id) { if($form_id == 'video_node_form' && isset($form['video']) && user_access('insert object params')) { Index: types/video_google/video_google.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/types/video_google/Attic/video_google.info,v retrieving revision 1.1.2.1 diff -u -r1.1.2.1 video_google.info --- types/video_google/video_google.info 11 Feb 2008 06:00:22 -0000 1.1.2.1 +++ types/video_google/video_google.info 16 Dec 2008 05:24:34 -0000 @@ -1,5 +1,13 @@ ; $Id: video_google.info,v 1.1.2.1 2008/02/11 06:00:22 fax8 Exp $ name = Google Video description = Enable Google video support for Video module. -dependencies = video +dependencies[] = video package = "Video" + +; Information added by drupal.org packaging script on 2008-04-09 +version = "5.x-1.x-dev" +project = "video" +datestamp = "1207700333" + + +core = 6.x \ No newline at end of file Index: types/video_google/video_google.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/types/video_google/Attic/video_google.module,v retrieving revision 1.1.2.4 diff -u -r1.1.2.4 video_google.module --- types/video_google/video_google.module 5 Mar 2008 16:23:38 -0000 1.1.2.4 +++ types/video_google/video_google.module 16 Dec 2008 05:24:34 -0000 @@ -13,18 +13,19 @@ /** * Implementation of hook_menu */ -function video_google_menu($maycache) { +function video_google_menu() { $items = array(); - if($maycache) { - $items[] = array( - 'path' => 'node/add/video/google', - 'title' => t('Google'), - 'access' => user_access('create video') - ); - } return $items; } +function video_google_theme() { + return array( + 'video_google_play' => array( + 'arguments' => array('node' => NULL), + ), + ); +} + /** * Implementation of hook_v_help @@ -49,7 +50,7 @@ '#description' => t('Post a video available on !link to this website.', array('!link' => l(t('Google Video'), 'http://video.google.com'), NULL, NULL, NULL, TRUE)), '#autothumbable' => true, '#autoresolution' => true, - '#autoplaytime' => false, // seems that thereisn't a video lenght field in the google video xml + '#autoplaytime' => true, ); return $info; @@ -57,9 +58,16 @@ /** - * Implementation of hook_v_form() + * Implementation of hook_form_alter() */ -function video_google_v_form(&$node, &$form) { +function video_google_form_video_node_form_alter(&$form, &$form_values) { + $node = $form['#node']; + if ($node->vtype != 'google') { + return; + } + + $form['#validate'][] = 'video_google_validate'; + //$form['#submit'][] = 'video_google_submit'; $form['video']['vidfile'] = array( '#type' => 'textfield', @@ -68,7 +76,7 @@ '#maxlength' => 700, '#required' => TRUE, '#weight' => -20, - '#description' => t('Insert the URL to the google video. ') . l(t('More information.'), 'video/help', NULL, NULL, 'videofile')); + '#description' => t('Insert the URL to the google video. ') . l(t('More information.'), 'video/help', array('fragment' => 'videofile'))); return $form; } @@ -76,16 +84,16 @@ /** - * implementation of hook_v_validate + * implementation of hook_validate */ -function video_google_v_validate($node) { +function video_google_validate($form, &$form_state) { // TODO: use youtube REST or XML-RPC to query youtube: check video available and embeddable - if(!preg_match("/^http:\/\/video\.google\.com\/videoplay\?docid=/", $node->vidfile)) { + if(!preg_match(",^http://video\.google\.com/videoplay\?docid=,", $form_state['values']['vidfile'])) { form_set_error('vidfile', t('The Google Video URL field must be similar to http://video.google.com/videoplay?docid=1806507480014945777')); } else { //get the video id - $id = _video_google_get_id($node->vidfile); + $id = _video_google_get_id($form_state['values']['vidfile']); $response = _video_apiclient_google_request($id); if(count($response) == 0) { // google video wasn't able to find the video @@ -117,16 +125,7 @@ $xml = _video_apiclient_google_request($id); - // we *should* be able to use media:thumbnail - // but unfortunately, that is stripped out from the request hook - // so instead, we'll parse it from the description, where it's repeated. - // TODO: look into how to fix this... - $desc = $xml['ITEM']['DESCRIPTION'][0]; - $regex = '@vidfile) { - _video_image_thumbnail_debug(t('No new video to thumbnail')); - return NULL; - } - if ($_POST['tempimage']['fids']['_original']) { - _video_image_thumbnail_debug(t('Video already thumbnailed')); - return NULL; - } - } - // let's include apiclient logic - - //get the video id - if (!$node->vidfile && count($_POST)) { - $vidfile = $_POST['vidfile']; - } else { - $vidfile = $node->vidfile; - } + $vidfile = $node->vidfile; $id = _video_google_get_id($vidfile); // get thumbnail url $thumbnail_url = _video_apiclient_google_get_thumbnail_url($id); @@ -169,6 +151,15 @@ } +/** + * Implementation of hook_v_auto_playtime +*/ +function video_google_v_auto_playtime(&$node) { + $id = _video_google_get_id($node->vidfile); + $response = _video_apiclient_google_request($id); // NOTE: here we already passed validation so we expect a valid response + + return $response['ITEM']['MEDIA:GROUP']['MEDIA:CONTENT'][0]['DURATION']; // return the length in seconds +} /** THEMEABLE FUNCTIONS */ @@ -236,4 +227,4 @@ -require_once(drupal_get_path('module', 'video') .'/includes/apiclient.inc'); +module_load_include('inc', 'video', 'includes/apiclient'); Index: types/video_upload/video_upload.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/types/video_upload/Attic/video_upload.info,v retrieving revision 1.1.2.1 diff -u -r1.1.2.1 video_upload.info --- types/video_upload/video_upload.info 11 Feb 2008 06:00:23 -0000 1.1.2.1 +++ types/video_upload/video_upload.info 16 Dec 2008 05:24:34 -0000 @@ -1,5 +1,14 @@ ; $Id: video_upload.info,v 1.1.2.1 2008/02/11 06:00:23 fax8 Exp $ name = Upload Video description = Enable Uploaded video support for Video module. -dependencies = video token +dependencies[] = video +dependencies[] = token package = "Video" + +; Information added by drupal.org packaging script on 2008-04-09 +version = "5.x-1.x-dev" +project = "video" +datestamp = "1207700333" + + +core = 6.x \ No newline at end of file Index: types/video_upload/video_upload.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/types/video_upload/Attic/video_upload.module,v retrieving revision 1.1.2.8 diff -u -r1.1.2.8 video_upload.module --- types/video_upload/video_upload.module 8 Apr 2008 19:52:41 -0000 1.1.2.8 +++ types/video_upload/video_upload.module 16 Dec 2008 05:24:34 -0000 @@ -14,28 +14,45 @@ /** * Implementation of hook_menu */ -function video_upload_menu($maycache) { +function video_upload_menu() { $items = array(); - if($maycache) { - $items[] = array( - 'path' => 'node/add/video/upload', - 'title' => t('Upload'), - 'access' => user_access('create video') + /* + $items['node/add/video/upload'] = array( + 'title' => 'Upload', + 'access arguments' => array('create video') ); - $items[] = array( - 'path' => 'admin/settings/video/upload', - 'title' => t('Upload'), - 'description' => t('Configure various settings of the video upload plugin.'), - 'access' => user_access('administer site configuration'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('video_upload_admin_settings'), + */ + $items['admin/settings/video/upload'] = array( + 'title' => 'Upload', + 'description' => 'Configure various settings of the video upload plugin.', + 'access arguments' => array('administer site configuration'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('video_upload_admin_settings'), 'type' => MENU_NORMAL_ITEM, ); - } return $items; } +function video_upload_theme() { + return array( + 'video_upload_file_info_form' => array( + 'file' => 'video_upload.module', + 'arguments' => array( + 'file' => NULL, + 'node' => NULL, + ), + ), + 'video_upload_get_script' => array( + 'file' => 'video_upload.module', + 'arguments' => array(), + ), + 'video_upload_busy' => array( + 'file' => 'video_upload.module', + 'arguments' => array(), + ), + ); +} /** * Setting form for video_upload @@ -128,7 +145,8 @@ function video_upload_v_auto_thumbnail(&$node) { // as we rely on ffmpeg_helper, let's check if we have video_ffmpeg_helper_installed if(module_exists('video_ffmpeg_helper')) { - return _video_ffmpeg_helper_auto_thumbnail($node); + $file = db_fetch_object(db_query('SELECT * FROM {files} WHERE fid = %d', $node->video_upload_file_fid)); + return _video_ffmpeg_helper_auto_thumbnail($file); } return false; } @@ -231,8 +249,17 @@ /** * Implementation of hook_v_form() */ -function video_upload_v_form(&$node, &$form) { - //print 'form'; +function video_upload_form_video_node_form_alter(&$form, &$form_values) { + $node = $form['#node']; + if ($node->vtype != 'upload') { + return; + } + + $form['#validate'][] = 'video_upload_validate'; + $form['#submit'][] = 'video_upload_submit'; + + _video_upload_check_settings(); + $we_have_video = false; // add js stuff for the 'upload in progess' message theme('video_upload_get_script'); @@ -242,9 +269,22 @@ // required for upload to work $form['#attributes']['enctype'] = 'multipart/form-data'; - $form['video'] += _video_upload_form($node); - return $form; + if (isset($node->video_upload_file)) { + $form['video']['video_upload_file_fid'] = array( + '#type' => 'hidden', + '#value' => $node->video_upload_file->fid, + ); + } + $form['video']['video_upload_file'] = array( + '#type' => 'file', + '#title' => $we_have_video ? t('Replace with') : t('Upload video file'), + '#size' => 40, + '#weight' => -9, + '#description' => t('Choose a video file from your pc.
    NOTE: The max upload size is') . ' ' . format_size(file_upload_max_size()) . '.', + // no need to set this as required as we do validation in the validate nodeapi hook + ); + } @@ -253,24 +293,16 @@ * Implementation of hook_nodeapi() */ function video_upload_nodeapi(&$node, $op) { + if (!isset($node->vtype)) { + return; + } + //m("video_upload_nodeapi: $op"); if($node->type == 'video' && $node->vtype == 'upload') { switch ($op) { case 'load': return _video_upload_load($node); - case 'prepare': - _video_upload_prepare($node); - break; - - case 'validate': - _video_upload_validate($node); - break; - - case 'submit': - _video_upload_submit($node); - break; - case 'insert': _video_upload_insert($node); break; @@ -294,14 +326,17 @@ } +function video_upload_delete_revision(&$node) { + file_set_status($node->video_upload_file, FILE_STATUS_TEMPORARY); + db_query('DELETE FROM {video_upload} WHERE vid=%d and fid=%d', $node->vid, $node->video_upload_file->fid); +} function _video_upload_load(&$node) { //print 'load'; $output = array(); - $output['video_fid'] = $node->serial_data['video_fid']; - $file = _video_upload_get_file($output['video_fid']); - $output['current_video_upload_file'] = $file; + $file = db_fetch_object(db_query('SELECT {f}.* FROM {files} f JOIN {video_upload} vu on f.fid=vu.fid WHERE vid=%d', $node->vid)); + $output['video_upload_file'] = $file; $output['vidfile'] = file_create_url($file->filepath); // set the filesize $output['size'] = $file->filesize; @@ -317,140 +352,90 @@ for some hints */ -function _video_upload_prepare(&$node) { - if (!count($_POST)) - return; - //print 'prepare'; - if (is_object($node->video_upload_file)) { - $file_field = $node->video_upload_file; - } else { - $file_field = 'video_upload_file'; - } - - if (count($_POST) && $file = file_check_upload($file_field)) { // a file has been uploaded - // this is the temp directory to store files - $temppath = file_directory_temp() . '/video/'; - // let's check that the directory is good - file_check_directory($temppath, TRUE); - // let's save the uploaded file to the temp directory - $file = file_save_upload($file, $temppath . '/' . $file->filename, FILE_EXISTS_REPLACE); - - // let's store the temp file into the DB - $file->fid = db_next_id('{files}_fid'); - db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize) VALUES (%d, %d, '%s', '%s', '%s', %d)", $file->fid, 1, 'video_upload_temp.'.$file->filename, $file->filepath, $file->filemime, $file->filesize); - - // TODO: delete here the previous $node->new_video_upload_file - - $node->new_video_upload_file = $file; - } - else if (($node->new_video_upload_file_fid || $_POST['new_video_upload_file_fid']) && $_POST['op'] == 'Submit') { - $node->new_video_upload_file = _video_upload_get_file($_POST['new_video_upload_file_fid']); - } - else if (($node->new_video_upload_file_fid || $_POST['new_video_upload_file_fid']) && $_POST['op'] == 'Preview') { - $node->new_video_upload_file = _video_upload_get_file($_POST['new_video_upload_file_fid']); - - } +function file_validate_is_video($file) { + // check mime type and possibly file extension + $errors = array(); + return $errors; } /** -* Create video upload specific form fields -*/ -function _video_upload_form(&$node) { - _video_upload_check_settings(); + * Validate video file and save uploaded file to temporary location + */ +function video_upload_validate($form, &$form_state) { + if ($form_state['clicked_button']['#value'] == t('Delete')) { + return; + } - $form = array(); + $node = $form['#node']; - if($node->new_video_upload_file) { // there is a newly uploaded file (this has been initialized by _prepare()) - $form['new_video_upload_file_fid'] = array('#type' => 'hidden', '#value' => $node->new_video_upload_file->fid); - $form['new_video_upload_file_info'] = array('#type' => 'item', '#value' => theme('video_upload_file_info_form', $node->new_video_upload_file, $node), '#weight' => -10); - - $we_have_video = true; - } - else { - $form['new_video_upload_file_fid'] = array('#type' => 'hidden', '#value' => 0); - if($node->current_video_upload_file) { // we don't have a new file - $form['current_video_upload_file_fid'] = array('#type' => 'hidden', '#value' => $node->current_video_upload_file->fid); - $form['current_video_upload_file_info'] = array('#type' => 'item', '#value' => theme('video_upload_file_info_form', $node->current_video_upload_file, $node), '#weight' => -10); - - $we_have_video = true; + $validators = array( + 'file_validate_is_video' => array(), + 'file_validate_size' => array(30 * 1024 * 1024), + ); + + $file = false; + if (count($_POST)) { + if ($file = file_save_upload('video_upload_file', $validators)) { // a file has been uploaded + $form_state['storage']['video_upload_file'] = $file; + $form_state['values']['video_upload_file_fid'] = $file->fid; } } - $form['video_upload_file'] = array( - '#type' => 'file', - '#title' => $we_have_video ? t('Replace with') : t('Upload video file'), - '#size' => 40, - '#weight' => -9, - '#description' => t('Choose a video file from your pc.
    NOTE: The max upload size is') . ' ' . format_size(file_upload_max_size()) . '.', - // no need to set this as required as we do validation in the validate nodeapi hook - ); - return $form; + if(!($form_state['storage']['video_upload_file'] || $form_state['values']['video_upload_file_fid'])) { + form_set_error('video_upload_file', t('You have not provided any video file. Please upload one.
    If you uploaded a video but the system did not received it, please check that it is smaller than') . ' ' . format_size(file_upload_max_size()).'.'); + } } - /** - * Validate video file + * Validate video file and save uploaded file to temporary location */ -function _video_upload_validate(&$node) { - //print 'validate'; - //print_r($node); die; - - if(!($node->new_file_uploaded || $node->new_video_upload_file_fid > 0 || $node->new_video_upload_file_fid > 0 || $node->current_video_upload_file_fid > 0)) { // - form_set_error('video_upload_file', t('You have not provided any video file. Please upload one.
    If you uploaded a video but the system did not received it, please check that it is smaller than') . ' ' . format_size(file_upload_max_size()).'.'); - } - else if($node->new_file_uploaded || $node->new_video_upload_file_fid > 0 || $node->new_video_upload_file_fid > 0){ - if($node->new_file_uploaded) { // only if the user oploaded a new file - $file = $node->new_file_uploaded; - } - else { - $file = _video_upload_get_file($node->new_video_upload_file_fid); - } - - // let's check file extension - $extensions = variable_get('video_upload_allowed_extensions', 'mov,flv,wmv'); - $regex = '/\.('. ereg_replace(',+', '|', preg_quote($extensions)) .')$/i'; - if (!preg_match($regex, $file->filename)) { - //set an error message and delete the the file - form_set_error('audio', t('The selected file %name can not be uploaded, because it is only possible to upload files with the following extensions: %files-allowed.', array('%name' => $file->filename, '%files-allowed' => $extensions))); - _video_upload_delete_file($file); - } +function video_upload_submit($form, &$form_state) { + $node =& $form['#node']; + if ($node->vtype != 'upload') { + return; } -} - -function _video_upload_submit(&$node) { - //print 'submit'; - - //print_r($node); die; - if($node->new_video_upload_file_fid) { - $fid = $node->new_video_upload_file_fid; + $form_state['values']['video_upload_file'] = $form_state['storage']['video_upload_file']; + // only clear storage if we are on the final submit + // This allows us to automatically forward to the newly created node + if ($form_state['clicked_button']['#value'] == t('Save') || + $form_state['clicked_button']['#value'] == t('Delete')) { + unset($form_state['storage']['video_upload_file']); } - else { - $fid = $node->current_video_upload_file_fid; - } - $node->serial_data['video_fid'] = $fid; } + function _video_upload_insert(&$node) { //print 'insert'; - if($node->new_video_upload_file_fid && $file = _video_upload_get_file($node->new_video_upload_file_fid)) { // there is a new file uploaded (now stored on the temp path); need to store in the final directory - - _video_upload_store_file($file, $node); - } + $file = $node->video_upload_file; + $new_path = _video_upload_get_path($file, $node); + file_move($file, $new_path); + db_query('UPDATE {files} SET filepath="%s", status=%d WHERE fid=%d', $file->filepath, FILE_STATUS_PERMANENT, $file->fid); + db_query('INSERT INTO {video_upload} (vid, fid) VALUES (%d, %d)', $node->vid, $file->fid); } function _video_upload_update(&$node) { //print 'update'; - - if($node->new_video_upload_file_fid && $file = _video_upload_get_file($node->new_video_upload_file_fid)) { // there is a new file uploaded (now stored on the temp path) - //need to store in the final directory - _video_upload_store_file($file, $node); - - if($node->current_video_upload_file) { - // let's delete the old video - _video_upload_delete_file($node->current_video_upload_file); + // there is a new file uploaded (now stored on the temp path) + if($node->video_upload_file && $node->video_upload_file_fid && + $node->video_upload_file->fid != $node->video_upload_file_fid) { + + if ($node->revision) { + return _video_upload_insert($node); } + // mark the file as temporary so the GC can clean it up + $file = new stdclass(); + $file->fid = $node->video_upload_file_fid; + file_set_status($file, FILE_STATUS_TEMPORARY); + db_query('DELETE FROM {video_upload} WHERE vid=%d AND fid=%d', + $node->vid, $file->fid); + // replace the old video in the video_upload table + $file = $node->video_upload_file; + $new_path = _video_upload_get_path($file, $node); + file_move($file, $new_path); + db_query('UPDATE {files} SET filepath="%s", status=%d WHERE fid=%d', $file->filepath, FILE_STATUS_PERMANENT, $file->fid); + db_query('INSERT INTO {video_upload} (vid, fid) VALUES (%d, %d)', $node->vid, $file->fid); } } @@ -461,12 +446,11 @@ function _video_upload_delete(&$node) { //print 'delete'; - // delete file - file_delete($node->current_video_upload_file->path); + // delete file (mark as temp and let the GC take it) + file_set_status($node->video_upload_file, FILE_STATUS_TEMPORARY); // delete file information from database - db_query('DELETE FROM {file_revisions} WHERE fid = %d', $node->current_video_upload_file->fid); - db_query('DELETE FROM {files} WHERE fid = %d', $node->current_video_upload_file->fid); + db_query('DELETE FROM {video_upload} WHERE fid = %d', $node->video_upload_file->fid); } @@ -493,7 +477,7 @@ // update the file db entry db_query("UPDATE {files} SET nid = %d, filename = '%s', filepath = '%s', filemime = '%s', filesize = %d WHERE fid = %d", $node->nid, $file->filename, $file->filepath, $file->filemime, $file->filesize, $file->fid); // add an entry in the file_revisions table - db_query("INSERT INTO {file_revisions} (fid, vid, list, description) VALUES (%d, %d, %d, '%s')", $file->fid, $node->vid, $file->list, $file->description); + db_query("INSERT INTO {upload} (fid, vid, list, description) VALUES (%d, %d, %d, '%s')", $file->fid, $node->vid, $file->list, $file->description); } else { drupal_set_message(t('An error occurred during file saving. Your video file has not been stored.'), 'error'); @@ -501,7 +485,7 @@ '!path' => $file, '!dest' => $dest_path, ); - watchdog('video_upload', t('moving file !path to !dest failed', $rep)); + watchdog('video_upload', 'moving file !path to !dest failed', $rep); } } @@ -549,7 +533,7 @@ file_delete($file->path); // delete file information from database - db_query('DELETE FROM {file_revisions} WHERE fid = %d', $file->fid); + db_query('DELETE FROM {upload} WHERE fid = %d', $file->fid); db_query('DELETE FROM {files} WHERE fid = %d', $file->fid); } @@ -600,7 +584,6 @@ } */ return true; - } @@ -629,7 +612,7 @@ * Implementation of hook_v_play */ function video_upload_v_play($node) { - include(drupal_get_path('module', 'video') .'/includes/common.inc'); + module_load_include('inc', 'video', 'includes/common'); return _video_common_get_player($node); } Index: types/video_url/video_url.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/types/video_url/Attic/video_url.info,v retrieving revision 1.1.2.1 diff -u -r1.1.2.1 video_url.info --- types/video_url/video_url.info 11 Feb 2008 06:00:23 -0000 1.1.2.1 +++ types/video_url/video_url.info 16 Dec 2008 05:24:34 -0000 @@ -1,5 +1,13 @@ ; $Id: video_url.info,v 1.1.2.1 2008/02/11 06:00:23 fax8 Exp $ name = URL Video description = Enable URL video support for Video module. -dependencies = video +dependencies[] = video package = "Video" + +; Information added by drupal.org packaging script on 2008-04-09 +version = "5.x-1.x-dev" +project = "video" +datestamp = "1207700333" + + +core = 6.x \ No newline at end of file Index: types/video_url/video_url.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/types/video_url/Attic/video_url.module,v retrieving revision 1.1.2.4 diff -u -r1.1.2.4 video_url.module --- types/video_url/video_url.module 5 Mar 2008 14:31:52 -0000 1.1.2.4 +++ types/video_url/video_url.module 16 Dec 2008 05:24:35 -0000 @@ -13,16 +13,8 @@ /** * Implementation of hook_menu */ -function video_url_menu($maycache) { +function video_url_menu() { $items = array(); - if($maycache) { - $items[] = array( - 'path' => 'node/add/video/url', - 'title' => t('URL'), - 'access' => user_access('create video') - ); - } - return $items; } @@ -48,9 +40,9 @@ '#name' => 'URL Video', '#description' => t('Post a video available on the Internet to this website.'), '#downloadable' => TRUE, - '#autothumbable' => FALSE, - '#autoresolution' => FALSE, - '#autoplaytime' => FALSE, + '#autothumbable' => module_exists('video_ffmpeg_helper') && variable_get('video_image_auto_thumbnail', false), + '#autoresolution' => module_exists('video_ffmpeg_helper') && variable_get('video_ffmpeg_helper_auto_resolution', false), + '#autoplaytime' => module_exists('video_ffmpeg_helper') && variable_get('video_ffmpeg_helper_auto_playtime', false), ); return $info; @@ -60,7 +52,14 @@ /** * Implementation of hook_v_form() */ -function video_url_v_form(&$node, &$form) { +function video_url_form_video_node_form_alter(&$form, &$form_values) { + $node = $form['#node']; + if ($node->vtype != 'url') { + return; + } + + $form['#validate'][] = 'video_url_validate'; + //$form['#submit'][] = 'video_url_submit'; $form['video']['vidfile'] = array( '#type' => 'textfield', @@ -69,7 +68,7 @@ '#maxlength' => 700, '#required' => TRUE, '#weight' => -20, - '#description' => t('Insert the URL to the video file. This shuold be something similar to http://www.example.com/videos/myvideo.flv') . ' ' . l(t('More information.'), 'video/help', NULL, NULL, 'videofile')); + '#description' => t('Insert the URL to the video file. This shuold be something similar to http://www.example.com/videos/myvideo.flv') . ' ' . l(t('More information.'), 'video/help', array('fragment' => 'videofile'))); return $form; } @@ -78,7 +77,7 @@ /** * implementation of hook_v_validate */ -function video_url_v_validate($node) { +function video_url_validate($form, &$form_state) { // Can you suggest a validation? // validation should allow URLs, relative paths but also streaming servers URLs } @@ -87,7 +86,7 @@ * Implementation of hook_v_play */ function video_url_v_play($node) { - include_once(drupal_get_path('module', 'video') .'/includes/common.inc'); + module_load_include('inc', 'video', 'includes/common'); return _video_common_get_player($node); } @@ -101,4 +100,40 @@ header("Location: $url"); //Redirect to the video file URL. } +/** + * Implements the hook_v_auto_thumnail +*/ +function video_url_v_auto_thumbnail(&$node) { + // as we rely on ffmpeg_helper, let's check if we have video_ffmpeg_helper_installed + if(module_exists('video_ffmpeg_helper')) { + $file = new stdClass(); + $file->filepath = $node->vidfile; + return _video_ffmpeg_helper_auto_thumbnail($file); + } + return false; +} + + +/** + * Implements the hook_v_auto_resolution +*/ +function video_url_v_auto_resolution(&$node) { + // as we rely on ffmpeg_helper, let's check if we have video_ffmpeg_helper_installed + if(module_exists('video_ffmpeg_helper')) { + return _video_ffmpeg_helper_auto_resolution($node); + } + return false; +} + + +/** + * Implements the hook_v_auto_resolution +*/ +function video_url_v_auto_playtime(&$node) { + // as we rely on ffmpeg_helper, let's check if we have video_ffmpeg_helper_installed + if(module_exists('video_ffmpeg_helper')) { + return _video_ffmpeg_helper_auto_playtime($node); + } + return false; +} Index: types/video_youtube/video_youtube.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/types/video_youtube/Attic/video_youtube.info,v retrieving revision 1.1.2.1 diff -u -r1.1.2.1 video_youtube.info --- types/video_youtube/video_youtube.info 11 Feb 2008 06:00:23 -0000 1.1.2.1 +++ types/video_youtube/video_youtube.info 16 Dec 2008 05:24:35 -0000 @@ -1,5 +1,13 @@ ; $Id: video_youtube.info,v 1.1.2.1 2008/02/11 06:00:23 fax8 Exp $ name = Youtube Video description = Enable Youtube videos support for Video module. -dependencies = video +dependencies[] = video package = "Video" + +; Information added by drupal.org packaging script on 2008-04-09 +version = "5.x-1.x-dev" +project = "video" +datestamp = "1207700333" + + +core = 6.x \ No newline at end of file Index: types/video_youtube/video_youtube.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/types/video_youtube/Attic/video_youtube.module,v retrieving revision 1.1.2.5 diff -u -r1.1.2.5 video_youtube.module --- types/video_youtube/video_youtube.module 8 Apr 2008 19:54:48 -0000 1.1.2.5 +++ types/video_youtube/video_youtube.module 16 Dec 2008 05:24:35 -0000 @@ -11,39 +11,39 @@ // let's include apiclient logic -include_once(drupal_get_path('module', 'video') .'/includes/apiclient.inc'); +module_load_include('inc', 'video', 'includes/apiclient'); /** * Implementation of hook_menu */ -function video_youtube_menu($maycache) { +function video_youtube_menu() { $items = array(); - if($maycache) { - $items[] = array( - 'path' => 'node/add/video/youtube', - 'title' => t('Youtube'), - 'access' => user_access('create video') - ); - $items[] = array( - 'path' => 'admin/settings/video/youtube', - 'title' => t('Youtube'), - 'description' => t('Configure various settings of the video Youtube plugin.'), - 'access' => user_access('administer site configuration'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('video_youtube_admin_settings'), + $items['admin/settings/video/youtube'] = array( + 'title' => 'Youtube', + 'description' => 'Configure various settings of the video Youtube plugin.', + 'access arguments' => array('administer site configuration'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('video_youtube_admin_settings'), 'type' => MENU_NORMAL_ITEM, ); - } return $items; } +function video_youtube_theme() { + return array( + 'video_youtube_play' => array( + 'arguments' => array('node' => NULL), + ), + ); +} + /** * Setting form for video_upload */ function video_youtube_admin_settings() { - $form = array(); + $form = array(); $form['video_youtube_auto_thumbnail'] = array( '#type' => 'checkbox', @@ -56,11 +56,17 @@ '#default_value' => variable_get('video_youtube_related', false), '#description' => t('If you enable related videos the Youtube player will display a list of related videos once the video completes playing.'), ); - $form['video_youtube_api_key'] = array( + $form['video_youtube_client_id'] = array( '#type' => 'textfield', - '#title' => t('Developer ID:'), + '#title' => t('Client ID'), + '#description' => t('Insert here the Client ID. You can get one from Youtube Development pages.'), + '#default_value' =>variable_get('video_youtube_client_id', ''), + ); + $form['video_youtube_dev_key'] = array( + '#type' => 'textfield', + '#title' => t('Developer key'), '#description' => t('Insert here the developer ID. You can get one from Youtube Development pages.'), - '#default_value' =>variable_get('video_youtube_api_key', ''), + '#default_value' =>variable_get('video_youtube_dev_key', ''), ); return system_settings_form($form); } @@ -69,11 +75,14 @@ /** * Validate settings */ -function video_youtube_admin_settings_validate($form_id, &$form_values, &$form) { - if ($form_values['video_youtube_auto_thumbnail']) { // autothumbnailing is active +function video_youtube_admin_settings_validate($form, &$form_state) { + if ($form_state['values']['video_youtube_auto_thumbnail']) { // autothumbnailing is active // let's check we have a valid dev key - if($form_values['video_youtube_api_key'] == '') { - form_set_error('video_youtube_api_key', t('You have to insert a valid Youtube Developer ID for auto thumbnailing to work')); + if($form_state['values']['video_youtube_client_id'] == '') { + form_set_error('video_youtube_client_id', t('You have to insert a valid Youtube Client ID for auto thumbnailing to work')); + } + if ($form_state['values']['video_youtube_dev_key'] == '') { + form_set_error('video_youtube_dev_key', t('You have to insert a valid Youtube Developer Key for auto thumbnailing to work')); } } } @@ -111,7 +120,14 @@ /** * Implementation of hook_v_form() */ -function video_youtube_v_form(&$node, &$form) { +function video_youtube_form_video_node_form_alter(&$form, &$form_values) { + $node = $form['#node']; + if ($node->vtype != 'youtube') { + return; + } + + $form['#validate'][] = 'video_youtube_validate'; + //$form['#submit'][] = 'video_youtube_submit'; $form['video']['vidfile'] = array( '#type' => 'textfield', @@ -120,7 +136,7 @@ '#maxlength' => 700, '#required' => TRUE, '#weight' => -20, - '#description' => t('Insert the URL to the youtube video. ') . l(t('More information.'), 'video/help', NULL, NULL, 'videofile')); + '#description' => t('Insert the URL to the youtube video. ') . l(t('More information.'), 'video/help', array('fragment' => 'videofile'))); return $form; } @@ -129,29 +145,38 @@ /** * implementation of hook_v_validate */ -function video_youtube_v_validate($node) { - if(!preg_match("/^http:\/\/([a-z]{2,3}\.)?youtube\.com\/watch\?v=/", $node->vidfile)) { +function video_youtube_validate($form, &$form_state) { + if(!preg_match("/^http:\/\/([a-z]{2,3}\.)?youtube\.com\/watch\?v=/", $form_state['values']['vidfile'])) { form_set_error('vidfile', t('The Youtube Video URL field must be similar to http://youtube.com/watch?v=IICWFx7sKmw, http://www.youtube.com/watch?v=IICWFx7sKmw or http://it.youtube.com/watch?v=IICWFx7sKmw')); } else { - // we have a good URL. Let's check that the video is available on Youtube and that it is embeddable. - // the approach used here is to return errors only if Youtube explicitely says "an error has occurred" - $id = _video_youtube_get_id($node->vidfile); - $response = _video_apiclient_youtube_request('youtube.videos.get_details', array('video_id' => $id)); - //print_r($response); die; - if(isset($response['ERROR'])) { - form_set_error('vidfile', t('The Youtube Video URL validation has failed for some reason. Please check the URL and try again.
    If the error persists please contact %site_name administrators.', array('%site_name' => variable_get('site_name', 'Drupal')))); - if(isset($response['ERROR']['DESCRIPTION'][0])) { - drupal_set_message(t('The Youtube validation service reported the following error: %error', array('%error'=>$response['ERROR']['DESCRIPTION'][0])), 'error'); + if (variable_get('video_youtube_dev_key', '') != '' && + variable_get('video_youtube_client_id', '') != '') { + // we have a good URL. Let's check that the video is available on Youtube and that it is embeddable. + // the approach used here is to return errors only if Youtube explicitely says "an error has occurred" + $id = _video_youtube_get_id($form_state['values']['vidfile']); + $response = _video_apiclient_youtube_request($id); + //print_r($response); die; + if(isset($response['ERROR'])) { + form_set_error('vidfile', t('The Youtube Video URL validation has failed for some reason. Please check the URL and try again.
    If the error persists please contact %site_name administrators.', array('%site_name' => variable_get('site_name', 'Drupal')))); + if(isset($response['ERROR']['DESCRIPTION'][0])) { + drupal_set_message(t('The Youtube validation service reported the following error: %error', array('%error'=>$response['ERROR']['DESCRIPTION'][0])), 'error'); + } + } + else if(isset($response['VIDEO_DETAILS']['EMBED_STATUS'][0]) + && $response['VIDEO_DETAILS']['EMBED_STATUS'][0] != 'ok') { + // embedding has been disabled. we let the video pass but we warn the user + form_set_error('vidfile', t('The video authors have disabled embedding on Youtube. This means that this video will only be playable directly on Youtube.')); + } + else { // if youtube did not explicetely said "an error has occurred" we accept the video + ; + } + } else { + // no dev keys, so our only recourse is to see if we get a 200 OK + $result = drupal_http_request($url); + if ($result->code != 200) { + form_set_error('vidfile', t('Invalid Youtube URL')); } - } - else if(isset($response['VIDEO_DETAILS']['EMBED_STATUS'][0]) - && $response['VIDEO_DETAILS']['EMBED_STATUS'][0] != 'ok') { - // embedding has been disabled. we let the video pass but we warn the user - drupal_set_message(t('The video authors have disabled embedding on Youtube. This means that this video will only be playable directly on Youtube.')); - } - else { // if youtube did not explicetely said "an error has occurred" we accept the video - ; } } } @@ -168,17 +193,17 @@ define('VIDEO_YOUTUBE_API_INFO', 'http://youtube.com/dev'); define('VIDEO_YOUTUBE_API_APPLICATION_URL', 'http://www.youtube.com/my_profile_dev'); -define('VIDEO_YOUTUBE_REST_ENDPOINT', 'http://www.youtube.com/api2_rest'); +define('VIDEO_YOUTUBE_API_URL', 'http://gdata.youtube.com/feeds/api/videos'); /** * this is a wrapper for _video_apiclient_request_xml that includes youtube's api key */ -function _video_apiclient_youtube_request($method, $args = array(), $cacheable = TRUE) { - $args['dev_id'] = trim(variable_get('video_youtube_api_key', '')); - $args['method'] = $method; +function _video_apiclient_youtube_request($id, $args = array(), $cacheable = TRUE) { + $args['client'] = trim(variable_get('video_youtube_client_id', '')); + $args['key'] = trim(variable_get('video_youtube_dev_key', '')); - return _video_apiclient_request_xml('youtube', VIDEO_YOUTUBE_REST_ENDPOINT, $args, $cacheable); + return _video_apiclient_request_xml('youtube', VIDEO_YOUTUBE_API_URL."/$id", $args, $cacheable); } /** @@ -189,10 +214,18 @@ * a URL pointing to the thumbnail */ function _video_apiclient_youtube_get_thumbnail_url($id) { - $response = _video_apiclient_youtube_request('youtube.videos.get_details', array('video_id' => $id)); + $response = _video_apiclient_youtube_request($id); - if(isset($response['THUMBNAIL_URL'][0]) && $response['THUMBNAIL_URL'][0] != '') { - return $response['THUMBNAIL_URL'][0]; + if(isset($response['MEDIA:GROUP']['MEDIA:THUMBNAIL'])) { + $url = ''; + $size = 0; + foreach ($response['MEDIA:GROUP']['MEDIA:THUMBNAIL'] as $t) { + if ($t['WIDTH'] > $size) { + $url = $t['URL']; + $size = $t['WIDTH']; + } + } + return $url; } return false; } @@ -202,20 +235,7 @@ * Implementation of hook_v_auto_thumbnail */ function video_youtube_v_auto_thumbnail($node) { - if (count($_POST)) { - if ($_POST['vidfile'] == $node->vidfile) { - _video_image_thumbnail_debug(t('No new video to thumbnail')); - return NULL; - } - if ($_POST['tempimage']['fids']['_original']) { - _video_image_thumbnail_debug(t('Video already thumbnailed')); - return NULL; - } - $vidfile = $_POST['vidfile']; - } else { - $vidfile = $node->vidfile; - } - + $vidfile = $node->vidfile; //get the video id $id = _video_youtube_get_id($vidfile); // get thumbnail url @@ -239,9 +259,9 @@ */ function video_youtube_v_auto_playtime(&$node) { $id = _video_youtube_get_id($node->vidfile); - $response = _video_apiclient_youtube_request('youtube.videos.get_details', array('video_id' => $id)); // NOTE: here we already passed validation so we expect a valid response + $response = _video_apiclient_youtube_request($id); // NOTE: here we already passed validation so we expect a valid response - return $response['VIDEO_DETAILS']['LENGTH_SECONDS'][0]; // return the lenght in seconds + return $response['MEDIA:GROUP']['YT:DURATION'][0]['SECONDS']; // return the length in seconds } @@ -299,8 +319,8 @@ * Get the id from an URL */ function _video_youtube_get_id($url) { - $parsed_url = parse_url($url); - parse_str($parsed_url['query'], $parsed_query); + $query = parse_url($url, PHP_URL_QUERY); + parse_str($query, $parsed_query); return $parsed_query['v']; }