Index: flvmediaplayer.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flvmediaplayer/flvmediaplayer.module,v
retrieving revision 1.14.2.52.2.20.2.19
diff -u -r1.14.2.52.2.20.2.19 flvmediaplayer.module
--- flvmediaplayer.module	31 Mar 2009 22:54:17 -0000	1.14.2.52.2.20.2.19
+++ flvmediaplayer.module	23 Apr 2009 18:53:48 -0000
@@ -127,7 +127,7 @@
         // get the configuration values for this node
         if ($node->flvmediaplayer_config = flvmediaplayer_configuration_values($node)) {
           // add player to node if it exists
-          flvmediaplayer_insert_player($node, theme('flvmediaplayer_display', $node, null, null, $a3));
+          flvmediaplayer_insert_player($node, theme('flvmediaplayer_node_display', $node, null, null, $a3));
         }
       }
     break;
@@ -148,8 +148,8 @@
         // set an override value
         $flv_options['node_override'] = true;
 
-        db_query("DELETE FROM {flvmediaplayer_node} WHERE nid = %d", $node->nid);
-        db_query("INSERT INTO {flvmediaplayer_node} (nid, config) VALUES (%d, '%s')", $node->nid, serialize($flv_options));
+        db_query('DELETE FROM {flvmediaplayer_node} WHERE nid = %d', $node->nid);
+        db_query('INSERT INTO {flvmediaplayer_node} (nid, config) VALUES (%d, "%s")', $node->nid, serialize($flv_options));
         // clear any cached data
         cache_clear_all('flvmp_%'. $node->nid, 'cache_flvmediaplayer', true);
       }
@@ -377,18 +377,20 @@
   // allow the file value to set the output if present in $params
   // look for the file on the params. Do this first to exit if there
   // is no file
-  if (! $config['flashvars']['file'] = flvmediaplayer_url($params['file'])) {
-    // now look to see if the configuration has set the file location
-    if (! $config['flashvars']['file'])  {
-      // set the control to true so that we do not loop here
-      if (! $control) {
-        $control = true;
-        // fire the extend hook to get the file
-        $config['flashvars']['file'] = flvmediaplayer_extend_fire('flvmediaplayer_file_use', 'file', $config['flvmp']['file_location_hook'], $node, $config['flvmp']);
-        if (! $config['flashvars']['file']) {
-          return false;
+  if (! $config['flashvars']['file']) {
+    if (! $config['flashvars']['file'] = flvmediaplayer_url($params['file'])) {
+      // now look to see if the configuration has set the file location
+      if (empty($config['flashvars']['file']))  {
+        // set the control to true so that we do not loop here
+        if (! $control) {
+          $control = true;
+          // fire the extend hook to get the file
+          $config['flashvars']['file'] = flvmediaplayer_extend_fire('flvmediaplayer_file_use', 'file', $config['flvmp']['file_location_hook'], $node, $config['flvmp']);
+          if (! $config['flashvars']['file']) {
+            return false;
+          }
+          $control = false;
         }
-        $control = false;
       }
     }
   }
@@ -406,7 +408,6 @@
   	// determine which profile should be used to display
     if ($config['flvmp']['embed_profile'] && $embed) { $display_profile = $config['flvmp']['embed_profile']; }
     else { $display_profile = $config['flvmp_name']; }
-
     // always pass a profile name to the config page
     // @TODO this is somewhat problematic as we're assuming this is a node. clean this up!
     // only pass back the single config url as the flash var
@@ -419,7 +420,7 @@
 
   // Additional flash var data assigned in the profile.
   // Override any previously set values
-  if ($vars = $config['flvmp_flashvars']) {
+  if ($vars = $config['flvmp']['flashvars']) {
     $vars = explode("\n", $vars);
     foreach($vars as $var) {
       // split the config_name data up
@@ -427,6 +428,10 @@
       $config['flashvars'][$var_name] = str_replace("\r", '', $var_value);
     }
   }
+  // are there any plugins set (probably only relevant for the JW player)
+  if ($plugins = $config['flvmp']['plugins']) {
+    $config['flashvars']['plugins'] = str_replace("\r", '', $plugins);
+  }
 
   return $config;
 }
@@ -467,12 +472,10 @@
       return false;
     }
   }
-
   // If paramters are passed in, merge these with the set values
   if (count($params)) {
     $config = array_merge($config, $params);
   }
-
   // @TODO do this before merging the params in, merge params AFTER
   // Now take the configuration data and put it into a structured array
   $data = array();
@@ -494,7 +497,6 @@
   // now add some data back in
   $data['name'] = $config['flvmp_name'];
   $data['pid'] = $config['flvmp_pid'];
-
   // merge the values and return
   return $data;
 }
@@ -681,7 +683,6 @@
 /* THEME FUNCTIONS */
 /* ******************************************************* */
 
-
 /**
  * Register theming functions
  * @return array
@@ -726,10 +727,19 @@
         'profile' => null,
         'params' => array(),
         'teaser' => false,
+       ),
+     ),
+    'flvmediaplayer_node_display' => array(
+      'file' => 'flvmediaplayer.module',
+      'arguments' => array(
+        'node' => NULL,
+        'profile' => null,
+        'params' => array(),
+        'teaser' => false,
       ),
     ),
   );
-};
+}
 
 
 /**
@@ -740,7 +750,7 @@
  * @return the full flashplayer javascript
  */
 function theme_flvmediaplayer_render_player($player_path, $params, $flashvars) {
-  return theme('swfobject_api', $player_path, $params, $flashvars);
+  return theme("swfobject_api", $player_path, $params, $flashvars );
 }
 
 
@@ -817,7 +827,7 @@
  *   array of vars and params to replace
  * @return string player display code
  */
-function theme_flvmediaplayer_display($node, $profile = null, $params = array(), $teaser = false) {
+function theme_flvmediaplayer_node_display($node, $profile = null, $params = array(), $teaser = false) {
   // get the full configuration and display data for these arguments
   $data = flvmediaplayer_node_data($node, $profile, $params);
   if ($data) {
@@ -841,4 +851,24 @@
     }
     return $output;
   }
+}
+
+
+/**
+ * themes a player based on a profile and inserted data.
+ * @TODO this is not a theme function. Recode to make it work that way
+ * @param object $node
+ *   drupal node object
+ * @param string $profile
+ *   profile to render node data through
+ * @param array $params
+ *   array of vars and params to replace
+ * @return string player display code
+ */
+function theme_flvmediaplayer_display($node, $profile = null, $params = array(), $teaser = false) {
+  // get the full configuration and display data for these arguments
+  $data = flvmediaplayer_node_data($node, $profile, $params);
+  if ($data) {
+    return theme('flvmediaplayer_render_player', $data['player_path'], $data['params'], $data['flashvars']);
+  }
 }
\ No newline at end of file
