aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FILE_TYPES.txt16
-rw-r--r--INSTALL.txt21
-rw-r--r--README.txt2
-rw-r--r--plugins/video_customfields/video_customfields.module225
-rw-r--r--plugins/video_image/video_image.module145
-rw-r--r--plugins/video_multidownload/video_multidownload.module303
-rw-r--r--plugins/video_optmetadata/video_optmetadata.module134
-rw-r--r--plugins/video_params/video_params.module105
-rw-r--r--plugins/video_upload/video_upload.module304
-rw-r--r--video.module802
10 files changed, 1472 insertions, 585 deletions
diff --git a/FILE_TYPES.txt b/FILE_TYPES.txt
index a0892cf..07d5513 100644
--- a/FILE_TYPES.txt
+++ b/FILE_TYPES.txt
@@ -6,10 +6,10 @@ FILE TYPE INFORMATIONS
Video.module for Drupal 4.7 supports multiple video formats.
.mov, .wmv, .rm, .3gp, .mp4, .swf, .dir, .dcr
- These files type are supported out the box.
+ These files type are supported out the box.
To play these file types you need to enter in the path to the file.
If your video is on the same webserver as drupal, you can use a path relative
- to the drupal directory, like "downloads/video.mov".
+ to the drupal directory, like "downloads/video.mov".
If your video is on another server you can enter the URI to the video
like "http://www.example.com/videos/my-video.mov".
The .mp4 and .3gp extentions use the Quicktime player.
@@ -20,14 +20,14 @@ Video.module for Drupal 4.7 supports multiple video formats.
in the video creation page you will be able to specify the parameters.
YouTube.com support
- You can host videos on youtube.com and put them on your site.
- To do this, after you upload the video on youtube.com enter
- the video ID into the "Video File" field. If the URI youtube.com gives
- you for the video is "http://www.youtube.com/watch.php?v=XM4QYXPf-s8"
+ You can host videos on youtube.com and put them on your site.
+ To do this, after you upload the video on youtube.com enter
+ the video ID into the "Video File" field. If the URI youtube.com gives
+ you for the video is "http://www.youtube.com/watch.php?v=XM4QYXPf-s8"
you would enter "XM4QYXPf-s8".
Google Video support
- You can host videos on video.google.com and put them on your site.
+ You can host videos on video.google.com and put them on your site.
To do this, after you upload the video on Google video enter get the
the embed code. In this code you will find an attribute like
src="http://video.google.com/googleplayer.swf?docId=-1591729516923874694" .
@@ -37,7 +37,7 @@ Google Video support
.flv
Video.module for drupal 4.7 now support Macromedia Flash FLV Videos
using FlowPlayer ( http://flowplayer.sourceforge.net/ ).
- To use .flv files simply download Flowplayer and put the file
+ To use .flv files simply download Flowplayer and put the file
called "FlowPlayer.swf" or "Player.swf" into your Drupal folder.
Then set the Flash player file name to use on the Flash settings in video module configuration page.
diff --git a/INSTALL.txt b/INSTALL.txt
index b47cff8..e328a58 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -6,6 +6,7 @@ INSTALL INSTRUCTIONS FOR VIDEO.MODULE
- Copy video folder to modules/
- Login as site administrator
- Activate video.module as usual (administer->modules)
+- Activate optional plugin modules (called video_something)
- Set access control as you like (administer->access control)
- (optional) Activate video.module blocks (administer->blocks)
@@ -61,11 +62,11 @@ VIDEO UPDATE.PHP VERSION 2
video_bitrate int(11) default NULL,
audio_bitrate int(11) default NULL,
audio_sampling_rate int(11) default NULL,
- audio_channels enum('','stereo','mono') default NULL,
+ audio_channels enum('','stereo','mono') default NULL,
playtime_seconds int(11) default NULL,
PRIMARY KEY (nid)
) TYPE=MyISAM COMMENT='size is in bytes';
-
+
VIDEO UPDATE.PHP VERSION 3
--------------------------
@@ -81,7 +82,7 @@ VIDEO UPDATE.PHP VERSION 3
video_bitrate int(11) default NULL,
audio_bitrate int(11) default NULL,
audio_sampling_rate int(11) default NULL,
- audio_channels enum('','5.1','stereo','mono') default NULL,
+ audio_channels enum('','5.1','stereo','mono') default NULL,
playtime_seconds int(11) default NULL,
download_folder varchar(255) NULL default NULL,
disable_multidownload tinyint(1) NOT NULL default '0',
@@ -94,7 +95,7 @@ VIDEO UPDATE.PHP VERSION 3
custom_field_6 text NULL default NULL,
PRIMARY KEY (nid)
) TYPE=MyISAM COMMENT='size is in bytes';
-
+
VIDEO UPDATE.PHP VERSION 4
--------------------------
@@ -111,7 +112,7 @@ VIDEO UPDATE.PHP VERSION 4
video_bitrate int(11) unsigned default NULL,
audio_bitrate int(11) unsigned default NULL,
audio_sampling_rate int(11) unsigned default NULL,
- audio_channels enum('','5.1','stereo','mono') default NULL,
+ audio_channels enum('','5.1','stereo','mono') default NULL,
playtime_seconds int(11) unsigned default NULL,
download_folder varchar(255) NULL default NULL,
disable_multidownload tinyint(1) unsigned NOT NULL default '0',
@@ -124,7 +125,7 @@ VIDEO UPDATE.PHP VERSION 4
custom_field_6 text NULL default NULL,
PRIMARY KEY (nid)
) TYPE=MyISAM COMMENT='size is in bytes';
-
+
VIDEO UPDATE.PHP VERSION 5
--------------------------
@@ -142,7 +143,7 @@ VIDEO UPDATE.PHP VERSION 5
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,
+ 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',
@@ -155,8 +156,8 @@ VIDEO UPDATE.PHP VERSION 5
custom_field_6 text NULL default NULL,
serialized_data text NULL default NULL,
PRIMARY KEY (vid)
- ) TYPE=MyISAM COMMENT='size is in bytes';
-
+ ) TYPE=MyISAM COMMENT='size is in bytes';
+
VIDEO UPDATE.PHP VERSION 6
--------------------------
@@ -173,7 +174,7 @@ VIDEO UPDATE.PHP VERSION 6
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,
+ 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',
diff --git a/README.txt b/README.txt
index 9c490d1..8ee2642 100644
--- a/README.txt
+++ b/README.txt
@@ -16,7 +16,7 @@ For general instructions read video.module handbook:
Please submit bugs/features/support requests at:
http://drupal.org/node/add/project_issue/video
-
+
Maintainers:
Fabio Varesano: fvaresano at yahoo dot it
David Norman: deekayen (at) deekayen [dot-} net
diff --git a/plugins/video_customfields/video_customfields.module b/plugins/video_customfields/video_customfields.module
new file mode 100644
index 0000000..f6b2e50
--- /dev/null
+++ b/plugins/video_customfields/video_customfields.module
@@ -0,0 +1,225 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Enable addition of custom fileds on video nodes created by video module.
+ *
+ * @author Fabio Varesano <fvaresano at yahoo dot it>
+ */
+
+
+/**
+ * Implementation of hook_help().
+ */
+function video_customfields_help($section) {
+ switch ($section) {
+ case 'admin/modules#description':
+ return t('Enable addition of custom fileds on video nodes created by video module.');
+ }
+}
+
+
+/**
+ * Implementation of hook_perm().
+ */
+function video_customfields_perm() {
+ return array('insert custom fields');
+}
+
+
+/**
+ * Settings Hook
+ *
+ * @return
+ * string of form content or error message
+ */
+function video_customfields_settings() {
+ //Must have "administer site configuration" and "administer video" privilages.
+ if (!user_access('administer video')) {
+ drupal_access_denied();
+ }
+
+ $form['customfields'] = array(
+ '#type' => 'fieldset',
+ '#weight' => -1,
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+ '#title' => t('Custom display fields'),
+ '#description' => t('Creates custom fields. Fields only show up if you give them a name.')
+ );
+ $form['customfields']['video_customfieldtitle'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Custom field group title'),
+ '#default_value' => variable_get('video_customfieldtitle', ''),
+ '#description' => t('Title of the group of all custom fields.'));
+ $form['customfields']['video_customfield1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Custom field 1 title'),
+ '#default_value' => variable_get('video_customfield1', ''));
+ $form['customfields']['video_customfield2'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Custom field 2 title'),
+ '#default_value' => variable_get('video_customfield2', ''));
+ $form['customfields']['video_customfield3'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Custom field 3 title'),
+ '#default_value' => variable_get('video_customfield3', ''));
+ $form['customfields']['video_customfield4'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Custom field 4 title'),
+ '#default_value' => variable_get('video_customfield4', ''));
+ $form['customfields']['video_customfield5'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Custom field 5 title'),
+ '#default_value' => variable_get('video_customfield5', ''));
+ $form['customfields']['video_customfield6'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Custom field 6 title'),
+ '#default_value' => variable_get('video_customfield6', ''));
+
+
+ $options = array(1 => 'Yes', 0 => 'No');
+
+ $form['customfields']['video_customgroupcollapsed'] = array(
+ '#type' => 'radios',
+ '#title' => t('Start group initially collapsed'),
+ '#options' => $options,
+ '#default_value' => variable_get('video_customgroupcollapsed', 1),
+ '#description' => t('Should the custom fields group be initially collapsed when creating and editing video nodes?')
+ );
+ return $form;
+}
+
+
+
+/**
+ * Implementation of hook_form_alter()
+ * 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_customfileds_form_alter($form_id, &$form) {
+
+ if($form_id == 'video_node_form' && isset($form['video']) && user_access('insert custom fields')) {
+
+ $title1 = variable_get('video_customfield1', '');
+ $title2 = variable_get('video_customfield2', '');
+ $title3 = variable_get('video_customfield3', '');
+ $title4 = variable_get('video_customfield4', '');
+ $title5 = variable_get('video_customfield5', '');
+ $title6 = variable_get('video_customfield6', '');
+ //Only display the custom fields group if atleast one field has a title.
+ if ($title1 . $title2 . $title3 . $title4 . $title5 . $title6 != '') {
+ $form['customfields'] = array('#type' => 'fieldset', '#title' => variable_get('video_customfieldtitle', 'Custom Fields'), '#collapsible' => TRUE, '#collapsed' => variable_get('video_customgroupcollapsed', FALSE), '#weight' => -17);
+ //If the custom field title is not blank, then display it.
+ if ($title1 != '') {
+ $form['customfields']['custom_field_1'] = array(
+ '#type' => 'textfield', '#title' => $title1, '#maxlength' => 250, '#default_value' => $node->custom_field_1);
+ }
+ if ($title2 != '') {
+ $form['customfields']['custom_field_2'] = array(
+ '#type' => 'textfield', '#title' => $title2, '#maxlength' => 250, '#default_value' => $node->custom_field_2);
+ }
+ if ($title3 != '') {
+ $form['customfields']['custom_field_3'] = array(
+ '#type' => 'textfield', '#title' => $title3, '#maxlength' => 250, '#default_value' => $node->custom_field_3);
+ }
+ if ($title4 != '') {
+ $form['customfields']['custom_field_4'] = array(
+ '#type' => 'textfield', '#title' => $title4, '#maxlength' => 250, '#default_value' => $node->custom_field_4);
+ }
+ if ($title5 != '') {
+ $form['customfields']['custom_field_5'] = array(
+ '#type' => 'textarea', '#title' => $title5, '#rows' => 4, '#default_value' => $node->custom_field_5);
+ }
+ if ($title6 != '') {
+ $form['customfields']['custom_field_6'] = array(
+ '#type' => 'textarea', '#title' => $title6, '#rows' => 4, '#default_value' => $node->custom_field_6);
+ }
+ }
+ }
+}
+
+
+/**
+ * Implementation of hook_nodeapi()
+ */
+function video_customfields_nodeapi(&$node, $op, $teaser) {
+ if($node->type == 'video') {
+ switch ($op) {
+ case 'view':
+ //If the main node view is being displayed then add the extra video information.
+ if ($teaser == FALSE) {
+
+ if (($node->custom_field_1 . $node->custom_field_2 . $node->custom_field_3 . $node->custom_field_4 . $node->custom_field_5 . $node->custom_field_6) != '') { //Make sure there is data to display.
+ //Add the HTML formatted output of the custom fields to the bottom.
+ $node->body .= theme('video_customfields', $node);
+ }
+ }
+ break;
+ }
+ }
+}
+
+
+/**
+ * Display custom fields on the view page.
+ *
+ * @param $node
+ * object with node information
+ *
+ * @return
+ * string of content to display
+ */
+function theme_video_customfields($node) {
+ //Adds the custom fields.
+ $group_title = variable_get('video_customfieldtitle', ''); //Title of the custom fields.
+ $title1 = variable_get('video_customfield1', '');
+ $title2 = variable_get('video_customfield2', '');
+ $title3 = variable_get('video_customfield3', '');
+ $title4 = variable_get('video_customfield4', '');
+ $title5 = variable_get('video_customfield5', '');
+ $title6 = variable_get('video_customfield6', '');
+ //Run the fields through the input filter set for the node, then remove paragraphs.
+ //Removes the <p> and </p> tags from the filter pass return. This allows each field to be on one line.
+ //A better system might be to remove only the first and last <p></P> tags.
+ $field1 = str_replace(array('<p>', '</p>'), '', check_markup($node->custom_field_1, $node->format, FALSE));
+ $field2 = str_replace(array('<p>', '</p>'), '', check_markup($node->custom_field_2, $node->format, FALSE));
+ $field3 = str_replace(array('<p>', '</p>'), '', check_markup($node->custom_field_3, $node->format, FALSE));
+ $field4 = str_replace(array('<p>', '</p>'), '', check_markup($node->custom_field_4, $node->format, FALSE));
+ $field5 = str_replace(array('<p>', '</p>'), '', check_markup($node->custom_field_5, $node->format, FALSE));
+ $field6 = str_replace(array('<p>', '</p>'), '', check_markup($node->custom_field_6, $node->format, FALSE));
+
+ $output = '';
+ //Make sure all the titles are not blank, if not then display them.
+ if (($title1 . $title2 . $title3 . $title4 . $title5 . $title6) != '') {
+ $output = '<div class="videofields">'; //Enclose all output in "videofields" div class.
+ if ($group_title != '') {
+ $output .= '<div class="title"><h2>' . $group_title . '</h2></div>' . "\n";
+ }
+ if ($title1 != '' and $node->custom_field_1 != '') {
+ $fields[] = array('title' => $title1, 'body' => $field1);
+ }
+ if ($title2 != '' and $node->custom_field_2 != '') {
+ $fields[] = array('title' => $title2, 'body' => $field2);
+ }
+ if ($title3 != '' and $node->custom_field_3 != '') {
+ $fields[] = array('title' => $title3, 'body' => $field3);
+ }
+ if ($title4 != '' and $node->custom_field_4 != '') {
+ $fields[] = array('title' => $title4, 'body' => $field4);
+ }
+ if ($title5 != '' and $node->custom_field_5 != '') {
+ $fields[] = array('title' => $title5, 'body' => $field5);
+ }
+ if ($title6 != '' and $node->custom_field_6 != '') {
+ $fields[] = array('title' => $title6, 'body' => $field6);
+ }
+ $output .= theme('video_fields', $fields); //Generate all the fields HTML.
+
+ $output .= '</div><br />'; //Close the "videofields" class div.
+ }
+ return $output;
+}
+
+
diff --git a/plugins/video_image/video_image.module b/plugins/video_image/video_image.module
new file mode 100644
index 0000000..59795cf
--- /dev/null
+++ b/plugins/video_image/video_image.module
@@ -0,0 +1,145 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Enable image support for video module.
+ *
+ * @author Fabio Varesano <fvaresano at yahoo dot it>
+ */
+
+
+/**
+ * Implementation of hook_help().
+ */
+function video_image_help($section) {
+ switch ($section) {
+ case 'admin/modules#description':
+ return t('Enable thumbnails support for video module.');
+ }
+}
+
+
+/**
+ * Implementation of hook_form_alter()
+ */
+function video_image_form_alter($form_id, &$form) {
+
+ if($form_id == 'video_node_form' && isset($form['video'])) {
+
+ $form['image'] = array('#type' => 'fieldset', '#title' => t('Image thumbnails'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => -17, '#description' => t('Use this form to upload an image.'));
+
+
+ if (function_exists('_image_check_settings')) {
+ _image_check_settings();
+ $node = $form['#node'];
+ $form['#attributes'] = array("enctype" => "multipart/form-data");
+
+ if ($node->iid) {
+ $image = node_load($node->iid);
+ $form['image']['image_thumbnail'] = array('#type' => 'item', '#title' => t('Thumbnail'), '#value' => image_display($image, 'thumbnail'));
+ }
+ $value = ($node->new_image) ? '#value' : '#default_value';
+ $form['image']['iid'] = array('#type' => 'hidden' , $value => $node->iid);
+ $form['image']['image'] = array('#type' => 'file', '#title' => t('Image'));
+ $form['image']['image_title'] = array('#type' => 'textfield', '#title' => t('Image title'), '#default_value' => '');
+ }
+ }
+
+}
+
+
+/**
+ * Implementation of hook_nodeapi()
+ */
+function video_image_nodeapi(&$node, $op, $teaser) {
+ if($node->type == 'video') {
+ switch ($op) {
+ case 'submit':
+ $node->serial_data['iid'] = $node->iid;
+ break;
+ case 'prepare':
+ $image->title = $_POST['edit']['image_title'];
+ $image->uid = $node->uid;
+ $image->name = $node->name;
+ $image->created = $node->created;
+ $image->type = 'image';
+ image_prepare($image, 'image');
+ if ($image->images) {
+ node_validate($image);
+ if (!form_get_errors()) {
+ $image = node_submit($image);
+ node_save($image);
+ $node->iid = $image->nid;
+ $node->new_image = TRUE;
+ }
+ }
+ elseif ($_POST['edit']['iid']) {
+ $node->iid = $_POST['edit']['iid'];
+ }
+ break;
+
+ case 'view':
+ //print_r($node);
+ if($teaser) {
+ if ($node->serial_data['image_teaser'] || $node->serial_data['iid']) { //If we are dealing with a teaser.
+ $node->teaser = theme('video_image_teaser', $node);
+ }
+ }
+ else {
+ if ($node->serial_data['image_view'] || $node->serial_data['iid']) {
+ $node->body = theme('video_image_body', $node) . $node->body;
+ }
+ }
+ break;
+ }
+ }
+}
+
+
+/**
+ * Render the output for the node teaser.
+ *
+ * @param $node
+ * object with node information
+ *
+ * @return
+ * string of content to display
+ */
+function theme_video_image_teaser($node) {
+ if($node->serial_data['iid']) {
+ $image = node_load($node->serial_data['iid']);
+ $image = image_display($image, 'thumbnail', array('class' => 'video_image_teaser'));
+ }
+ else {
+ $image = theme('image', $node->serial_data['image_teaser'], $node->title, $node->title, array('class' => 'video_image_teaser'), FALSE);
+ }
+ $output .= l($image, "node/$node->nid", array(), NULL, NULL, FALSE, TRUE); //Create a link with an image in it.
+ $output .= $node->teaser . '<br class="video_image_clear" />';
+ return $output;
+}
+
+
+/**
+ * Generates the image HTML displayed in the Node body.
+ *
+ * @param $node
+ * object with node information
+ *
+ * @return
+ * string of content to display
+ */
+function theme_video_image_body($node) {
+ if($node->serial_data['iid']) {
+ $image = node_load($node->serial_data['iid']);
+ $image = image_display($image, 'thumbnail');
+ }
+ else { // only for backward compatibility
+ $image = theme('image', $node->serial_data['image_view'], $node->title, $node->title, array('class' => 'video_image_view'), FALSE); //Create image HTML
+ }
+ $output = l($image, "node/$node->nid/play", array('title' => t('play') . ' ' . $node->title), NULL, NULL, FALSE, TRUE); //Create link HTML with image in it.
+
+ return $output;
+}
+
+?>
diff --git a/plugins/video_multidownload/video_multidownload.module b/plugins/video_multidownload/video_multidownload.module
new file mode 100644
index 0000000..03027bf
--- /dev/null
+++ b/plugins/video_multidownload/video_multidownload.module
@@ -0,0 +1,303 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Enable multiple file download in video module.
+ *
+ * @author Fabio Varesano <fvaresano at yahoo dot it>
+ */
+
+
+/**
+ * Implementation of hook_help().
+ */
+function video_multidownload_help($section) {
+ switch ($section) {
+ case 'admin/modules#description':
+ return t('Enable multiple file download in video module.');
+ }
+}
+
+
+/**
+ * Implementation of hook_menu().
+ *
+ * @param $may_cache
+ * boolean indicating whether cacheable menu items should be returned
+ *
+ * @return
+ * array of menu information
+ */
+function video_multidownload_menu($may_cache) {
+ $items = array();
+ if ($may_cache) {
+ ; // for further uses
+ }
+ else {
+ 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) {
+ $items[] = array('path' => 'node/'.arg(1).'/multidownload',
+ 'title' => t('download other formats'),
+ 'callback' => 'video_multidownload_download',
+ 'access' => user_access('access video'),
+ 'weight' => 7,
+ 'type' => MENU_LOCAL_TASK);
+ }
+ }
+ }
+ }
+ return $items;
+}
+
+
+/**
+ * Implementation of hook_perm().
+ */
+function video_multidownload_perm() {
+ return array('create multi-file downloads');
+}
+
+
+/**
+ * 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) {
+
+ if ($form_id == 'video_node_form' && isset($form['video']) && user_access('create multi-file downloads')) {
+
+ $node = $form['#node'];
+
+ $form['multi-file'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Multiple files in download tab'),
+ '#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')
+ );
+ $form['multi-file']['disable_multidownload'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Disable multi-file downloads'),
+ '#default_value' => isset($node->disable_multidownload) ? $node->disable_multidownload : 1,
+ '#description' => t('Disables multi-file downloads for this video only.')
+ );
+ $form['multi-file']['download_folder'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Multi-file download folder'),
+ '#default_value' => $node->download_folder,
+ '#maxlength' => 250,
+ '#description' => t('Enter the folder containing your videos. It must be relative from the drupal directory. If the absolute path is "C:\inetpub\drupal\videos\projectfolder\" or "/usr/htdocs/drupal/videos/projectfolder/" then enter something like "videos/projectfolder/".'));
+ $form['multi-file']['use_play_folder'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Show files in "play" folder'),
+ '#default_value' => $node->use_play_folder,
+ '#description' => t('Display videos in the same directory as the "play" video. If folder above is entered this will be in addition.'));
+ }
+}
+
+
+
+function video_multidownload_download() {
+ if ($node = node_load(arg(1))) {
+ if (variable_get("video_multidownload", 0) == 0 or $node->disable_multidownload == 1) {
+
+ }
+ else if (arg(3) != '') { //If we are passed an encoded URL redirect to the downloader.
+ _video_download_goto(arg(3), $node->vid, TRUE);
+ }
+ else { //Multiple file downloads is turned on.
+ $download_error = FALSE; //Initialize and clear the error flag.
+ $node->file_array = array(); //Initialize the final file array.
+ global $base_url;
+ $full_download_folder = getcwd() . '/' . $node->download_folder; //Get absolute path to folder.
+ //If the download folder is set and valid scan it for files.
+ if ($node->download_folder != '' and file_exists($full_download_folder)) {
+ $scan_download_folder = _video_multidownload_scandir($full_download_folder); //Get array of file names in the directory.
+ $scan_download_folder['local_dir'] = $full_download_folder; //For getting filesize.
+ $scan_download_folder['dir_stub'] = $node->download_folder; //To put in the URL.
+ $folder_array[] = $scan_download_folder;
+
+ }
+ //If option is set to use "play" folder and it exists, scan it for files.
+ $play_dir_stub = str_replace(basename($node->vidfile), "", $node->vidfile); //Remove the filename from the play file to get directory.
+ $play_dir = getcwd() . '/' . $play_dir_stub; //Get the local directory path where the file is kept.
+ if ($node->use_play_folder == 1 and file_exists($play_dir) and $play_dir_stub != '/') { //Make sure play stub won't allow scanning base drupal directory.
+ $scan_play_folder = _video_scandir($play_dir);
+ $scan_play_folder['local_dir'] = $play_dir; //For getting filesize.
+ $scan_play_folder['dir_stub'] = $play_dir_stub; //To put in the URL.
+ $folder_array[] = $scan_play_folder;
+ }
+
+ if (count($folder_array) > 0) { //Make sure we have a folder to scan.
+ foreach ($folder_array as $dir_scan) { //Scan through one or both folders results.
+ foreach ($dir_scan as $file) { //Go through each file in the directory.
+ if (is_file($dir_scan['local_dir'] . "/" . $file)) { //Make sure it's a valid file.
+ //Checks the new file with the files already in the array to eliminate dupes.
+ $match = false;
+ foreach ($node->file_array as $file_array_file) {
+ if ($file_array_file['file'] == $file) { //If the file is already in the array.
+ $match = TRUE;
+ }
+ } //If we get here with $match still set FALSE we don't have a dupe.
+
+ $file_ext = substr($file, strrpos($file, '.') + 1); //Get the file extension.
+ $ext_array = explode(',', variable_get('video_download_ext', 'mov,wmv,avi'));
+
+ if (!$match and in_array($file_ext, $ext_array)) { //Only add file if it's not already in the array and it's extension shouldn't be hidden.
+ $file_array_size[] = filesize($dir_scan['local_dir'] . $file); //Create an array of the file sizes for sorting.
+
+ global $base_url;
+ $file_url = $base_url . '/' . $dir_scan['dir_stub'] . $file; //Generate absolute URL to video.
+ $file_url = str_replace(' ', '%20', $file_url); //Replace any spaces in filename.
+ $encoded_url = base64_encode($file_url); //Encode URL to base64 MIME value so it can be passed in URL.
+ $encoded_url = str_replace('/', '-', $encoded_url); //Replace "/" with "-" so it doesn't mess up the URL.
+
+ $node->file_array[] = array( 'file' => $file
+ , 'type' => $file_ext
+ , 'size' => filesize($dir_scan['local_dir'] . $file)
+ , 'encoded_url' => $encoded_url
+ );
+ }
+ } //Close the valid file check.
+ } //Close the directory scan.
+ } //Close scan location array.
+
+ if (count($node->file_array) > 0) { //Make sure atleast 1 file was found.
+ array_multisort($file_array_size, SORT_ASC, $node->file_array); //Sort based of file size.
+
+ }
+ else { //Else if no files were found in the directory.
+ $download_error = TRUE;
+ }
+ }
+ else { //Else if we have no valid folders to scan.
+ $download_error = TRUE;
+ }
+
+ //If there was no error send the files array to the theme function for display.
+ if($download_error == FALSE) {
+ print theme('video_multidownload_download', $node); //Print to the screen from the theme_video_download function.
+ }
+ else { //Else if there is an error download the play file.
+ _video_download_goto($node->vidfile, $node->vid);
+ }
+
+ } //Close multi-file downloads is turned on.
+ }
+}
+
+
+/**
+ * Outputs the HTML for the download page when multi-file download are turned on.
+ *
+ * @param $node
+ * object with node information
+ *
+ * @return
+ * string of content to display
+ */
+function theme_video_multidownload_download($node) {
+ $output = '';
+ //Replace some common file types with full name and links.
+ $find = array('mov', 'wmv', 'rm', 'avi', 'zip', 'divx', 'flv');
+ $replace = array('<a href="http://www.apple.com/quicktime" title="'. t('QuickTime Homepage') . '">' . t('Quicktime') . '</a>'
+ , '<a href="http://www.microsoft.com/windowsmedia" title="'. t('Windows Media Homepage') . '">' . t('Windows Media') . '</a>'
+ , '<a href="http://www.real.com" title="'. t('Real Media Homepage') . '">' . t('Real Media') . '</a>'
+ , '<a href="http://en.wikipedia.org/wiki/AVI" title="'. t('AVI Information at wikipedia.org') . '">' . t('AVI') . '</a>'
+ , '<a href="http://en.wikipedia.org/wiki/ZIP_file_format" title="'. t('ZIP Information at wikipedia.org') . '">' . t('ZIP') . '</a>'
+ , '<a href="http://www.divx.com" title="'. t('Divx Homepage') . '">' . t('DIVX') . '</a>'
+ , '<a href="http://www.macromedia.com/go/getflashplayer" title="'. t('Macromedia Flash Homepage') . '">' .t('Flash FLV') . '</a>'
+ );
+ $output .= '<br /><div class="videodownload">'; //Enclose all HTML in "videodownload" class.
+ foreach($node->file_array as $file) { //Goes through the array of video files and gets them ready for display.
+ $file_type = str_replace($find, $replace, $file['type']); //Match and replace common file types.
+ $link = l($file['file'], "node/$node->nid/multidownload/" . $file['encoded_url']); //Create link to download file.
+ $file_array_table[] = array($link, format_size($file['size']), $file_type); //Create table row.
+ }
+ $headers = array(t('File Link'), t('File Size'), t('File Type'));
+ $output .= theme_table($headers, $file_array_table); //Create the table of files.
+ $output .= '</div>'; //Close the "videodownload" class.
+
+ //Adds a breadcrumb back to view on the download page. This may not be needed but some better breadcrumbs are.
+ $breadcrumb = drupal_get_breadcrumb();
+ $breadcrumb[] = l(t('View'), "node/$node->nid");
+ drupal_set_breadcrumb($breadcrumb);
+
+ drupal_set_title(t('Downloading').' '.$node->title);
+ return theme("page", $output);
+}
+
+
+
+/**
+ * Scans a directory and returns an array of all the filenames in the directory.
+ * This function is only necessary to maintain PHP 4 support.
+ *
+ * @param $dir
+ * The directory. Can be an absolute path or relative from the current working directory.
+ *
+ * @return
+ * array of filenames.
+ */
+function _video_multidownload_scandir($dir) {
+ //Try a few different ways to open the directory.
+ if (is_dir($dir)) {
+ $dir_open = opendir($dir);
+ }
+ else if (is_dir($new_dir = getcwd() . $dir)) {
+ $dir_open = opendir($new_dir);
+ }
+ else if (is_dir($new_dir = getcwd() . '/' . $dir)) {
+ $dir_open = opendir($new_dir);
+ }
+ else { //If directory does not exist.
+ return FALSE;
+ }
+ if (!$dir_open) { //If opendir returned false then return false.
+ return FALSE;
+ }
+ //If it makes it this far $dir_open should be valid.
+ while (($dir_content = readdir($dir_open)) !== FALSE) {
+ $files[] = $dir_content;
+ }
+ return $files;
+}
+
+
+/**
+ * Forward user directly to the file for downloading
+ *
+ * @param $input_url
+ * string should be either a base64 encoded absolute URL, relative URL, or absolute URL.
+ *
+ * @param $vid
+ * integer node version ID of the node to have it's download counter updated.
+ *
+ * @param $base64_encoded
+ * boolean value determines whether the $input is base64 encoded.
+ *
+ * @return
+ * Nothing
+ */
+function _video_multidownload_download_goto($input_url, $vid, $base64_encoded) {
+ if (user_access('download video') && $base64_encoded) {
+
+ $encoded_url = str_replace('-', '/', $input_url); //Replace "-" to "/" for MIME base64.
+ $location = base64_decode($encoded_url);
+
+ if (variable_get('video_downloadcounter', 1)) {
+ db_query("UPDATE {video} SET download_counter = download_counter + 1 where vid = '%d'", $vid); //Increment download counter.
+ }
+
+ header("Location: $location"); //Redirect to the video files URL.
+ }
+ else { //If the user does not have access to download videos.
+ drupal_set_message(t('You do not have permission to download videos.'), 'error');
+ $node = node_load(array('vid' => $vid)); //Load a node with the $vid so we can get the nid.
+ drupal_goto("node/$node->nid"); //Use the nid we just loaded to go back to the node page.
+ }
+}
diff --git a/plugins/video_optmetadata/video_optmetadata.module b/plugins/video_optmetadata/video_optmetadata.module
new file mode 100644
index 0000000..f3764d2
--- /dev/null
+++ b/plugins/video_optmetadata/video_optmetadata.module
@@ -0,0 +1,134 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Enable addition of optional metadata on video nodes created by video module.
+ *
+ * @author Fabio Varesano <fvaresano at yahoo dot it>
+ */
+
+
+/**
+ * Implementation of hook_help().
+ */
+function video_optmetadata_help($section) {
+ switch ($section) {
+ 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.');
+ }
+}
+
+
+/**
+ * Implementation of hook_perm().
+ */
+function video_optmetadata_perm() {
+ return array('insert optional metadata');
+}
+
+
+
+/**
+ * Implementation of hook_form_alter()
+ * 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) {
+
+ if($form_id == 'video_node_form' && isset($form['video']) && user_access('insert optional metadata')) {
+
+ // get node object
+ $node = $form['#node'];
+ // Optional Video Metadata. We display this group expanded only if displaying of optional metadata is enabled.
+ $form['metadata'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Optional Metadata'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#weight' => -16,
+ '#description' => t('Insert here the metadata informations.')
+ );
+ $form['metadata']['video_bitrate'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Video Bitrate'),
+ '#length' => 11,
+ '#maxlength' => 11,
+ '#default_value' => $node->video_bitrate,
+ '#description' => t('Video bitrate in kbits/sec.')
+ );
+ $form['metadata']['audio_bitrate'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Audio Bitrate'),
+ '#length' => 11,
+ '#maxlength' => 11,
+ '#default_value' => $node->audio_bitrate,
+ '#description' => t('Audio bitrate in kbits/sec.')
+ );
+ $form['metadata']['audio_sampling_rate'] = array(
+ '#type' => 'select',
+ '#title' => t('Audio Sampling Rate'),
+ '#options' => array(0 => 'none', 8000 => '8 kHz', 11025 => '11 kHz', 16000 => '16 kHz', 22050 => '22 kHz', 32000 => '32 kHz', 44100 => '44.1 kHz', 48000 => '48 kHz', 96000 => '96 kHz', 192400 => '192 kHz'),
+ '#default_value' => $node->audio_sampling_rate,
+ '#description' => t('Integer value of audio sampling rate in Hz.')
+ );
+ $form['metadata']['audio_channels'] = array(
+ '#type' => 'select',
+ '#title' => t('Audio Channels'),
+ '#options' => array('' => 'none', '5.1' => t('5.1'), 'stereo' => t('Stereo'), 'mono' => t('Mono')),
+ '#default_value' => $node->audio_channels
+ );
+ // Ends Video Optional Metadata
+ }
+}
+
+
+/**
+ * Implementation of hook_nodeapi()
+ */
+function video_optmetadata_nodeapi(&$node, $op, $teaser) {
+ if($node->type == 'video') {
+ switch ($op) {
+ case 'view':
+ //Add the HTML formatted output of the optional video metadata to the bottom.
+ $node->body .= theme('video_metadata', $node);
+ break;
+ }
+ }
+}
+
+/**
+ * Display optional metadata (Video and Audio bitrate,..) on the view page.
+ *
+ * @param $node
+ * object with node information
+ *
+ * @return
+ * string of content to display
+ $node->video_bitrate, $node->audio_bitrate, $node->audio_sampling_rate, $node->audio_channels,
+ */
+function theme_video_metadata($node) {
+ //Make sure atleast one fields had data.
+ if ($node->video_bitrate != 0 or $node->audio_bitrate != 0 or $node->audio_sampling_rate != 0 or $node->audio_channels != 0) {
+ $output = "\n\n<div class=\"video_metadata\">\n";
+ $output .= ' <div class="title"><h2>'.t('Video Metadata')."</h2></div>\n";
+ if($node->video_bitrate != 0) {
+ $fields[] = array('title' => t('Video Bitrate') . ':', 'body' => $node->video_bitrate . ' ' . t('kbits/sec'));
+ }
+ if($node->audio_bitrate != 0) {
+ $fields[] = array('title' => t('Audio Bitrate') . ':', 'body' => $node->audio_bitrate . ' ' . t('kbits/sec'));
+ }
+ if($node->audio_sampling_rate != 0) {
+ $fields[] = array('title' => t('Audio Sampling Rate') . ':', 'body' => $node->audio_sampling_rate . ' ' . t('Hz'));
+ }
+ if($node->audio_channels != '') {
+ $fields[] = array('title' => t('Audio Channels') . ':', 'body' => $node->audio_channels);
+ }
+ $output .= theme('video_fields', $fields); //Generate the fields HTML.
+ $output .= '</div>'; //Closing div video_metadata
+ }
+ else { //If all the fields are blank then display nothing.
+ $output = '';
+ }
+ return $output;
+}
diff --git a/plugins/video_params/video_params.module b/plugins/video_params/video_params.module
new file mode 100644
index 0000000..46fa2e3
--- /dev/null
+++ b/plugins/video_params/video_params.module
@@ -0,0 +1,105 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Enable addition of params to object generated by video module
+ *
+ * @author Fabio Varesano <fvaresano at yahoo dot it>
+ */
+
+
+
+/**
+ * Implementation of hook_help().
+ */
+function video_params_help($section) {
+ switch ($section) {
+ 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.');
+ }
+}
+
+
+/**
+ * Implementation of hook_perm().
+ */
+function video_params_perm() {
+ return array('insert object params');
+}
+
+
+
+
+/**
+ * Implementation of hook_form_alter()
+ * 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) {
+
+ if($form_id == 'video_node_form' && isset($form['video']) && user_access('insert object params')) {
+
+ // get node object
+ $node = $form['#node'];
+
+ //We must convert the array data back to something that can go in the textarea.
+ $textarea = '';
+ if(is_array($node->serial_data['object_parameters'])) {
+ foreach ($node->serial_data['object_parameters'] as $param => $value) {
+ $textarea .= $param . '=' . $value . "\n";
+ }
+ $textarea = substr($textarea, 0, -1); //Remove the last newline "\n" from the end.
+ }
+ $form['parameters'] = array('#type' => 'fieldset', '#title' => t('HTML object parameters'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => -17);
+ $form['parameters']['object_parameters'] = array(
+ '#title' => t('Embedded object parameters'),
+ '#type' => 'textarea',
+ '#rows' => 5,
+ '#default_value' => $textarea,
+ '#description' => t('Enter the values that you would like to be embedded in &#60;param name="param_1" value="value_1" /&#62; tags. Each parameter should be on a seperate line with an equal sign between the parameter and its assigned value. Like param=value for example.')
+ );
+ }
+}
+
+
+/**
+ * Implementation of hook_nodeapi()
+ */
+function video_params_nodeapi(&$node, $op, $teaser) {
+ if($node->type == 'video') {
+ switch ($op) {
+ case 'submit':
+ //Process the data in the object_parameters textarea.
+ if ($node->object_parameters != '') { //Make sure the textarea was not empty.
+ $lines = explode("\r\n", $node->object_parameters); //Make an array of each line from the textarea.
+ foreach ($lines as $line) { //Loop through each line.
+ $array = explode('=', $line); //Break apart at the "=" sign. $line should be in format param=value
+ $node->serial_data['object_parameters'][$array[0]] = $array[1]; //Assign the "param" as the key and "value" as the value.
+ }
+ }
+ break;
+ }
+ }
+}
+
+
+/**
+ * Implementation of hook_v_get_param() - video module specific hook
+ */
+function video_params_v_get_params(&$node) {
+
+ $serial_data = $node->serial_data;
+
+ if(is_array($serial_data) && array_key_exists('object_parameters', $serial_data) && !empty($serial_data['object_parameters'])) {
+ return $serial_data['object_parameters'];
+ }
+ else {
+ return NULL;
+ }
+}
+
+
+
+
+
diff --git a/plugins/video_upload/video_upload.module b/plugins/video_upload/video_upload.module
new file mode 100644
index 0000000..22f8b1c
--- /dev/null
+++ b/plugins/video_upload/video_upload.module
@@ -0,0 +1,304 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Enable Video files uploading in video module
+ *
+ * @author Fabio Varesano <fvaresano at yahoo dot it>
+ */
+
+
+/**
+ * Implementation of hook_help().
+ */
+function video_upload_help($section) {
+ switch ($section) {
+ case 'admin/modules#description':
+ return t('Enable video files uploading in video module.');
+ }
+}
+
+
+/**
+ * Settings Hook
+ *
+ * @return
+ * string of form content or error message
+ */
+function video_upload_settings() {
+ //Must have "administer site configuration" and "administer video" privilages.
+ if (!user_access('administer video')) {
+ drupal_access_denied();
+ }
+
+ $form = array();
+ $form['video_upload_override_vidfile'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('override video file'),
+ '#description' => t('Check this if your users must only submit videos throught uploading. This disable path insertion.'),
+ '#default_value' => variable_get('video_upload_override_vidfile', false),
+ );
+ $form['video_upload_uploadable_extensions'] = array(
+ '#type' => 'textfield',
+ '#title' => t('uploadable extensions'),
+ '#description' => t('Insert here a comma separated list of extensions you want to enable for upload.'),
+ '#default_value' => variable_get('video_upload_uploadable_extensions', ''),
+ );
+
+
+ return $form;
+}
+
+
+/**
+ * Implementation of hook_perm().
+ */
+function video_upload_perm() {
+ return array('upload video files');
+}
+
+
+/**
+ * Implementation of hook_nodeapi()
+ */
+function video_upload_nodeapi(&$node, $op, $teaser) {
+ switch ($op) {
+
+ case 'load':
+ $output['video_upload_file'] = _video_upload_load($node);
+ $output['vidfile'] = file_create_url($output['video_upload_file']->filepath);
+ return $output;
+ case 'prepare':
+ _video_upload_prepare($node);
+ break;
+
+ case 'validate':
+ _video_upload_validate($node);
+ break;
+
+
+ case 'submit':
+ _video_upload_submit($node);
+ break;
+
+ case 'insert':
+ case 'update':
+ _video_upload_store($node);
+ break;
+
+ case 'delete':
+ ;
+ break;
+
+ case 'delete revision':
+ video_upload_delete_revision($node);
+ break;
+
+
+
+ }
+}
+
+
+/**
+ * Implementation of hook_form_alter()
+ * We use this to add a file upload field to the video creation form.
+ */
+function video_upload_form_alter($form_id, &$form) {
+
+ if($form_id == 'video_node_form' && isset($form['video']) && user_access('upload video files')) {
+
+ //get node object from form
+ $node = $form['#node'];
+
+ // required for upload to work
+ $form['#attributes']['enctype'] = 'multipart/form-data';
+
+ if(variable_get('video_upload_override_vidfile', false)) {
+ // remove unnecessary fields
+ $form['video']['vidfile'] = NULL;
+ $form['video']['filesize'] = NULL;
+ $form['video'] += _video_upload_form($node);
+ }
+ else {
+ // vidfile field is no more required while upload is enabled.
+ $form['video']['vidfile']['#required'] = FALSE;
+
+ $form['video']['vidfile']['#description'] .= '<p>' . t('If you want to upload a video simply ignore this field and select your video file at the "Upload video file" field.') . '</p>';
+ $form['video']['video_upload'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Upload video'),
+ '#weight' => -19,
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+
+ $form['video']['video_upload'] += _video_upload_form($node);
+ }
+ }
+}
+
+
+function _video_upload_load(&$node) {
+ 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);
+ return db_fetch_object($result);
+ }
+}
+
+
+/**
+ * Validate video file
+ */
+function _video_upload_validate(&$node) {
+ // if we override the default video module vidfile field and we don't have a file uploaded set error
+ if (variable_get('video_upload_override_vidfile', false) && !isset($node->video_upload_file) && !isset($_SESSION['video_upload_file'])) {
+ form_set_error('video_upload_file', t('A file must be provided.'));
+ return;
+ }
+}
+
+
+function _video_upload_submit(&$node) {
+ ;
+}
+
+
+function _video_upload_prepare(&$node) {
+ // clear video file informations
+ if(count($_POST) == 0) {
+ if (!empty($_SESSION['video_upload_file'])) {
+ file_delete($_SESSION['video_upload_file']->filepath);
+ }
+ unset($_SESSION['video_upload_file']);
+ }
+
+
+ if ($file = file_check_upload('video_upload_file')) {
+ $temppath = file_directory_temp() . '/video/';
+ file_check_directory($temppath, TRUE);
+ $node->video_upload_file = file_save_upload($file, $temppath .'/'. $file->filename, FILE_EXISTS_REPLACE);
+ $node->video_upload_file->newfile = TRUE;
+
+ $_SESSION['video_upload_file'] = $node->video_upload_file;
+ }
+ else if (!empty($_SESSION['video_upload_file'])) {
+ $node->video_upload_file = $_SESSION['video_upload_file'];
+ } else {
+ $_SESSION['video_upload_file'] = $node->video_upload_file;
+ }
+}
+
+
+function _video_upload_store(&$node) {
+ if(!empty($_SESSION['video_upload_file'])) {
+ $file = $_SESSION['video_upload_file'];
+ $dest_dir = variable_get('video_upload_default_path', 'videos') .'/';
+ if ($file = file_save_upload($file, $dest_dir . $file->filename)) {
+ $file = $_SESSION['video_upload_file'];
+ $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, $node->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, $node->vid, $file->list, $file->description);
+ unset($_SESSION['video_upload_file']);
+ }
+
+ }
+}
+
+
+/**
+* Create video upload specific form fields
+*/
+function _video_upload_form($node) {
+ _video_upload_check_settings();
+
+ $form = array();
+
+ $form['video_upload_file'] = array(
+ '#type' => 'file',
+ '#title' => t('Upload video file'),
+ '#size' => 40,
+ '#weight' => -19,
+ '#description' => t('The uploaded file will be used as video file for this node.<br /><b>NOTE:</b> The max upload size is') . ' ' . format_size(_video_upload_get_max_upload_size()) . '.',
+ );
+
+ if (isset($node->video_upload_file)) {
+ $form['video_upload_file']['#prefix'] = theme('video_upload_file_info_form', $node);
+ $form['video_upload_file']['#title'] = t('Replace with');
+ }
+
+ return $form;
+}
+
+
+/**
+ * Display informations about already uploaded file
+ */
+function theme_video_upload_file_info_form(&$node) {
+ $output = '<p>' . t('A video file has been already uploaded.') . '</p>';
+
+ // create array containing uploaded file informations
+ $items = array(
+ '<b>'. t('file name') .':</b> ' . $node->video_upload_file->filename,
+ '<b>'. t('file path') .':</b> ' . $node->video_upload_file->filepath,
+ '<b>'. t('file size') .':</b> ' . format_size($node->video_upload_file->filesize),
+ '<b>'. t('file mime') .':</b> ' . $node->video_upload_file->filemime,
+ );
+
+ // create information list
+ $output .= theme_item_list($items, t('uploaded video informations:'));
+
+ return $output;
+}
+
+
+/**
+ * Check PHP's post_max_size and upload_max_filesize settings and determine
+ * the maximum size of a file upload.
+ * (code from audio.module)
+ * @return an integer number of bytes
+ */
+function _video_upload_get_max_upload_size() {
+ $limits = array();
+ foreach (array('upload_max_filesize', 'post_max_size') as $setting) {
+ // the post_max_size and upload_max_filesize settings could be a string
+ // ('2m', '1G') or an integer (2097152 or 1073741824).
+ $val = ini_get($setting);
+ if (!is_numeric($val)) {
+ // separate the numeric and alpha parts, then get to multiplying
+ $val = trim($val);
+ $last = strtolower($val{strlen($val)-1});
+ switch($last) {
+ case 'g':
+ $val *= 1024;
+ case 'm':
+ $val *= 1024;
+ case 'k':
+ $val *= 1024;
+ }
+ }
+ $limits[] = $val;
+ }
+ // the smallest value will be the limiting factor so retun it.
+ return min($limits);
+}
+
+
+/**
+ * Verify the video_upload module settings.
+ */
+function _video_upload_check_settings() {
+ // File paths
+ $video_path = file_create_path(variable_get('video_upload_default_path', 'videos'));
+ $temp_path = rtrim($video_path, '/') . '/temp';
+
+ if (!file_check_directory($video_path, FILE_CREATE_DIRECTORY, 'video_upload_default_path')) {
+ return false;
+ }
+ if (!file_check_directory($temp_path, FILE_CREATE_DIRECTORY, 'video_upload_default_path')) {
+ return false;
+ }
+
+ return true;
+}
diff --git a/video.module b/video.module
index c85ad1e..276f4ab 100644
--- a/video.module
+++ b/video.module
@@ -41,14 +41,14 @@ function video_help($section = 'admin/help#video') {
case 'admin/modules#description':
return t('Allows video nodes.');
case 'node/add#video':
- return t('Allows you to insert videos as nodes');
+ return t('Allows you to insert videos as nodes.');
case 'video/help':
$help = '';
$help .= '<a name="videofile"></a><h3>' . t('Video File Field') . '</h3>';
$help .= '<p>' . t('This is the field where you enter the video file information. The Video module currently supports these file types:') . '</p>';
$help .= '<ul><li><b>' . t('.mov, .wmv, .rm, .flv, .swf, .dir, .dcr') . '</b><ul><li>' . t('To play these file types you need to enter in the path to the file. If your video is on the same webserver as drupal, you can use a path relative to the drupal directory, like "downloads/video.mov". If your video is on another server you can enter the URI to the video like "http://www.example.com/videos/my-video.mov".') . '</li></ul><br /></li>';
$help .= '<li><b><a href="http://www.youtube.com">' . t('YouTube.com support') . '</a></b><ul><li>' . t('You can host videos on youtube.com and put them on your site. To do this, after you upload the video on youtube.com enter the video ID into the "Video File" field. If the URI youtube.com gives you for the video is "http://www.youtube.com/watch.php?v=XM4QYXPf-s8" you would enter "XM4QYXPf-s8".') . '</li></ul><br /></li>';
- $help .= '<li><b><a href="http://video.google.com">' . t('Google Video support') . '</a></b><ul><li>' . t('You can host videos on video.google.com and put them on your site.
+ $help .= '<li><b><a href="http://video.google.com">' . t('Google Video support') . '</a></b><ul><li>' . t('You can host videos on video.google.com and put them on your site.
To do this, after you upload the video on Google video enter get the
the embed code. In this code you will find an attribute like
src="http://video.google.com/googleplayer.swf?docId=-1591729516923874694" .
@@ -104,7 +104,7 @@ function video_menu($may_cache) {
'type' => MENU_LOCAL_TASK);
}
//If the video is of type youtube and multi-file downloads aren't turned on don't show the download tab.
- if (variable_get('video_displaydownloadmenutab', 1) == 1 and (_video_get_filetype(($node->vidfile) != 'youtube' and _video_get_filetype($node->vidfile) != 'googlevideo') or $node->disable_multidownload == 0)) {
+ if (variable_get('video_displaydownloadmenutab', 1) == 1 and (_video_get_filetype($node->vidfile) != 'youtube' and _video_get_filetype($node->vidfile) != 'googlevideo')) {
$items[] = array('path' => 'node/'.arg(1).'/download',
'title' => t('download'),
'callback' => 'video_download',
@@ -164,8 +164,9 @@ function video_link($type, $node = NULL) {
}
$link = substr($link, 0, -3); //Trim the last " | " off.
+ return array($link);
}
- return array($link);
+ return array();
}
/**
@@ -218,9 +219,6 @@ function video_feed() {
*/
function video_perm() {
$array = array('create video', 'access video', 'administer video', 'download video', 'view play counter', 'view download counter');
- if (variable_get('video_multidownload', '0')) { //Only display permission if turned on in settings.
- $array[] = 'create multi-file downloads';
- }
return $array;
}
@@ -312,63 +310,6 @@ function video_settings() {
'#default_value' => variable_get('video_download_ext', 'mov,wmv,rm,flv,avi,divx,mpg,mpeg,mp4,zip'),
'#description' => t('The extensions of files to list from the multi-file download folder on the download page. Extensions should be comma seperated with no spaces, for example (mov,wmv,rm).'));
- $form['video_display_metadata'] = array(
- '#type' => 'radios',
- '#title' => t('Display Optional Metadata'),
- '#options' => $options,
- '#default_value' => variable_get('video_display_metadata', 0),
- '#description' => t('Allows displaying a list of videos metadata: Video bitrate, Audio bitrate, Audio Sampling Rate and Audio Channels.'));
-
- $form['video_object_parameters'] = array(
- '#type' => 'radios',
- '#title' => t('Allow adding of parameters to object HTML'),
- '#options' => $options,
- '#default_value' => variable_get('video_object_parameters', 0),
- '#description' => t('Turns on a text box that takes parameter=value pairs and puts them into parameter tags in the embedded object tag for each video.'));
-
- $form['video_image'] = array(
- '#type' => 'radios',
- '#title' => t('Allow adding image to nodes and node teasers'),
- '#options' => $options,
- '#default_value' => variable_get('video_image', 0),
- '#description' => t('This will allow users to put images in the node teaser and node view.'));
-
- $form['customfields'] = array('#type' => 'fieldset', '#weight' => -1, '#collapsible' => TRUE, '#collapsed' => TRUE, '#title' => t('Custom display fields'), '#description' => t('Creates custom fields. Fields only show up if you give them a name.'));
- $form['customfields']['video_customfieldtitle'] = array(
- '#type' => 'textfield',
- '#title' => t('Custom field group title'),
- '#default_value' => variable_get('video_customfieldtitle', ''),
- '#description' => t('Title of the group of all custom fields.'));
- $form['customfields']['video_customfield1'] = array(
- '#type' => 'textfield',
- '#title' => t('Custom field 1 title'),
- '#default_value' => variable_get('video_customfield1', ''));
- $form['customfields']['video_customfield2'] = array(
- '#type' => 'textfield',
- '#title' => t('Custom field 2 title'),
- '#default_value' => variable_get('video_customfield2', ''));
- $form['customfields']['video_customfield3'] = array(
- '#type' => 'textfield',
- '#title' => t('Custom field 3 title'),
- '#default_value' => variable_get('video_customfield3', ''));
- $form['customfields']['video_customfield4'] = array(
- '#type' => 'textfield',
- '#title' => t('Custom field 4 title'),
- '#default_value' => variable_get('video_customfield4', ''));
- $form['customfields']['video_customfield5'] = array(
- '#type' => 'textfield',
- '#title' => t('Custom field 5 title'),
- '#default_value' => variable_get('video_customfield5', ''));
- $form['customfields']['video_customfield6'] = array(
- '#type' => 'textfield',
- '#title' => t('Custom field 6 title'),
- '#default_value' => variable_get('video_customfield6', ''));
- $form['customfields']['video_customgroupcollapsed'] = array(
- '#type' => 'radios',
- '#title' => t('Start group initially collapsed'),
- '#options' => $options,
- '#default_value' => variable_get('video_customgroupcollapsed', 1),
- '#description' => t('Should the custom fields group be initially collapsed when creating and editing video nodes?'));
return $form;
}
@@ -443,7 +384,7 @@ function video_form($node) {
'#default_value' => $node->title, '#weight' => -20);
$form['body_filter']['body'] = array('#type' => 'textarea',
'#title' => t('Body'), '#default_value' => $node->body,
- '#required' => TRUE, '#weight' => -15);
+ '#required' => FALSE, '#weight' => -15);
$form['body_filter']['filter'] = filter_form($node->format);
$form['log'] = array('#type' => 'fieldset', '#title' => t('Log message'),
'#collapsible' => TRUE, '#collapsed' => TRUE);
@@ -459,6 +400,7 @@ function video_form($node) {
'#default_value' => $node->vidfile,
'#maxlength' => 700,
'#required' => TRUE,
+ '#weight' => -20,
'#description' => t('Put here the video file path. You can use either relative to the drupal root directory (something/video.mov) or absolute (http://www.example.com/videos/videos.mov). Windows Media currently requires a fully qualified URL to function. Flash movies may not play with spaces in the path or filename. To add youtube.com videos enter the video ID. If your video was at (http://www.youtube.com/watch.php?v=aBM4QYXPf-s) you would enter (aBM4QYXPf-s). To add Google videos you will need the docId values available on the embed code google provide with "google:" as heading. ') . l(t('More information.'), 'video/help', NULL, NULL, 'videofile'));
$form['video']['videox'] = array(
'#type' => 'textfield',
@@ -517,128 +459,10 @@ function video_form($node) {
'#default_value' => $playtime['seconds'],
'#description' => t('Integer of seconds.'));
- if (variable_get('video_multidownload', 0) and user_access('create multi-file downloads')) { //If multi-file downloading is turned on display settings group.
- $form['multi-file'] = array('#type' => 'fieldset', '#title' => t('Multiple files in download tab'), '#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'));
- $form['multi-file']['disable_multidownload'] = array(
- '#type' => 'checkbox',
- '#title' => t('Disable multi-file downloads'),
- '#default_value' => isset($node->disable_multidownload) ? $node->disable_multidownload : 1,
- '#description' => t('Disables multi-file downloads for this video only.'));
- $form['multi-file']['download_folder'] = array(
- '#type' => 'textfield',
- '#title' => t('Multi-file download folder'),
- '#default_value' => $node->download_folder,
- '#maxlength' => 250,
- '#description' => t('Enter the folder containing your videos. It must be relative from the drupal directory. If the absolute path is "C:\inetpub\drupal\videos\projectfolder\" or "/usr/htdocs/drupal/videos/projectfolder/" then enter something like "videos/projectfolder/".'));
- $form['multi-file']['use_play_folder'] = array(
- '#type' => 'checkbox',
- '#title' => t('Show files in "play" folder'),
- '#default_value' => $node->use_play_folder,
- '#description' => t('Display videos in the same directory as the "play" video. If folder above is entered this will be in addition.'));
- }
-
- if (variable_get('video_object_parameters', 0)) { //Only display the option if it is turned on in settings.
- //We must convert the array data back to something that can go in the textarea.
- $textarea = '';
- if(is_array($node->serial_data['object_parameters'])) {
- foreach ($node->serial_data['object_parameters'] as $param => $value) {
- $textarea .= $param . '=' . $value . "\n";
- }
- $textarea = substr($textarea, 0, -1); //Remove the last newline "\n" from the end.
- }
- $form['parameters'] = array('#type' => 'fieldset', '#title' => t('HTML object parameters'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => -17);
- $form['parameters']['object_parameters'] = array(
- '#title' => t('Embedded object parameters'),
- '#type' => 'textarea',
- '#rows' => 5,
- '#default_value' => $textarea,
- '#description' => t('Enter the values that you would like to be embedded in &#60;param name="param_1" value="value_1" /&#62; tags. Each parameter should be on a seperate line with an equal sign between the parameter and its assigned value. Like param=value for example.'));
- }
-
- if (variable_get('video_image', 0)) { //Only display the option if it is turned on in settings.
- $form['image'] = array('#type' => 'fieldset', '#title' => t('Image thumbnails'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => -17, '#description' => t('Please enter full URL value to the image.'));
- $form['image']['image_teaser'] = array(
- '#title' => t('Image thumbnail for node teaser'),
- '#type' => 'textfield',
- '#maxlength' => 255,
- '#default_value' => $node->serial_data['image_teaser'],
- '#description' => t('This image will be displayed in the node teaser.'));
- $form['image']['image_view'] = array(
- '#title' => t('Image for node view'),
- '#type' => 'textfield',
- '#maxlength' => 255,
- '#default_value' => $node->serial_data['image_view'],
- '#description' => t('This image will be displayed on the full node view.'));
- }
-
- $title1 = variable_get('video_customfield1', '');
- $title2 = variable_get('video_customfield2', '');
- $title3 = variable_get('video_customfield3', '');
- $title4 = variable_get('video_customfield4', '');
- $title5 = variable_get('video_customfield5', '');
- $title6 = variable_get('video_customfield6', '');
- //Only display the custom fields group if atleast one field has a title.
- if ($title1 . $title2 . $title3 . $title4 . $title5 . $title6 != '') {
- $form['customfields'] = array('#type' => 'fieldset', '#title' => variable_get('video_customfieldtitle', 'Custom Fields'), '#collapsible' => TRUE, '#collapsed' => variable_get('video_customgroupcollapsed', FALSE), '#weight' => -17);
- //If the custom field title is not blank, then display it.
- if ($title1 != '') {
- $form['customfields']['custom_field_1'] = array(
- '#type' => 'textfield', '#title' => $title1, '#maxlength' => 250, '#default_value' => $node->custom_field_1);
- }
- if ($title2 != '') {
- $form['customfields']['custom_field_2'] = array(
- '#type' => 'textfield', '#title' => $title2, '#maxlength' => 250, '#default_value' => $node->custom_field_2);
- }
- if ($title3 != '') {
- $form['customfields']['custom_field_3'] = array(
- '#type' => 'textfield', '#title' => $title3, '#maxlength' => 250, '#default_value' => $node->custom_field_3);
- }
- if ($title4 != '') {
- $form['customfields']['custom_field_4'] = array(
- '#type' => 'textfield', '#title' => $title4, '#maxlength' => 250, '#default_value' => $node->custom_field_4);
- }
- if ($title5 != '') {
- $form['customfields']['custom_field_5'] = array(
- '#type' => 'textarea', '#title' => $title5, '#rows' => 4, '#default_value' => $node->custom_field_5);
- }
- if ($title6 != '') {
- $form['customfields']['custom_field_6'] = array(
- '#type' => 'textarea', '#title' => $title6, '#rows' => 4, '#default_value' => $node->custom_field_6);
- }
- }
-
- // Optional Video Metadata. We display this group expanded only if displaying of optional metadata is enabled.
- $form['metadata'] = array('#type' => 'fieldset', '#title' => t('Optional Metadata'), '#collapsible' => TRUE, '#collapsed' => !variable_get('video_display_metadata', FALSE), '#weight' => -16, '#description' => t('Metadata entered here will be displayed only if administrator enables displaying on the '.l(t('administration page'),'admin/settings/video', array('title'=>t('administration page'))).'.'));
- $form['metadata']['video_bitrate'] = array(
- '#type' => 'textfield',
- '#title' => t('Video Bitrate'),
- '#length' => 11,
- '#maxlength' => 11,
- '#default_value' => $node->video_bitrate,
- '#description' => t('Video bitrate in kbits/sec.'));
- $form['metadata']['audio_bitrate'] = array(
- '#type' => 'textfield',
- '#title' => t('Audio Bitrate'),
- '#length' => 11,
- '#maxlength' => 11,
- '#default_value' => $node->audio_bitrate,
- '#description' => t('Audio bitrate in kbits/sec.'));
- $form['metadata']['audio_sampling_rate'] = array(
- '#type' => 'select',
- '#title' => t('Audio Sampling Rate'),
- '#options' => array(0 => 'none', 8000 => '8 kHz', 11025 => '11 kHz', 16000 => '16 kHz', 22050 => '22 kHz', 32000 => '32 kHz', 44100 => '44.1 kHz', 48000 => '48 kHz', 96000 => '96 kHz', 192400 => '192 kHz'),
- '#default_value' => $node->audio_sampling_rate,
- '#description' => t('Integer value of audio sampling rate in Hz.'));
- $form['metadata']['audio_channels'] = array(
- '#type' => 'select',
- '#title' => t('Audio Channels'),
- '#options' => array('' => 'none', '5.1' => t('5.1'), 'stereo' => t('Stereo'), 'mono' => t('Mono')),
- '#default_value' => $node->audio_channels);
- // Ends Video Optional Metadata
-
return $form;
}
+
/**
* Hook: Create video record in video table
*
@@ -647,10 +471,14 @@ function video_form($node) {
*/
function video_insert($node) {
_video_db_preprocess($node); //Make changes to data before inserting into DB.
+
+ $node->serialized_data = serialize($node->serial_data); //Serialize the data for insertion into the database.
+
return db_query("INSERT INTO {video} (vid, nid, 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', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%d', '%d', '%s', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
$node->vid, $node->nid, $node->vidfile, $node->size, $node->videox, $node->videoy, $node->video_bitrate, $node->audio_bitrate, $node->audio_sampling_rate, $node->audio_channels, $node->playtime_seconds, $node->disable_multidownload, $node->download_folder, $node->use_play_folder, $node->custom_field_1, $node->custom_field_2, $node->custom_field_3, $node->custom_field_4, $node->custom_field_5, $node->custom_field_6, $node->serialized_data);
}
+
/**
* Hook
*
@@ -663,6 +491,9 @@ function video_update($node) {
return video_insert($node);
}
else {
+
+ $node->serialized_data = serialize($node->serial_data); //Serialize the data for insertion into the database.
+
return db_query("UPDATE {video} SET vidfile='%s', size='%d', videox='%d', videoy='%d', video_bitrate='%d', audio_bitrate='%d', audio_sampling_rate='%d', audio_channels='%s', playtime_seconds='%d', disable_multidownload='%d', download_folder='%s', use_play_folder='%d', custom_field_1='%s', custom_field_2='%s', custom_field_3='%s', custom_field_4='%s', custom_field_5='%s', custom_field_6='%s', serialized_data='%s' WHERE vid = '%d'",
$node->vidfile, $node->size, $node->videox, $node->videoy, $node->video_bitrate, $node->audio_bitrate, $node->audio_sampling_rate, $node->audio_channels, $node->playtime_seconds, $node->disable_multidownload, $node->download_folder, $node->use_play_folder, $node->custom_field_1, $node->custom_field_2, $node->custom_field_3, $node->custom_field_4, $node->custom_field_5, $node->custom_field_6, $node->serialized_data, $node->vid);
}
@@ -678,7 +509,7 @@ function video_update($node) {
* nothing
*/
function _video_db_preprocess(&$node) {
- $serial_data = array();
+ //$node->serial_data = array();
//Calculate the time in seconds.
$node->playtime_seconds += ($node->playtime_hours * 3600) + ($node->playtime_minutes * 60);
@@ -698,21 +529,6 @@ function _video_db_preprocess(&$node) {
if (!user_access('create multi-file downloads')) {
$node->disable_multidownload = 1;
}
-
- //Stick the data from the image fields into the array.
- $serial_data['image_teaser'] = $node->image_teaser;
- $serial_data['image_view'] = $node->image_view;
-
- //Process the data in the object_parameters textarea.
- if ($node->object_parameters != '') { //Make sure the textarea was not empty.
- $lines = explode("\r\n", $node->object_parameters); //Make an array of each line from the textarea.
- foreach ($lines as $line) { //Loop through each line.
- $array = explode('=', $line); //Break apart at the "=" sign. $line should be in format param=value
- $serial_data['object_parameters'][$array[0]] = $array[1]; //Assign the "param" as the key and "value" as the value.
- }
- }
-
- $node->serialized_data = serialize($serial_data); //Serialize the data for insertion into the database.
}
/**
@@ -734,10 +550,7 @@ function video_delete($node) {
*/
function video_validate($node) {
if (isset($node->vidfile)) {
- if ($node->vidfile == '') {
- form_set_error('vidfile', t('You have to insert a valid file path for this video'));
- }
- else {
+ if ($node->vidfile != '') {
//let's see if we have it yet
$result = db_query("SELECT * from {video} WHERE vidfile = '%s' and nid <> '%d'", $node->vidfile, $node->nid);
if (db_num_rows($result) > 0) {
@@ -776,14 +589,18 @@ function video_validate($node) {
}
/**
- * Hook
+ * Implementation of hook_load()
*
* @param $node
* object or boolean FALSE on error
*/
function video_load($node) {
if (is_numeric($node->vid)) {
- return db_fetch_object(db_query("SELECT * FROM {video} WHERE vid = '%d'", $node->vid));
+ $node = db_fetch_object(db_query("SELECT * FROM {video} WHERE vid = '%d'", $node->vid));
+
+ // load serialized data for plug-ins
+ $node->serial_data = unserialize($node->serialized_data);
+ return $node;
}
else {
return false;
@@ -799,24 +616,10 @@ function video_load($node) {
*/
function video_view(&$node, $teaser = FALSE, $page = FALSE) {
$node = node_prepare($node, $teaser); //Run the body through the standard filters.
- $node->serial_data = unserialize($node->serialized_data);
- //If the main node view is being displayed then add the extra video information.
- if ($teaser == FALSE) {
- if ($node->serial_data['image_view'] and variable_get('video_image', 0)) {
- $node->body = theme('video_image_body', $node) . $node->body;
- }
- if (($node->custom_field_1 . $node->custom_field_2 . $node->custom_field_3 . $node->custom_field_4 . $node->custom_field_5 . $node->custom_field_6) != '') { //Make sure there is data to display.
- //Add the HTML formatted output of the custom fields to the bottom.
- $node->body .= theme('video_customfields', $node);
- }
- if(variable_get('video_display_metadata', FALSE)) {
- //Add the HTML formatted output of the optional video metadata to the bottom.
- $node->body .= theme('video_metadata', $node);
- }
- }
- else if ($node->serial_data['image_teaser'] and variable_get('video_image', 0)) { //If we are dealing with a teaser.
- $node->teaser = theme('video_image_teaser', $node);
- }
+
+ // include the video css file
+ theme_add_style(drupal_get_path('module', 'video').'/video.css');
+
}
/********************************************************************
@@ -947,100 +750,17 @@ function video_block_list($delta = 0) {
****************************************************/
/**
- * Either redirects to download the video file.
- * Or displays a list of files to download.
+ * Redirects to download the video file.
*/
function video_download() {
if ($node = node_load(arg(1))) {
- if (variable_get("video_multidownload", 0) == 0 or $node->disable_multidownload == 1) {
- if (_video_get_filetype($node->vidfile) != 'youtube' and _video_get_filetype($node->vidfile) != 'googlevideo') { //Make sure the video type is not youtube before downloading.
- _video_download_goto($node->vidfile, $node->vid);
- }
- else { //If video is type youtube then it can't be downloaded.
- drupal_set_message(t('There are no files to download for this video.'), 'error');
- print theme('page', '');
- }
+ if (_video_get_filetype($node->vidfile) != 'youtube' and _video_get_filetype($node->vidfile) != 'googlevideo') { //Make sure the video type is not youtube before downloading.
+ _video_download_goto($node->vidfile, $node->vid);
}
- else if (arg(3) != '') { //If we are passed an encoded URL redirect to the downloader.
- _video_download_goto(arg(3), $node->vid, TRUE);
+ else { //If video is type youtube then it can't be downloaded.
+ drupal_set_message(t('There are no files to download for this video.'), 'error');
+ print theme('page', '');
}
- else { //Multiple file downloads is turned on.
- $download_error = FALSE; //Initialize and clear the error flag.
- $node->file_array = array(); //Initialize the final file array.
- global $base_url;
- $full_download_folder = getcwd() . '/' . $node->download_folder; //Get absolute path to folder.
- //If the download folder is set and valid scan it for files.
- if ($node->download_folder != '' and file_exists($full_download_folder)) {
- $scan_download_folder = _video_scandir($full_download_folder); //Get array of file names in the directory.
- $scan_download_folder['local_dir'] = $full_download_folder; //For getting filesize.
- $scan_download_folder['dir_stub'] = $node->download_folder; //To put in the URL.
- $folder_array[] = $scan_download_folder;
- }
- //If option is set to use "play" folder and it exists, scan it for files.
- $play_dir_stub = str_replace(basename($node->vidfile), "", $node->vidfile); //Remove the filename from the play file to get directory.
- $play_dir = getcwd() . '/' . $play_dir_stub; //Get the local directory path where the file is kept.
- if ($node->use_play_folder == 1 and file_exists($play_dir) and $play_dir_stub != '/') { //Make sure play stub won't allow scanning base drupal directory.
- $scan_play_folder = _video_scandir($play_dir);
- $scan_play_folder['local_dir'] = $play_dir; //For getting filesize.
- $scan_play_folder['dir_stub'] = $play_dir_stub; //To put in the URL.
- $folder_array[] = $scan_play_folder;
- }
-
- if (count($folder_array) > 0) { //Make sure we have a folder to scan.
- foreach ($folder_array as $dir_scan) { //Scan through one or both folders results.
- foreach ($dir_scan as $file) { //Go through each file in the directory.
- if (is_file($dir_scan['local_dir'] . "/" . $file)) { //Make sure it's a valid file.
- //Checks the new file with the files already in the array to eliminate dupes.
- $match = false;
- foreach ($node->file_array as $file_array_file) {
- if ($file_array_file['file'] == $file) { //If the file is already in the array.
- $match = TRUE;
- }
- } //If we get here with $match still set FALSE we don't have a dupe.
-
- $file_ext = substr($file, strrpos($file, '.') + 1); //Get the file extension.
- $ext_array = explode(',', variable_get('video_download_ext', 'mov,wmv,avi'));
-
- if (!$match and in_array($file_ext, $ext_array)) { //Only add file if it's not already in the array and it's extension shouldn't be hidden.
- $file_array_size[] = filesize($dir_scan['local_dir'] . $file); //Create an array of the file sizes for sorting.
-
- global $base_url;
- $file_url = $base_url . '/' . $dir_scan['dir_stub'] . $file; //Generate absolute URL to video.
- $file_url = str_replace(' ', '%20', $file_url); //Replace any spaces in filename.
- $encoded_url = base64_encode($file_url); //Encode URL to base64 MIME value so it can be passed in URL.
- $encoded_url = str_replace('/', '-', $encoded_url); //Replace "/" with "-" so it doesn't mess up the URL.
-
- $node->file_array[] = array( 'file' => $file
- , 'type' => $file_ext
- , 'size' => filesize($dir_scan['local_dir'] . $file)
- , 'encoded_url' => $encoded_url
- );
- }
- } //Close the valid file check.
- } //Close the directory scan.
- } //Close scan location array.
-
- if (count($node->file_array) > 0) { //Make sure atleast 1 file was found.
- array_multisort($file_array_size, SORT_ASC, $node->file_array); //Sort based of file size.
-
- }
- else { //Else if no files were found in the directory.
- $download_error = TRUE;
- }
- }
- else { //Else if we have no valid folders to scan.
- $download_error = TRUE;
- }
-
- //If there was no error send the files array to the theme function for display.
- if($download_error == FALSE){
- print theme('video_download', $node); //Print to the screen from the theme_video_download function.
- }
- else { //Else if there is an error download the play file.
- _video_download_goto($node->vidfile, $node->vid);
- }
-
- } //Close multi-file downloads is turned on.
}
else {
drupal_not_found();
@@ -1052,11 +772,14 @@ function video_download() {
*/
function video_play() {
if ($node = node_load(arg(1))) {
+ // include video.js file for Internet Explorer fixes
+ theme('video_get_script');
drupal_set_title(t('Playing') . ' ' . $node->title);
switch (_video_get_filetype($node->vidfile)) {
case 'mov':
case 'mp4':
case '3gp':
+ case '3g2':
print theme('video_play_quicktime', $node);
break;
case 'rm':
@@ -1100,7 +823,7 @@ function video_play() {
*********************************************************************/
/**
- * Play videos from in Flash video format
+ * Play videos from in FLV Flash video format
*
* @param $node
* object with node information
@@ -1112,13 +835,30 @@ function theme_video_play_flash($node) {
$loader_location = variable_get('video_flvplayerloader', 'Player.swf');
$file = basename($node->vidfile);
$url = _video_get_fileurl($node->vidfile);
- $output = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'.$node->videox.'" height="'.$node->videoy.'" id="Player">
+
+
+ // this will be executed by not Internet Explorer browsers
+ $output = '<!--[if !IE]> <-->
+<object type="application/x-shockwave-flash" width="'. $node->videox .'" height="'. $node->videoy .'"
+data="'. $loader_location .'">
+<!--> <![endif]-->' . "\n";
+
+ // this will be executed by Internet Explorer
+ $output .= '<!--[if IE]>
+<object type="application/x-shockwave-flash" width="'. $node->videox .'" height="'. $node->videoy .'"
+classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
+codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
+<![endif]-->' . "\n";
+
+ // params will be passed to both IE or not IE browsers
+ $output .= '<param name="movie" value="'.$loader_location.'" />
<param name="allowScriptAccess" value="sameDomain" />
- <param name="movie" value="'.$loader_location.'" />
<param name="quality" value="high" />
- <param name="FlashVars" value="baseURL='. $url .'&videoFile='. $file .'&autoPlay=true&bufferLength=5" />
- <embed src="'.$loader_location.'" flashvars="baseURL='. $url .'&videoFile='. $file .'&autoPlay=true&bufferLength=5" width="'.$node->videox.'" height="'.$node->videoy.'" name="Player" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
- </object>';
+ <param name="FlashVars" value="baseURL='. $url .'&videoFile='. $file .'&autoPlay=true&bufferLength=5" />' . "\n"
+ . _video_get_parameters($node) .
+ '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
+</object>';
+
$output = _theme_video_format_play($output, t('http://www.macromedia.com/go/getflashplayer'),
t('Link to Macromedia Flash Player Download Page'),
t('Download latest Flash Player'));
@@ -1135,15 +875,32 @@ function theme_video_play_flash($node) {
* string of content to display
*/
function theme_video_play_swf($node) {
- $output = "<object width=\"$node->videox\" height=\"$node->videoy\">
- <param name=\"movie\" value=\"$node->vidfile\" />"
- . _video_get_parameters($node->serialized_data) .
- "<embed src=\"$node->vidfile\" width=\"$node->videox\" height=\"$node->videoy\" />
- </object>";
+
+ // this will be executed by not Internet Explorer browsers
+ $output = '<!--[if !IE]> <-->
+<object type="application/x-shockwave-flash" width="'. $node->videox .'" height="'. $node->videoy .'"
+data="'. $node->vidfile .'">
+<!--> <![endif]-->' . "\n";
+
+ // this will be executed by Internet Explorer
+ $output .= '<!--[if IE]>
+<object type="application/x-shockwave-flash" width="'. $node->videox .'" height="'. $node->videoy .'"
+classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
+codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
+<![endif]-->' . "\n";
+
+ // params will be passed to both IE or not IE browsers
+ $output .= '<param name="movie" value="'. $node->vidfile .'" />' . "\n"
+ . _video_get_parameters($node) .
+ '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
+</object>';
+
$output = _theme_video_format_play($output, t('http://www.macromedia.com/go/getflashplayer'), t('Link to Flash player download'), t('Download the latest Flash player'));
return theme('page', $output);
}
+
+
/**
* Play Director .dcr/.dir files.
*
@@ -1157,11 +914,26 @@ function theme_video_play_swf($node) {
function theme_video_play_dcr($node) {
$file = basename($node->vidfile);
$url = _video_get_fileurl($node->vidfile);
- $output = '<object classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=10,0,0,0" width="'.$node->videox.'" height="'.$node->videoy.'" ID="player" />
- <param name="src" value="'.$node->vidfile.'" />
- '. _video_get_parameters($node->serialized_data) .'
- <embed src="'.$node->vidfile.'" width="'.$node->videox.'" height="'.$node->videoy.'" type="application/x-director" pluginspace="http://www.macromedia.com/shockwave/download/" />
- </object>';
+
+ // this will be executed by not Internet Explorer browsers
+ $output = '<!--[if !IE]> <-->
+<object type="application/x-director" width="'. $node->videox .'" height="'. $node->videoy .'"
+data="'. $node->vidfile .'">
+<!--> <![endif]-->' . "\n";
+
+ // this will be executed by Internet Explorer
+ $output .= '<!--[if IE]>
+<object type="application/x-director" width="'. $node->videox .'" height="'. $node->videoy .'"
+classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000"
+codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=10,0,0,0">
+<![endif]-->' . "\n";
+
+// params will be passed to both IE or not IE browsers
+ $output .= '<param name="src" value="'. $node->vidfile .'" />' . "\n"
+ . _video_get_parameters($node) .
+ '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
+</object>';
+
$output = _theme_video_format_play($output, t('http://www.macromedia.com/shockwave/download/'),
t('Link to Macromedia Shockwave Player Download Page'),
t('Download latest Shockwave Player'));
@@ -1179,11 +951,36 @@ function theme_video_play_dcr($node) {
* string of content to display
*/
function theme_video_play_quicktime($node) {
- drupal_set_html_head('<script src="'. drupal_get_path('module', 'video') .'/video_insert.js" language="JavaScript" type="text/javascript"></script>');
- $height = $node->videoy + 16; //Increase the height to accommodate the player controls on the bottom.
+ //Increase the height to accommodate the player controls on the bottom.
+ $height = $node->videoy + 16;
+
+ // this will be executed by not Internet Explorer browsers
+ $output = '<!--[if !IE]> <-->
+<object type="video/quicktime" width="'. $node->videox .'" height="'. $height .'"
+data="'. $node->vidfile .'">
+<!--> <![endif]-->' . "\n";
+
+ // this will be executed by Internet Explorer
+ $output .= '<!--[if IE]>
+<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="'. $node->videox .'" height="'. $height .'" scale="tofit" >
+<![endif]-->' . "\n";
+
+ // params will be passed to both IE or not IE browsers
+ $output .= '<param name="src" value="'. $node->vidfile .'" />
+ <param name="AUTOPLAY" value="true" />
+ <param name="KIOSKMODE" value="false" />' . "\n"
+ . _video_get_parameters($node) .
+ '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
+</object>'; // only one </object> needed becouse only one opening tag has been parsed by browsers
+
+
+ /*
$output = '<script language="JavaScript" type="text/javascript">';
$output .= "InsertQuicktimeVideo('{$node->vidfile}','$height','{$node->videox}');";
$output .= '</script>';
+ */
+
+
$output = _theme_video_format_play($output, t('http://www.apple.com/quicktime/download'),
t('Link to QuickTime Download Page'),
t('Download latest Quicktime Player'));
@@ -1203,23 +1000,39 @@ function theme_video_play_realmedia($node) {
// Real's embeded player includes the controls
// in the height
$node->videoy += 40;
- $output = '<object id="video1" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" height="'.$node->videoy.'" width="'.$node->videox.'">
+
+ // this will be executed by not Internet Explorer browsers
+ $output = '<!--[if !IE]> <-->
+<object type="audio/x-pn-realaudio-plugin" width="'. $node->videox .'" height="'. $node->videoy .'"
+data="'. $node->vidfile .'">
+<!--> <![endif]-->' . "\n";
+
+ // this will be executed by Internet Explorer
+ $output .= '<!--[if IE]>
+<object type="audio/x-pn-realaudio-plugin" width="'. $node->videox .'" height="'. $node->videoy .'"
+classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" >
+<![endif]-->' . "\n";
+
+ // params will be passed to both IE or not IE browsers
+ $output .= '<param name="src" value="'. $node->vidfile .'" />
<param name="_ExtentX" value="7276" />
- <param name="_ExtentY" value="3307" />
- <param name="AUTOSTART" value="1" />
+ <param name="" value="3307" />
+ <param name="AUTOSTART" value="true" />
<param name="SHUFFLE" value="0" />
<param name="PREFETCH" value="0" />
<param name="NOLABELS" value="0" />
- <param name="SRC" value="'.$node->vidfile.'" ref />
<param name="CONTROLS" value="All" />
<param name="CONSOLE" value="Clip1" />
<param name="LOOP" value="0" />
<param name="NUMLOOP" value="0" />
<param name="CENTER" value="0" />
- <param name="MAINTAINASPECT" value="0" />
- <param name="BACKGROUNDCOLOR" value="#000000" />
- <embed src="'.$node->vidfile.'" type="audio/x-pn-realaudio-plugin" console="Clip1" controls="All" height="'.$node->videoy.'" width="'.$node->videox.'" autostart="true"></embed>
- </object>';
+ <param name="MAINTAINASPECT" value="1" />
+ <param name="BACKGROUNDCOLOR" value="#000000" />'
+ . _video_get_parameters($node) .
+ '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
+</object>'; // only one </object> needed becouse only one opening tag has been parsed by browsers
+
+
$output = _theme_video_format_play($output, t('http://www.real.com/'),
t('Link to Real'),
t('Download latest Realmedia Player'));
@@ -1239,23 +1052,31 @@ function theme_video_play_windowsmedia($node) {
// Windows Media's embeded player includes the controls in the height
$node->videoy += 68;
$vidfile = _video_get_fileurl($node->vidfile) . basename($node->vidfile);
- $output = '<object id="video1" width="'.$node->videox.'" height="'.$node->videoy.'"
- classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
- codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
- standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">
- <param name="fileName" value="'.$vidfile.'" />
+
+ // this will be executed by not Internet Explorer browsers
+ $output = '<!--[if !IE]> <-->
+<object type="application/x-mplayer2" width="'. $node->videox .'" height="'. $node->videoy .'"
+data="'. $node->vidfile .'">
+<!--> <![endif]-->' . "\n";
+
+ // this will be executed by Internet Explorer
+ $output .= '<!--[if IE]>
+<object type="application/x-oleobject" width="'. $node->videox .'" height="'. $node->videoy .'"
+classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" >
+<![endif]-->' . "\n";
+
+ // params will be passed to both IE or not IE browsers
+ $output .= '<param name="src" value="'. $vidfile .'" />
+ <param name="URL" value="'.$vidfile.'" />
<param name="animationatStart" value="true" />
<param name="transparentatStart" value="true" />
<param name="autoStart" value="true" />
<param name="showControls" value="true" />
- <param name="loop" value="true" />
- <embed type="application/x-mplayer2"
- pluginspage="http://microsoft.com/windows/mediaplayer/en/download/"
- id="mediaPlayer" name="mediaPlayer" displaysize="4" autosize="-1"
- showcontrols="true" showtracker="-1"
- showdisplay="0" showstatusbar="-1" videoborder3d="-1" width="'.$node->videox.'" height="'.$node->videoy.'"
- src="'.$vidfile.'" autostart="true" loop="true"></embed>
- </object>';
+ <param name="loop" value="true" />'
+ . _video_get_parameters($node) .
+ '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
+</object>'; // only one </object> needed becouse only one opening tag has been parsed by browsers
+
$output = _theme_video_format_play($output, t('http://windowsupdate.microsoft.com/'),
t('Link to Windows Update'),
@@ -1277,10 +1098,28 @@ function theme_video_play_windowsmedia($node) {
function theme_video_play_youtube($node) {
$width = ($node->videox ? $node->videox : '425');
$height = ($node->videoy ? $node->videoy : '350');
- $output = '<object width="'.$width.'" height="'.$height.'">
- <param name="movie" value="http://www.youtube.com/v/' . $node->vidfile . '" />
- <embed src="http://www.youtube.com/v/' . $node->vidfile . '" type="application/x-shockwave-flash" width="'.$width.'" height="'.$height.'"></embed>
- </object>';
+
+
+ // this will be executed by not Internet Explorer browsers
+ $output = '<!--[if !IE]> <-->
+<object type="application/x-shockwave-flash" width="'. $width .'" height="'. $height .'"
+data="http://www.youtube.com/v/' . $node->vidfile . '">
+<!--> <![endif]-->' . "\n";
+
+ // this will be executed by Internet Explorer
+ $output .= '<!--[if IE]>
+<object type="application/x-shockwave-flash" width="'. $width .'" height="'. $height .'"
+classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
+codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
+<![endif]-->' . "\n";
+
+ // params will be passed to both IE or not IE browsers
+ $output .= '<param name="movie" value="http://www.youtube.com/v/' . $node->vidfile . '" />' . "\n"
+ . _video_get_parameters($node) .
+ '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
+</object>';
+
+
$output = _theme_video_format_play($output, t('http://www.youtube.com/help.php'), t('Link to youtube.com'), t('youtube.com'));
return theme('page', $output);
}
@@ -1300,10 +1139,34 @@ function theme_video_play_googlevideo($node) {
$height = ($node->videoy ? $node->videoy : '350');
// Strip heading "google:"
$videoid = substr($node->vidfile, 7);
- $output = '<object width="'.$width.'" height="'.$height.'">
- <param name="movie" value="http://video.google.com/googleplayer.swf?docId=' . $videoid . '"></param>
- <embed style="width:' . $width . 'px; height=' . $height . 'px;" src="http://video.google.com/googleplayer.swf?docId=' . $videoid . '" type="application/x-shockwave-flash" width="'.$width.'" height="'.$height.'" allowScriptAccess="sameDomain" quality="best" bgcolor="#ffffff" scale="noScale" wmode="window" salign="TL" FlashVars="playerMode=embedded"></embed>
- </object>';
+
+ // this will be executed by not Internet Explorer browsers
+ $output = '<!--[if !IE]> <-->
+<object type="application/x-shockwave-flash" width="'. $node->videox .'" height="'. $node->videoy .'"
+data="http://video.google.com/googleplayer.swf?docId='. $videoid .'">
+<!--> <![endif]-->' . "\n";
+
+ // this will be executed by Internet Explorer
+ $output .= '<!--[if IE]>
+<object type="application/x-shockwave-flash" width="'. $node->videox .'" height="'. $node->videoy .'"
+classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
+codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
+<![endif]-->' . "\n";
+
+ // params will be passed to both IE or not IE browsers
+ $output .= '<param name="movie" value="http://video.google.com/googleplayer.swf?docId=' . $videoid . '" />' . "\n";
+ // following a list of params simply copied from old embed tag params. I don't know if this are really needed.
+ $output .= '<param name="quality" value="best" />
+ <param name="bgcolor" value="#ffffff" />
+ <param name="allowScriptAccess" value="sameDomain" />
+ <param name="scale" value="noScale" />
+ <param name="wmode" value="window" />
+ <param name="salign" value="TL" />
+ <param name="FlashVars" value="playerMode=embedded" />'
+ . _video_get_parameters($node) .
+ '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
+</object>';
+
$output = _theme_video_format_play($output, t('http://video.google.com/support'), t('Link to video.google.com'), t('video.google.com'));
return theme('page', $output);
@@ -1331,101 +1194,6 @@ function _theme_video_format_play($output, $url, $title, $link_text) {
return $output ."\n</p> \n </div>\n";
}
-/**
- * Display custom fields on the view page.
- *
- * @param $node
- * object with node information
- *
- * @return
- * string of content to display
- */
-function theme_video_customfields($node) {
- //Adds the custom fields.
- $group_title = variable_get('video_customfieldtitle', ''); //Title of the custom fields.
- $title1 = variable_get('video_customfield1', '');
- $title2 = variable_get('video_customfield2', '');
- $title3 = variable_get('video_customfield3', '');
- $title4 = variable_get('video_customfield4', '');
- $title5 = variable_get('video_customfield5', '');
- $title6 = variable_get('video_customfield6', '');
- //Run the fields through the input filter set for the node, then remove paragraphs.
- //Removes the <p> and </p> tags from the filter pass return. This allows each field to be on one line.
- //A better system might be to remove only the first and last <p></P> tags.
- $field1 = str_replace(array('<p>', '</p>'), '', check_markup($node->custom_field_1, $node->format, FALSE));
- $field2 = str_replace(array('<p>', '</p>'), '', check_markup($node->custom_field_2, $node->format, FALSE));
- $field3 = str_replace(array('<p>', '</p>'), '', check_markup($node->custom_field_3, $node->format, FALSE));
- $field4 = str_replace(array('<p>', '</p>'), '', check_markup($node->custom_field_4, $node->format, FALSE));
- $field5 = str_replace(array('<p>', '</p>'), '', check_markup($node->custom_field_5, $node->format, FALSE));
- $field6 = str_replace(array('<p>', '</p>'), '', check_markup($node->custom_field_6, $node->format, FALSE));
-
- $output = '';
- //Make sure all the titles are not blank, if not then display them.
- if (($title1 . $title2 . $title3 . $title4 . $title5 . $title6) != '') {
- $output = '<div class="videofields">'; //Enclose all output in "videofields" div class.
- if ($group_title != '') {
- $output .= '<div class="title"><h2>' . $group_title . '</h2></div>' . "\n";
- }
- if ($title1 != '' and $node->custom_field_1 != '') {
- $fields[] = array('title' => $title1, 'body' => $field1);
- }
- if ($title2 != '' and $node->custom_field_2 != '') {
- $fields[] = array('title' => $title2, 'body' => $field2);
- }
- if ($title3 != '' and $node->custom_field_3 != '') {
- $fields[] = array('title' => $title3, 'body' => $field3);
- }
- if ($title4 != '' and $node->custom_field_4 != '') {
- $fields[] = array('title' => $title4, 'body' => $field4);
- }
- if ($title5 != '' and $node->custom_field_5 != '') {
- $fields[] = array('title' => $title5, 'body' => $field5);
- }
- if ($title6 != '' and $node->custom_field_6 != '') {
- $fields[] = array('title' => $title6, 'body' => $field6);
- }
- $output .= theme('video_fields', $fields); //Generate all the fields HTML.
-
- $output .= '</div><br />'; //Close the "videofields" class div.
- }
- return $output;
-}
-
-/**
- * Display optional metadata (Video and Audio bitrate,..) on the view page.
- *
- * @param $node
- * object with node information
- *
- * @return
- * string of content to display
- $node->video_bitrate, $node->audio_bitrate, $node->audio_sampling_rate, $node->audio_channels,
- */
-function theme_video_metadata($node) {
- //Make sure atleast one fields had data.
- if ($node->video_bitrate != 0 or $node->audio_bitrate != 0 or $node->audio_sampling_rate != 0 or $node->audio_channels != 0) {
- $output = "\n\n<div class=\"video_metadata\">\n";
- $output .= ' <div class="title"><h2>'.t('Video Metadata')."</h2></div>\n";
- if($node->video_bitrate != 0) {
- $fields[] = array('title' => t('Video Bitrate') . ':', 'body' => $node->video_bitrate . ' ' . t('kbits/sec'));
- }
- if($node->audio_bitrate != 0) {
- $fields[] = array('title' => t('Audio Bitrate') . ':', 'body' => $node->audio_bitrate . ' ' . t('kbits/sec'));
- }
- if($node->audio_sampling_rate != 0) {
- $fields[] = array('title' => t('Audio Sampling Rate') . ':', 'body' => $node->audio_sampling_rate . ' ' . t('Hz'));
- }
- if($node->audio_channels != '') {
- $fields[] = array('title' => t('Audio Channels') . ':', 'body' => $node->audio_channels);
- }
- $output .= theme('video_fields', $fields); //Generate the fields HTML.
- $output .= '</div>'; //Closing div video_metadata
- }
- else { //If all the fields are blank then display nothing.
- $output = '';
- }
- return $output;
-}
/**
* Takes an associative array of $fields with 'title' and 'body' keys and outputs the HTML.
@@ -1447,75 +1215,12 @@ function theme_video_fields($fields) {
return $output;
}
-/**
- * Render the output for the node teaser.
- *
- * @param $node
- * object with node information
- *
- * @return
- * string of content to display
- */
-function theme_video_image_teaser($node) {
- $output = '<table border="0" cellpadding="6"><tr><td>';
- $output .= l(theme('image', $node->serial_data['image_teaser'], $node->title, $node->title, NULL, FALSE), "node/$node->nid", array(), NULL, NULL, FALSE, TRUE); //Create a link with an image in it.
- $output .= '</td><td valign="top">' . $node->teaser . '</td></tr></table>';
- return $output;
-}
/**
- * Generates the image HTML displayed in the Node body.
- *
- * @param $node
- * object with node information
- *
- * @return
- * string of content to display
+ * Import the video.js script
*/
-function theme_video_image_body($node) {
- $image = theme('image', $node->serial_data['image_view'], $node->title, $node->title, NULL, FALSE); //Create image HTML
- $output = l($image, "node/$node->nid/play", array(), NULL, NULL, FALSE, TRUE); //Create link HTML with image in it.
- return $output;
-}
-
-/**
- * Outputs the HTML for the download page when multi-file download are turned on.
- *
- * @param $node
- * object with node information
- *
- * @return
- * string of content to display
- */
-function theme_video_download($node) {
- $output = '';
- //Replace some common file types with full name and links.
- $find = array('mov', 'wmv', 'rm', 'avi', 'zip', 'divx', 'flv');
- $replace = array('<a href="http://www.apple.com/quicktime" title="'. t('QuickTime Homepage') . '">' . t('Quicktime') . '</a>'
- , '<a href="http://www.microsoft.com/windowsmedia" title="'. t('Windows Media Homepage') . '">' . t('Windows Media') . '</a>'
- , '<a href="http://www.real.com" title="'. t('Real Media Homepage') . '">' . t('Real Media') . '</a>'
- , '<a href="http://en.wikipedia.org/wiki/AVI" title="'. t('AVI Information at wikipedia.org') . '">' . t('AVI') . '</a>'
- , '<a href="http://en.wikipedia.org/wiki/ZIP_file_format" title="'. t('ZIP Information at wikipedia.org') . '">' . t('ZIP') . '</a>'
- , '<a href="http://www.divx.com" title="'. t('Divx Homepage') . '">' . t('DIVX') . '</a>'
- , '<a href="http://www.macromedia.com/go/getflashplayer" title="'. t('Macromedia Flash Homepage') . '">' .t('Flash FLV') . '</a>'
- );
- $output .= '<br /><div class="videodownload">'; //Enclose all HTML in "videodownload" class.
- foreach($node->file_array as $file) { //Goes through the array of video files and gets them ready for display.
- $file_type = str_replace($find, $replace, $file['type']); //Match and replace common file types.
- $link = l($file['file'], "node/$node->nid/download/" . $file['encoded_url']); //Create link to download file.
- $file_array_table[] = array($link, format_size($file['size']), $file_type); //Create table row.
- }
- $headers = array(t('File Link'), t('File Size'), t('File Type'));
- $output .= theme_table($headers, $file_array_table); //Create the table of files.
- $output .= '</div>'; //Close the "videodownload" class.
-
- //Adds a breadcrumb back to view on the download page. This may not be needed but some better breadcrumbs are.
- $breadcrumb = drupal_get_breadcrumb();
- $breadcrumb[] = l(t('View'), "node/$node->nid");
- drupal_set_breadcrumb($breadcrumb);
-
- drupal_set_title(t('Downloading').' '.$node->title);
- return theme("page", $output);
+function theme_video_get_script() {
+ drupal_set_html_head('<script defer="defer" type="text/javascript" src="'. check_url(base_path() . drupal_get_path('module', 'video')) . '/video.js"></script>');
}
/******************************************************************************
@@ -1559,9 +1264,6 @@ function _video_get_filetype($vidfile) {
* @param $vid
* integer node version ID of the node to have it's download counter updated.
*
- * @param $base64_encoded
- * boolean value determines whether the $input is base64 encoded.
- *
* @return
* Nothing
*/
@@ -1586,39 +1288,7 @@ function _video_download_goto($input_url, $vid, $base64_encoded = FALSE) {
}
}
-/**
- * Scans a directory and returns an array of all the filenames in the directory.
- * This function is only necessary to maintain PHP 4 support.
- *
- * @param $dir
- * The directory. Can be an absolute path or relative from the current working directory.
- *
- * @return
- * array of filenames.
- */
-function _video_scandir($dir) {
- //Try a few different ways to open the directory.
- if (is_dir($dir)) {
- $dir_open = opendir($dir);
- }
- else if (is_dir($new_dir = getcwd() . $dir)) {
- $dir_open = opendir($new_dir);
- }
- else if (is_dir($new_dir = getcwd() . '/' . $dir)) {
- $dir_open = opendir($new_dir);
- }
- else { //If directory does not exist.
- return FALSE;
- }
- if (!$dir_open) { //If opendir returned false then return false.
- return FALSE;
- }
- //If it makes it this far $dir_open should be valid.
- while (($dir_content = readdir($dir_open)) !== FALSE) {
- $files[] = $dir_content;
- }
- return $files;
-}
+
/**
* Convert filesize to bytes
@@ -1738,19 +1408,19 @@ function _video_get_mime_type($node) {
/**
* Generates the HTML for any object parameters in an embedded video.
*
- * @param $serialized_data
- * string of the serialized data directly from the database.
+ * @param $node the node which is being played
*
* @return
* string with the parameters in HTML form.
*/
-function _video_get_parameters($serialized_data) {
- $serial_data = unserialize($serialized_data);
- if(is_array($serial_data) && array_key_exists('object_parameters', $serial_data) && !empty($serial_data['object_parameters'])) {
- $output = '';
- foreach ($serial_data['object_parameters'] as $param => $value) {
- $output .= "<param name=\"$param\" value=\"$value\" />\n";
- }
+function _video_get_parameters(&$node) {
+
+ // call hook_v_get_params
+ $param_value = module_invoke_all('v_get_params', $node);
+
+ $output = '';
+ foreach ($param_value as $param => $value) {
+ $output .= "<param name=\"$param\" value=\"$value\" />\n";
}
return $output;
}