Index: swftools.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/swftools/swftools.module,v
retrieving revision 1.20.2.8
diff -u -p -r1.20.2.8 swftools.module
--- swftools.module	17 Mar 2009 23:13:22 -0000	1.20.2.8
+++ swftools.module	18 Mar 2009 16:09:21 -0000
@@ -111,7 +111,6 @@ function swftools_perm() {
   );
 }
 
-
 /**
  * Take an array of play list data and options, and return a markup string.
  * 
@@ -1063,8 +1062,8 @@ function swftools_prepare_playlist_data(
         }
         else {
           $playlist_data['playlist'][$key]['filepath'] = $data['filepath'];
-		  $playlist_data['playlist'][$key]['fileurl'] = $data['filepath'];          
-		}
+      $playlist_data['playlist'][$key]['fileurl'] = $data['filepath'];          
+    }
       }
     }
     if (!isset($data['filename'])) {
@@ -1431,6 +1430,22 @@ function swftools_url_parse($string) {
 }
 
 /**
+ * Implementation of hook_field_formatter_info().
+ */
+function swftools_field_formatter_info() {
+  return array(
+    'swftools' => array('label' => t('SWF Tools'),
+      'field types' => array('filefield'),
+      'multiple values' => CONTENT_HANDLE_CORE,
+    ),
+    'swftools_no_file' => array('label' => t('SWF Tools (with no download-able file)'),
+      'field types' => array('filefield'),
+      'multiple values' => CONTENT_HANDLE_CORE,
+    ),    
+  );
+}
+
+/**
  * Implementation of hook_theme
  */
 function swftools_theme() {
@@ -1438,11 +1453,47 @@ function swftools_theme() {
     'swftools_embed' => array(
       'arguments' => array('embed_code' => NULL, 'action' => NULL, 'methods' => NULL, 'vars' => array(), 'html_alt' => NULL),
     ),
+    'swftools_formatter_swftools' => array(
+      'arguments' => array('element' => NULL),
+    ),
+    'swftools_formatter_swftools_no_file' => array(
+      'arguments' => array('element' => NULL),
+    ),        
   );
 }
 
 
 /**
+ * Theme function; Pass the file to the SWF Tools.
+ */
+function theme_swftools_formatter_swftools($element) {
+  if ($swftools = _sfwtools_prepare_swf_for_theme($element)) {
+    $filefield = theme('filefield_formatter_default', $element);
+    return $swftools . $filefield;
+  }
+}
+
+/**
+ * Theme function; Pass the file to the SWF Tools.
+ */
+function theme_swftools_formatter_swftools_no_file($element) {
+  return _sfwtools_prepare_swf_for_theme($element);
+}
+
+/**
+ * Helper function; Prepare the SWF theme for the filefield formatter.
+ * @param $element
+ *   The element passed by CCK module
+ * @return
+ *   The HTML output or empty string if the element has no file.
+ */
+function _sfwtools_prepare_swf_for_theme($element) {
+  // Check there is a file.
+  return !empty($element['#item']['fid']) ? swf($element['#item']['filepath']) : '';
+}
+
+
+/**
  * Implementation of hook_file_download
  * Allows SWF Tools to work with a private file system that might include files
  * upload outside the control of an upload module, e.g. FTP of large video files
