aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Varesano <fax8@13637.no-reply.drupal.org>2007-02-18 14:15:52 +0000
committerFabio Varesano <fax8@13637.no-reply.drupal.org>2007-02-18 14:15:52 +0000
commit0f6866b59bae258bc7bd1609381c8562c7c6bbab (patch)
tree3aabb5f6ae6e35b0583cf978a2c1cde11251ff47
parentc79262dfbc7a8c6f047cc94a011414a95593525c (diff)
downloadvideo-0f6866b59bae258bc7bd1609381c8562c7c6bbab.tar.gz
video-0f6866b59bae258bc7bd1609381c8562c7c6bbab.tar.bz2
#76319 by Sean B Fuller, agilpwc, Grugnog2: Video should play on the same page
-rw-r--r--video.module249
1 files changed, 162 insertions, 87 deletions
diff --git a/video.module b/video.module
index 2e6c086..392958d 100644
--- a/video.module
+++ b/video.module
@@ -175,8 +175,8 @@ function video_link($type, $node = NULL) {
$display_download_link = variable_get('video_displaydownloadlink', 1);
}
- if (user_access('play video')) {
- if (variable_get('video_displayplaylink', 1)) {
+ if (variable_get('video_displayplaylink', 1)) {
+ if (user_access('play video')) {
$link['video_play'] = array(
'title' => t('play'),
'href' => "node/$node->nid/play",
@@ -186,19 +186,19 @@ function video_link($type, $node = NULL) {
),
);
}
- }
- else {
- $text .= l(t('login'), "user/login", array('class' => 'outgoing', 'title' => t('login to your account')));
- $text .= ' ' . t('or') . ' ';
- $text .= l(t('register'), "user/register", array('class' => 'outgoing', 'title' => t('create a new account')));
- $text .= t(' to play video');
+ else {
+ $text .= l(t('login'), "user/login", array('class' => 'outgoing', 'title' => t('login to your account')));
+ $text .= ' ' . t('or') . ' ';
+ $text .= l(t('register'), "user/register", array('class' => 'outgoing', 'title' => t('create a new account')));
+ $text .= t(' to play video');
- $link['video_play'] = array(
- 'title' => $text,
- 'html' => TRUE,
- );
+ $link['video_play'] = array(
+ 'title' => $text,
+ 'html' => TRUE,
+ );
- }
+ }
+ }
if ($display_download_link == 1) {
$link['video_download'] = array(
'title' => t('download'),
@@ -234,43 +234,6 @@ function video_link($type, $node = NULL) {
}
return array();
}
-
- /*
- // Node links for a video
- if ($type == 'node' && $node->type == 'video' && $node->vidfile && user_access('access video')) {
- //If the video is of type youtube and multi-file downloads aren't turned on don't show the download link.
- if ((_video_get_filetype($node->vidfile) == 'youtube' or _video_get_filetype($node->vidfile) == 'googlevideo') and $node->disable_multidownload == 1) {
- $display_download_link = 0;
- }
- else {
- $display_download_link = variable_get('video_displaydownloadlink', 1);
- }
-
- if (user_access('play video')) {
- if (variable_get('video_displayplaylink', 1)) {
- $link['video_play'] = array(
- 'title' => t('play'),
- 'href' => "node/$node->nid/play",
- 'attributes' => array(
- 'class' => 'outgoing',
- 'title' => t('play %link', array('%link' => $node->title)),
- ),
- );
- }
- }
- if ($display_download_link == 1) {
- $link['video_download'] = array(
- 'title' => t('download'),
- 'href' => "node/$node->nid/download",
- 'attributes' => array(
- 'class' => 'outgoing',
- 'title' => t('download %link', array('%link' => $node->title)),
- ),
- );
- }
- }
- return $link;
- */
/**
@@ -343,12 +306,18 @@ function video_settings_form() {
$form = array();
$form['tabs'] = array('#type' => 'fieldset', '#title' => t('Tab menu options'), '#collapsible' => TRUE, '#collapsed' => TRUE);
+ $form['tabs']['video_playinbody'] = array(
+ '#type' => 'radios',
+ '#title' => t('Play in node'),
+ '#options' => $options,
+ '#default_value' => variable_get('video_playinbody', 1),
+ '#description' => t('Toggle display of video in the body of the node.'));
$form['tabs']['video_displayplaymenutab'] = array(
'#type' => 'radios',
'#title' => t('Display play menu tab'),
'#options' => $options,
'#default_value' => variable_get('video_displayplaymenutab', 1),
- '#description' => t('Toggle display of menu link to play video from the node page.'));
+ '#description' => t('Toggle display of menu link to play video from the node page. If you have chosen to display the video in the body of the node, then this is redundant and must be set to "No."'));
$form['tabs']['video_displaydownloadmenutab'] = array(
'#type' => 'radios',
'#title' => t('Display download menu tab'),
@@ -374,7 +343,7 @@ function video_settings_form() {
'#title' => t('Display play link'),
'#options' => $options,
'#default_value' => variable_get('video_displayplaylink', 1),
- '#description' => t('Toggle display of "play" link (below the node content in most themes).'));
+ '#description' => t('Toggle display of "play" link (below the node content in most themes). If you choose to display the video in the body of the node, then this is redundant and must be set to "No."'));
$form['menu']['video_displaydownloadlink'] = array(
'#type' => 'radios',
'#title' => t('Display download link'),
@@ -568,6 +537,35 @@ function video_form($node) {
return $form;
}
+/**
+ * Form API callback to validate the upload settings form.
+ *
+ * Keeps the use from showing the play tab or the play link
+ * if they have chosen to display the video in the node body.
+ *
+ * @param $form_id
+ * The identifier of the form
+ *
+ * @param $form_values
+ * form values from the settings page
+ *
+ */
+function video_settings_form_validate($form_id, $form_values){
+ // If the user has selected to play videos in the body
+ // and also has the play tab or the play link on
+ // report back that this is redundant and throw an error.
+ if($form_values['video_playinbody'] == 1){
+ if($form_values['video_displayplaylink'] == 1){
+ form_set_error('video_displayplaylink', t('You cannot have the play link turned on if you are playing videos in the node body.'));
+ }
+ if($form_values['video_displayplaymenutab'] == 1){
+ form_set_error('video_displayplaymenutab', t('You cannot have the play tab turned on if you are playing videos in the node body.'));
+ }
+ }
+ if($form_values['video_playinbody'] == 0 && $form_values['video_displayplaylink'] == 0 && $form_values['video_displayplaymenutab'] == 0){
+ drupal_set_message(t('You have NOT selected a method to display videos. Please choose at least one play option below. If you only want users to download videos, you can ignore this message, but usually you will want at least one option turned on. The current possible options are: Display play link, Display in node, and Display play menu tab.'));
+ }
+}
/**
* Implementation of hook submit
@@ -721,6 +719,27 @@ function video_view(&$node, $teaser = FALSE, $page = FALSE) {
drupal_add_css(drupal_get_path('module', 'video').'/video.css');
$node->content['body'] = array('#value' => $node->body);
+ // theme the teaser
+ $node->teaser = theme('video_teaser', $node, $teaser, $page);
+
+ // if we are viewing the page, run the body through the theme
+ if ($page) {
+ $output = '';
+ if (variable_get('video_playinbody', 0)) {
+ if (user_access('play video')) {
+ $output .= theme('video_player', $node);
+ }
+ else {
+ $output .= l(t('login'), "user/login", array('class' => 'outgoing', 'title' => t('login to your account')));
+ $output .= ' ' . t('or') . ' ';
+ $output .= l(t('register'), "user/register", array('class' => 'outgoing', 'title' => t('create a new account')));
+ $output .= t(' to play video');
+ }
+ }
+ $output .= theme('video_view', $node, $teaser, $page);
+ $node->content['body'] = array('#value' => $output);
+ }
+
return $node;
}
@@ -874,49 +893,105 @@ 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') . ' ' . theme('placeholder', $node->title));
- if (variable_get('video_playcounter', 1)) {
- db_query("UPDATE {video} SET play_counter = play_counter + 1 where vid = %d", $node->vid); //Increment play counter.
- }
-
- switch (_video_get_filetype($node->vidfile)) {
- case 'divx':
- return theme('video_play_divx', $node);
- case 'mov':
- case 'mp4':
- case '3gp':
- case '3g2':
- return theme('video_play_quicktime', $node);
- case 'rm':
- return theme('video_play_realmedia', $node);
- case 'flv':
- return theme('video_play_flash', $node);
- case 'swf':
- return theme('video_play_swf', $node);
- case 'dir':
- case 'dcr':
- return theme('video_play_dcr', $node);
- case 'wmv':
- return theme('video_play_windowsmedia', $node);
- case 'ogg':
- return theme('video_play_ogg_theora', $node);
- case 'youtube':
- return theme('video_play_youtube', $node);
- case 'googlevideo':
- return theme('video_play_googlevideo', $node);
- default:
- drupal_set_message('Video type not supported', 'error');
- drupal_goto("node/$node->nid");
- break;
+ $output = theme('video_player', $node);
+ if($output == ''){
+ drupal_goto("node/$node->nid");
}
+ return $output;
}
else {
drupal_not_found();
}
}
+/**
+ * Theme the teaser
+ *
+ * This is just in place for site admins and theme developers
+ * who need to adjust how the teaser is themed.
+ *
+ * @param $node
+ * The node to be displayed.
+ * @param $teaser
+ * Whether we are to generate a "teaser" or summary of the node, rather than display the whole thing.
+ * @param $page
+ * Whether the node is being displayed as a standalone page. If this is TRUE, the node title should not be displayed, as it will be printed automatically by the theme system. Also, the module may choose to alter the default breadcrumb trail in this case.
+ *
+ * @return
+ * html
+ */
+function theme_video_teaser($node, $teaser = FALSE, $page = FALSE) {
+ return $node->teaser;
+}
+
+/**
+ * theme the view of the page to include the video
+ * assumes that body was put through prepare in hook_view
+ *
+ * @param $node
+ * The node to be displayed.
+ * @param $teaser
+ * Whether we are to generate a "teaser" or summary of the node, rather than display the whole thing.
+ * @param $page
+ * Whether the node is being displayed as a standalone page. If this is TRUE, the node title should not be displayed, as it will be printed automatically by the theme system. Also, the module may choose to alter the default breadcrumb trail in this case.
+ *
+ * @return
+ * html
+ */
+function theme_video_view($node, $teaser = FALSE, $page = FALSE) {
+ return '<div id="video_body">'. $node->body .'</div>';
+}
+
+/**
+* theme function to control which player is presented
+*
+* @param $node
+* node object
+*
+* @return
+* html
+*/
+function theme_video_player($node) {
+ // include video.js file for Internet Explorer fixes
+ theme('video_get_script');
+ drupal_set_title(t('Playing') . ' ' . theme('placeholder', $node->title));
+ if (variable_get('video_playcounter', 1)) {
+ db_query("UPDATE {video} SET play_counter = play_counter + 1 where vid = %d", $node->vid); //Increment play counter.
+ }
+
+ switch (_video_get_filetype($node->vidfile)) {
+ case 'divx':
+ return theme('video_play_divx', $node);
+ case 'mov':
+ case 'mp4':
+ case '3gp':
+ case '3g2':
+ return theme('video_play_quicktime', $node);
+ case 'rm':
+ return theme('video_play_realmedia', $node);
+ case 'flv':
+ return theme('video_play_flash', $node);
+ case 'swf':
+ return theme('video_play_swf', $node);
+ case 'dir':
+ case 'dcr':
+ return theme('video_play_dcr', $node);
+ case 'wmv':
+ return theme('video_play_windowsmedia', $node);
+ case 'ogg':
+ return theme('video_play_ogg_theora', $node);
+ case 'youtube':
+ return theme('video_play_youtube', $node);
+ case 'googlevideo':
+ return theme('video_play_googlevideo', $node);
+ default:
+ drupal_set_message('Video type not supported', 'error');
+ drupal_goto("node/$node->nid");
+ break;
+ }
+}
+
/*********************************************************************
* Themeable functions for playing videos. They print a page with a player embedded.
*********************************************************************/