Index: video.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/video/video.module,v
retrieving revision 1.51
diff -u -r1.51 video.module
--- video.module	25 Aug 2006 23:43:28 -0000	1.51
+++ video.module	13 Sep 2006 23:17:23 -0000
@@ -253,12 +253,18 @@
 
   $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', 0),
+    '#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'),
@@ -284,7 +290,7 @@
     '#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'),
@@ -322,6 +328,33 @@
   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 and 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.'));
+    }
+  }
+}
+
 /******************************************************************************
  * Node Hooks
  ******************************************************************************/
@@ -622,11 +655,18 @@
  *   Nothing, modifies $node which is passed by reference.
  */
 function video_view(&$node, $teaser = FALSE, $page = FALSE) {
+
+  // prepare the body and teaser
   $node = node_prepare($node, $teaser); //Run the body through the standard filters.
 
   // include the video css file
   theme_add_style(drupal_get_path('module', 'video').'/video.css');
 
+  // if we are viewing the page, run the body through the theme
+  if($page){
+    $node->body = theme('video_view', $node, $teaser, $page);
+  }
+  
 }
 
 /********************************************************************
@@ -779,40 +819,12 @@
  */
 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 '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();
@@ -824,6 +836,74 @@
  *********************************************************************/
 
 /**
+ * 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){
+  $output = '';
+  if(user_access('play video') && variable_get('video_playinbody', 0)){
+    $output .= theme('video_player', $node);
+  }
+  $output .= '<div id="video_body">'. $node->body .'</div>';
+  return $output; 
+}
+
+/**
+ * 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');
+  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 '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');
+	  return '';
+  }
+}
+
+
+/**
  * Play videos from in FLV Flash video format
  *
  * @param $node
