aboutsummaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorglen201 <glen201@527446.no-reply.drupal.org>2009-07-31 02:01:53 +0000
committerglen201 <glen201@527446.no-reply.drupal.org>2009-07-31 02:01:53 +0000
commitb66f50d2ce11d0cc8bb53af94ad86278d3fe8e51 (patch)
tree0a9b459d44a0d2729c479d5393e87cd94cb785f2 /includes
parent2524eecbeef2c8b3c0d80a5ffcde2604da50e30c (diff)
downloadvideo-b66f50d2ce11d0cc8bb53af94ad86278d3fe8e51.tar.gz
video-b66f50d2ce11d0cc8bb53af94ad86278d3fe8e51.tar.bz2
#486064: by RobertOak "no video fields in views" Fixed, added Views 2 support
.MPEG/MPG defaulted to play with Windows Media
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc17
-rw-r--r--includes/video.views.inc135
-rw-r--r--includes/video.views_default.inc233
-rw-r--r--includes/video_views_handler_field_download.inc37
-rw-r--r--includes/video_views_handler_field_image.inc74
-rw-r--r--includes/video_views_handler_field_play.inc31
-rw-r--r--includes/video_views_handler_field_playtime_seconds.inc76
7 files changed, 594 insertions, 9 deletions
diff --git a/includes/common.inc b/includes/common.inc
index eeca72a..c70a7a5 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -8,13 +8,9 @@
* porting to Drupal 6
* @author Heshan Wanigasooriya <heshan at heidisoft.com><heshanmw@gmail.com>
* @author Glen Marianko Twitter@demoforum <glenm at demoforum dot com>
- * @todo
+ * @todo Configure default players by video filetype (user configurable?)
*/
-
-
-
-
/**
* Get the object for the suitable player for the parameter resource
*/
@@ -23,10 +19,9 @@ function _video_common_get_player($node) {
case 'divx':
return theme('video_play_divx', $node);
case 'mov':
- case 'mp4':
case '3gp':
case '3g2':
- case 'mpg':
+ case 'mp4':
return theme('video_play_quicktime', $node);
case 'rm':
return theme('video_play_realmedia', $node);
@@ -40,7 +35,9 @@ function _video_common_get_player($node) {
case 'asf':
case 'wmv':
case 'avi':
- return theme('video_play_windowsmedia', $node);
+ case 'mpg':
+ case 'mpeg':
+ return theme('video_play_windowsmedia', $node);
case 'ogg':
return theme('video_play_ogg_theora', $node);
case 'youtube':
@@ -246,9 +243,11 @@ data="'. $url .'">
<![endif]-->' . "\n";
// params will be passed to both IE or not IE browsers
+ //GMM: kioskmode enabled so users don't bypass download security video through player
$output .= '<param name="src" value="'. $url .'" />
<param name="AUTOPLAY" value="'.(variable_get('video_autoplay', TRUE) ? 'true' : 'false').'" />
- <param name="KIOSKMODE" value="false" />' . "\n"
+ <param name="KIOSKMODE" value="true" />
+ <param name="CONTROLLER" value="true" />' . "\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
diff --git a/includes/video.views.inc b/includes/video.views.inc
new file mode 100644
index 0000000..1f0682e
--- /dev/null
+++ b/includes/video.views.inc
@@ -0,0 +1,135 @@
+<?php
+//$Id$
+/**
+* Provides views data and enumerates handlers for video.module
+*
+* @return
+* array - Enables support in the video module for views integration
+* @author Glen Marianko Twitter@demoforum <glenm at demoforum dot com>
+* @todo
+**/
+
+function video_views_data() {
+ // Basic table information.
+ // ----------------------------------------------------------------
+ // views table
+ $data['video']['table']['group'] = t('Video');
+ $data['video']['table']['join'] = array(
+ // ...to the node table
+ 'node' => array(
+ 'left_field' => 'nid',
+ 'field' => 'vid',
+ ),
+ );
+
+ // Fields that can be inserted into a view
+ // play counter
+ $data['video']['play_counter'] = array(
+ 'title' => t('Play count'),
+ 'help' => t('This will display the number of times this has been played.'),
+ 'field' => array(
+ 'handler' => 'views_handler_field_numeric',
+ 'click sortable' => TRUE,
+ ),
+ 'filter' => array(
+ 'handler' => 'views_handler_filter_numeric',
+ ),
+ 'sort' => array(
+ 'title' => t('Play count'),
+ 'help' => t('Sort by the number of video plays.'),
+ 'handler' => 'views_handler_sort',
+ ),
+ );
+ $data['video']['download_counter'] = array(
+ 'title' => t('Download count'),
+ 'help' => t('This will display the number of times this has been downloaded.'),
+ 'field' => array(
+ 'handler' => 'views_handler_field_numeric',
+ 'click sortable' => TRUE,
+ ),
+ 'filter' => array(
+ 'handler' => 'views_handler_filter_numeric',
+ ),
+ 'sort' => array(
+ 'title' => t('Download count'),
+ 'help' => t('Sort by the number of video downloads.'),
+ 'handler' => 'views_handler_sort',
+ ),
+ );
+ $data['video']['videox'] = array(
+ 'title' => t('Width (x)'),
+ 'help' => t('This will display the width (x) of the video'),
+ 'field' => array(
+ 'handler' => 'views_handler_field_numeric',
+ 'click sortable' => TRUE,
+ ),
+ 'filter' => array(
+ 'handler' => 'views_handler_filter_numeric',
+ ),
+ 'sort' => array(
+ 'handler' => 'views_handler_sort',
+ ),
+ );
+ $data['video']['videoy'] = array(
+ 'title' => t('Height (y)'),
+ 'help' => t('This will display the height (y) of the video'),
+ 'field' => array(
+ 'handler' => 'views_handler_field_numeric',
+ 'click sortable' => TRUE,
+ ),
+ 'filter' => array(
+ 'handler' => 'views_handler_filter_numeric',
+ ),
+ 'sort' => array(
+ 'handler' => 'views_handler_sort',
+ ),
+ );
+ $data['video']['playtime_seconds'] = array(
+ 'title' => t('Length'),
+ 'help' => t('This will display the play length of the video.'),
+ 'field' => array(
+ 'handler' => 'video_views_handler_field_playtime_seconds',
+ 'click sortable' => TRUE,
+ ),
+ 'filter' => array(
+ 'handler' => 'views_handler_filter_numeric',
+ ),
+ 'sort' => array(
+ 'title' => t('Length'),
+ 'help' => t('Sort by the video length.'),
+ 'handler' => 'views_handler_sort',
+ ),
+ );
+ $data['video']['download_link'] = array(
+ 'real field' => 'vidfile',
+ 'title' => t('Download link'),
+ 'help' => t('This will display a download link if the node allows it.'),
+ 'field' => array(
+ 'handler' => 'video_views_handler_field_download',
+ 'click sortable' => FALSE,
+ )
+ );
+ $data['video']['play_link'] = array(
+ 'real field' => 'vidfile',
+ 'title' => t('Play link'),
+ 'help' => t('This will display a play link if the node allows it.'),
+ 'field' => array(
+ 'handler' => 'video_views_handler_field_play',
+ 'click sortable' => FALSE,
+ ),
+ );
+
+ // Add video_image support only if the video_image module is enabled
+ if (module_exists('video_image')) {
+ $data['video']['video_image'] = array(
+ 'real field' => 'vidfile',
+ 'title' => t('Thumbnail'),
+ 'help' => t('This will display the thumbnail image for the video.'),
+ 'field' => array(
+ 'handler' => 'video_views_handler_field_image',
+ 'click sortable' => FALSE,
+ ),
+ );
+ }
+ return $data;
+}
diff --git a/includes/video.views_default.inc b/includes/video.views_default.inc
new file mode 100644
index 0000000..271738e
--- /dev/null
+++ b/includes/video.views_default.inc
@@ -0,0 +1,233 @@
+<?php
+//$Id$
+/**
+* Implementation of hook_views_tables
+*
+* @return
+* array - Enables default video module Video Tracker vie
+ * @author Glen Marianko Twitter@demoforum <glenm at demoforum dot com>
+* @todo
+**/
+
+/**
+* Provide a default view
+*
+* @return
+ array - of views
+**/
+function video_views_default_views() {
+ $views = array();
+
+ // view definition (Views 2)
+ $view = new view;
+ $view->name = 'video_tracker';
+ $view->description = 'Shows all recent video activity (table format)';
+ $view->tag = '';
+ $view->view_php = '';
+ $view->base_table = 'node';
+ $view->is_cacheable = FALSE;
+ $view->api_version = 2;
+ $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+ $handler = $view->new_display('default', 'Defaults', 'default');
+ $handler->override_option('fields', array(
+ 'title' => array(
+ 'id' => 'title',
+ 'table' => 'node',
+ 'field' => 'title',
+ 'label' => 'Title',
+ 'link_to_node' => TRUE,
+ ),
+ 'changed' => array(
+ 'id' => 'changed',
+ 'table' => 'node',
+ 'field' => 'changed',
+ 'label' => 'Last Updated',
+ 'date_format' => 'small',
+ ),
+ 'name' => array(
+ 'id' => 'name',
+ 'table' => 'users',
+ 'field' => 'name',
+ 'label' => 'Author',
+ ),
+ 'playtime_seconds' => array(
+ 'label' => 'Play time',
+ 'alter' => array(
+ 'alter_text' => 0,
+ 'text' => '',
+ 'make_link' => 0,
+ 'path' => '',
+ 'link_class' => '',
+ 'alt' => '',
+ 'prefix' => '',
+ 'suffix' => '',
+ 'help' => '',
+ 'trim' => 0,
+ 'max_length' => '',
+ 'word_boundary' => 1,
+ 'ellipsis' => 1,
+ 'strip_tags' => 0,
+ 'html' => 0,
+ ),
+ 'exclude' => 0,
+ 'id' => 'playtime_seconds',
+ 'table' => 'video',
+ 'field' => 'playtime_seconds',
+ 'relationship' => 'none',
+ ),
+ 'video_image' => array(
+ 'id' => 'video_image',
+ 'table' => 'video',
+ 'field' => 'video_image',
+ 'label' => 'Preview / Play',
+ ),
+ ));
+ $handler->override_option('sorts', array(
+ 'changed' => array(
+ 'order' => 'ASC',
+ 'granularity' => 'second',
+ 'id' => 'changed',
+ 'table' => 'node',
+ 'field' => 'changed',
+ 'relationship' => 'none',
+ ),
+ ));
+ $handler->override_option('filters', array(
+ 'type' => array(
+ 'id' => 'type',
+ 'table' => 'node',
+ 'field' => 'type',
+ 'operator' => 'in',
+ 'value' => array(
+ '0' => 'video',
+ ),
+ ),
+ 'status' => array(
+ 'id' => 'status',
+ 'table' => 'node',
+ 'field' => 'status',
+ 'value' => '1',
+ ),
+ ));
+ $handler->override_option('access', array(
+ 'type' => 'none',
+ 'role' => array(),
+ 'perm' => '',
+ ));
+ $handler->override_option('cache', array(
+ 'type' => 'none',
+ ));
+ $handler->override_option('title', 'Recent video activity');
+ $handler->override_option('header_format', '1');
+ $handler->override_option('footer_format', '1');
+ $handler->override_option('empty', 'There is no recent video activity');
+ $handler->override_option('empty_format', '1');
+ $handler->override_option('items_per_page', '20');
+ $handler->override_option('use_pager', TRUE);
+ $handler->override_option('style_plugin', 'table');
+ $handler->override_option('style_options', array(
+ 'columns' => array(),
+ 'default' => 'changed',
+ 'info' => array(
+ 'title' => array(
+ 'sortable' => TRUE,
+ ),
+ 'changed' => array(
+ 'sortable' => TRUE,
+ ),
+ ),
+ 'override' => FALSE,
+ 'order' => 'asc',
+ ));
+ $handler = $view->new_display('page', 'Page', 'page_1');
+ $handler->override_option('path', 'video/tracker');
+ $handler->override_option('menu', array(
+ 'type' => 'none',
+ 'title' => '',
+ 'description' => '',
+ 'weight' => 0,
+ 'name' => 'navigation',
+ ));
+ $handler->override_option('tab_options', array(
+ 'type' => 'none',
+ 'title' => '',
+ 'description' => '',
+ 'weight' => 0,
+ ));
+ $handler = $view->new_display('block', 'Block', 'block_1');
+ $handler->override_option('fields', array(
+ 'title' => array(
+ 'label' => '',
+ 'alter' => array(
+ 'alter_text' => 0,
+ 'text' => '',
+ 'make_link' => 0,
+ 'path' => '',
+ 'link_class' => '',
+ 'alt' => '',
+ 'prefix' => '',
+ 'suffix' => '',
+ 'help' => '',
+ 'trim' => 0,
+ 'max_length' => '',
+ 'word_boundary' => 1,
+ 'ellipsis' => 1,
+ 'strip_tags' => 0,
+ 'html' => 0,
+ ),
+ 'link_to_node' => 1,
+ 'exclude' => 0,
+ 'id' => 'title',
+ 'table' => 'node',
+ 'field' => 'title',
+ 'override' => array(
+ 'button' => 'Use default',
+ ),
+ 'relationship' => 'none',
+ ),
+ 'video_image' => array(
+ 'label' => '',
+ 'alter' => array(
+ 'alter_text' => 0,
+ 'text' => '',
+ 'make_link' => 0,
+ 'path' => '',
+ 'link_class' => '',
+ 'alt' => '',
+ 'prefix' => '',
+ 'suffix' => '',
+ 'help' => '',
+ 'trim' => 0,
+ 'max_length' => '',
+ 'word_boundary' => 1,
+ 'ellipsis' => 1,
+ 'strip_tags' => 0,
+ 'html' => 0,
+ ),
+ 'exclude' => 0,
+ 'id' => 'video_image',
+ 'table' => 'video',
+ 'field' => 'video_image',
+ 'override' => array(
+ 'button' => 'Use default',
+ ),
+ 'relationship' => 'none',
+ ),
+ ));
+ $handler->override_option('use_ajax', TRUE);
+ $handler->override_option('items_per_page', 1);
+ $handler->override_option('use_pager', 'mini');
+ $handler->override_option('style_plugin', 'grid');
+ $handler->override_option('style_options', array(
+ 'grouping' => '',
+ 'columns' => '1',
+ 'alignment' => 'horizontal',
+ ));
+ $handler->override_option('block_description', 'Video Tracker');
+ $handler->override_option('block_caching', -1);
+
+ // recent video node activity view
+ $views[$view->name] = $view;
+ return $views;
+}
+
diff --git a/includes/video_views_handler_field_download.inc b/includes/video_views_handler_field_download.inc
new file mode 100644
index 0000000..c01333e
--- /dev/null
+++ b/includes/video_views_handler_field_download.inc
@@ -0,0 +1,37 @@
+<?php
+//$Id$
+/**
+* Implementation of hook_views_tables
+*
+* @return
+* array - Enables support in the video module for views integration
+ * @author Glen Marianko Twitter@demoforum <glenm at demoforum dot com>
+ * @todo
+**/
+
+/**
+ * Field handler to display the play length of the video.
+ *
+ * @ingroup views_field_handlers
+ */
+class video_views_handler_field_download extends views_handler_field {
+ /**
+ * Render field output to the browser.
+ */
+ function render($values) {
+ return _video_views_handler_field_download($values);
+ }
+}
+/**
+* Handler to to return the correct download link for the video in a field
+**/
+function _video_views_handler_field_download($values) {
+ /* $str = NULL;
+ foreach($values as $key => $value) {
+ $str .= $key .'<br>';
+ }
+ return $str; */
+ if($values->node_type && $values->node_type != 'video') return NULL;
+ return l(t('Download'), "node/$values->nid/download", array());
+}
+
diff --git a/includes/video_views_handler_field_image.inc b/includes/video_views_handler_field_image.inc
new file mode 100644
index 0000000..fbbe905
--- /dev/null
+++ b/includes/video_views_handler_field_image.inc
@@ -0,0 +1,74 @@
+<?php
+//$Id$
+/**
+* Implementation of hook_views_tables
+*
+* @return
+* array - Enables support in the video module for views integration
+ * @author Glen Marianko Twitter@demoforum <glenm at demoforum dot com>
+ * @todo
+**/
+
+/**
+ * Field handler to display the video preview thumbnail
+ *
+ * @ingroup views_field_handlers
+ */
+class video_views_handler_field_image extends views_handler_field {
+ /**
+ * Define options available for this field.
+ */
+ function option_definition() {
+ $options = parent::option_definition();
+ $options['img_type'] = array('default' => 'thumbnail');
+ $options['disp_link'] = array('default' => TRUE);
+ return $options;
+ }
+
+ /**
+ * Build option configuration form.
+ */
+ function options_form(&$form, &$form_state) {
+ parent::options_form($form, $form_state);
+
+ $form['img_type'] = array(
+ '#title' => t('Show image as'),
+ '#type' => 'select',
+ '#options' => array(
+ 'thumbnail' => t('Thumbnail'),
+ 'preview' => t('Preview'),
+ ),
+ '#default_value' => $this->options['img_type'],
+ );
+ $form['disp_link'] = array(
+ '#title' => t('Link image to video'),
+ '#type' => 'checkbox',
+ '#default_value' => $this->options['disp_link'],
+ );
+
+ }
+/**
+ * Render field output to the browser.
+ */
+ function render($values) {
+ return _video_views_handler_field_image($values, $this->options['img_type'], $this->options['disp_link']);
+ }
+}
+/**
+* Handler to render the preview image associated with a video
+**/
+function _video_views_handler_field_image($values, $image_type, $linked) {
+ if($values->node_type && $values->node_type != 'video') return NULL;
+ $node = node_load($values->nid);
+ $output = NULL;
+ if($node->iid && $image = node_load($node->iid)) {
+ $image_html = NULL;
+ if($image != NULL && $image->type == 'image') {
+ $image_html = image_display($image, $image_type, array('class' => 'video_image_teaser'));
+ //Create a link with an image in it.
+ $output .= ($linked ? l($image_html, "node/$values->nid", array('html' => TRUE)) : $image_html);
+ $output .= '<br class="video_image_clear" />';
+ }
+ }
+ return $output;
+}
diff --git a/includes/video_views_handler_field_play.inc b/includes/video_views_handler_field_play.inc
new file mode 100644
index 0000000..1eac89e
--- /dev/null
+++ b/includes/video_views_handler_field_play.inc
@@ -0,0 +1,31 @@
+<?php
+//$Id$
+/**
+* Implementation of hook_views_tables
+*
+* @return
+* array - Enables support in the video module for views integration
+ * @author Glen Marianko Twitter@demoforum <glenm at demoforum dot com>
+ * @todo
+**/
+
+/**
+ * Field handler to display the play length of the video.
+ *
+ * @ingroup views_field_handlers
+ */
+class video_views_handler_field_play extends views_handler_field {
+ /**
+ * Render field output to the browser.
+ */
+ function render($values) {
+ return _video_views_handler_field_play($values);
+ }
+}
+/**
+* Handler to to render the "Play" link field
+**/
+function _video_views_handler_field_play($values) {
+ if($values->node_type && $values->node_type != 'video') return NULL;
+ return l(t('Play'), "node/$values->nid/play", array());
+}
diff --git a/includes/video_views_handler_field_playtime_seconds.inc b/includes/video_views_handler_field_playtime_seconds.inc
new file mode 100644
index 0000000..c0efc93
--- /dev/null
+++ b/includes/video_views_handler_field_playtime_seconds.inc
@@ -0,0 +1,76 @@
+<?php
+//$Id$
+/**
+* Implementation of hook_views_tables
+*
+* @return
+* array - Enables support in the video module for views integration
+ * @author Glen Marianko Twitter@demoforum <glenm at demoforum dot com>
+ * @todo
+**/
+
+/**
+ * Field handler to display the play length of the video.
+ *
+ * @ingroup views_field_handlers
+ */
+class video_views_handler_field_playtime_seconds extends views_handler_field {
+ /**
+ * Define options available for this field.
+ */
+ function option_definition() {
+ $options = parent::option_definition();
+ $options['time_type'] = array('default' => 'hms');
+ return $options;
+ }
+
+ /**
+ * Build option configuration form.
+ */
+ function options_form(&$form, &$form_state) {
+ parent::options_form($form, $form_state);
+
+ $form['time_type'] = array(
+ '#title' => t('Show playtime as'),
+ '#type' => 'select',
+ '#options' => array(
+ 'hms' => t('Hour:min:sec'),
+ 'sec' => t('Seconds'),
+ ),
+ '#default_value' => $this->options['time_type'],
+ );
+ }
+ /**
+ * Render field output to the browser.
+ */
+ function render($values) {
+ return _video_playtime_seconds($values, $this->options['time_type']);
+ }
+}
+/**
+* Handler to to render the correct playtime for the video in a field
+**/
+function _video_playtime_seconds($values, $type) {
+ if($values->node_type && $values->node_type != 'video') return NULL;
+ switch ($type) {
+ case 'hms':
+ $hms = _video_sec2hms($values->video_playtime_seconds);
+
+ // Pad the minutes / seconds with a leading "0", if
+ // necessary
+ if ($hms['hours'] > 0) {
+ $hms['minutes'] = str_pad($hms['minutes'], 2, '0', STR_PAD_LEFT);
+ }
+ $hms['seconds'] = str_pad($hms['seconds'], 2, '0', STR_PAD_LEFT);
+
+ $out = '';
+ if ($hms['hours'] > 0) {
+ $out .= $hms['hours'].":";
+ }
+ $out .= $hms['minutes'].":".$hms['seconds'];
+ return $out;
+ case 'sec':
+ default:
+ return $values->video_playtime_seconds;
+ }
+}