--- swfobject_orig.module	2007-04-02 16:01:01.000000000 -0700
+++ swfobject.module	2007-04-02 15:33:09.000000000 -0700
@@ -1,26 +1,26 @@
 <?php
 // $Id: swfobject.module,v 1.2.2.1 2006/12/14 14:23:57 rz Exp $
 
-// Implementation of hook_help()
-function swfobject_help($section) {
-  switch ($section) {
-    case 'admin/modules#description':
-      $output = t('Create Flash Movie blocks using swfobject.js');
-      break;
-  }
-  return $output;
-}
-
 // Implementation of hook_menu()
 function swfobject_menu($may_cache){
+  $items = array();
   if(!$may_cache){
     drupal_add_js(drupal_get_path('module','swfobject').'/js/swfobject.js');
+    
+    $items[] = array(
+      'path' => 'admin/settings/swfobject',
+      'title' => t('SWF Object'),
+      'description' => t('Select the number of independent SWF blocks, and enable debug mode.'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('swfobject_admin_settings'),
+      'access' => user_access('administer site configuration'),
+    );
   }
-  return array();
+  return $items;
 }
 
 // Implementation of hook_settings()
-function swfobject_settings() {
+function swfobject_admin_settings() {
   $form['swfobject_number'] = array(
     '#type' => 'select', 
     '#title' => t('Number of Flash Gallery Blocks'), 
@@ -35,7 +35,7 @@ function swfobject_settings() {
     '#default_value' => variable_get('swfobject_debug', 'normal'),
     '#options' => drupal_map_assoc(array('normal','debug'))
   );
-  return $form;
+  return system_settings_form($form);
 }
 
 // Implementation of hook_block()
@@ -65,11 +65,15 @@ function swfobject_block($op = 'list', $
         '#title' => t('Required Attributes'),
         '#collapsible' => false
       );
+      if (variable_get('swfobject_swf_'. $delta, '')) {
+        $form['req']['current_swf'] = array(
+          '#value' => t('Current swf: ') . str_replace(array('%h', '%t'), array(base_path(), path_to_theme()), variable_get('swfobject_swf_'. $delta, '')),
+        );
+      }
       $form['req']['swfobject_swf_'. $delta] = array(
-        '#type' => 'textfield', 
-        '#title' => t('Flash file (.swf) location'), 
-        '#default_value' => variable_get('swfobject_swf_'. $delta, 'gallery.swf'),
-        '#description' => t('Enter the path to the flash file (example: "flash/gallery.swf").<br />Macros:<ul><li>%h (host name: http://www.example.com/)</li><li>%t (path to theme: theme/yourtheme/)</li></ul>')        
+        '#type' => 'file', 
+        '#title' => t('Upload Flash file (.swf)'),  
+        '#description' => t('The Flash file to appear in the block.'), 
       );
       $form['req']['swfobject_id_'.$delta] = array(
         '#type' => 'textfield',
@@ -217,7 +221,7 @@ function swfobject_block($op = 'list', $
 
     case 'save':
       foreach($edit as $key=>$value){
-        if(strpos($key, 'swfobject_') === 0){
+        if(strpos($key, 'swfobject_') === 0 && strpos($key, 'swfobject_swf_') !== 0){
           if($value == 'default'){
             // do not store default variables
             variable_del($key);
@@ -226,6 +230,16 @@ function swfobject_block($op = 'list', $
           }
         }
       }
+      
+      // Save uploaded file
+      $file_dir = variable_get('file_directory_path', 'files') .'/swfobject';
+      if(!file_check_directory($file_dir)) {
+        mkdir($file_dir);
+      }
+      if($file = file_save_upload('swfobject_swf_'.$delta, $file_dir .'/'. $file->filename)) {
+        variable_set('swfobject_swf_'.$delta, $file->filepath);
+      }
+      
       if(isset($edit['swfobject_provide_container_'.$delta])){
         variable_set('swfobject_provide_container_'.$delta,
                      $edit['swfobject_provide_container_'.$delta]);
@@ -244,6 +258,17 @@ function swfobject_block($op = 'list', $
     break;
   }
 }
+
+/*
+ * Implementation of hook_form_alter()
+ */ 
+function swfobject_form_alter($form_id, &$form) {
+  // Need to set encoding type in a form_alter because above block config form goes
+  // through block_admin_configure.
+  if ($form['module']['#value'] == 'swfobject' && $form_id == 'block_admin_configure') {
+    $form['#attributes']['enctype'] = 'multipart/form-data';
+  }
+}
   
 // helper function for displaying the actual block
 function theme_swfobject_block_view($delta = 1){
