? dpl5_feedmanager_get_form_fix.patch
Index: feedmanager.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/feedparser/feedmanager.module,v
retrieving revision 1.47
diff -u -p -r1.47 feedmanager.module
--- feedmanager.module	4 Jan 2007 01:56:33 -0000	1.47
+++ feedmanager.module	7 Feb 2007 16:00:20 -0000
@@ -229,117 +229,135 @@ function feedmanager_form_feed($edit = a
     
   switch($op) {
     case 'edit':
-      $form['title'] = array('#type' => 'textfield',
-        '#title' => t('Title'),
-        '#default_value' => $edit['title'],
-        '#maxlength' => 64,
-        '#description' => t('The name of the feed; typically the name of the web site you syndicate content from.'),
-        '#required' => TRUE,
-      );
-    
-      $form['url'] = array('#type' => 'textfield',
-        '#title' => t('URL'),
-        '#default_value' => $edit['url'],
-        '#size' => 100,
-        '#description' => t('The fully-qualified URL of the feed.'),
-        '#attributes' => array('readonly' => 'readonly')
-      );
-      
-      $form['description'] = array('#type' => 'textarea',
-        '#title' => t('Description'),
-        '#default_value' => $edit['description'],
-        '#rows' => 5,
-        '#description' => t('As supplied by the RSS feed.'),
-      );
-    
-      $period = array(0 => t('never')) + drupal_map_assoc(array(300, 900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
-      if ($edit['refresh'] == -1) {
-        $edit['refresh'] = 3600;
-      }
-      $form['refresh'] = array('#type' => 'select',
-        '#title' => t('Update interval'),
-        '#default_value' => $edit['refresh'],
-        '#options' => $period,
-        '#description' => t('The refresh interval indicating how often you want to update this feed. Requires %cron.', array('%cron' => l('crontab', 'admin/settings') )),
-      );
-    
-      $period = array(0 => t('never')) + drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
-      $form['expires'] = array(
-        '#type' => 'select',
-        '#title' => t('Discard news items older than'),
-        '#default_value' => $edit['expires'],
-        '#options' => $period,
-        '#description' => t('Older news items will be automatically discarded.  Requires %cron.', array('%cron' => l('crontab', 'admin/settings') ))
-      );
-   
-      // Handling of categories:
-      $form += feedmanager_freetag($edit);
-    
-      $form['advanced'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Advanced'),
-        '#description' => t('These settings are specific to the type of feed processor you have selected.'),
-        '#collapsible' => TRUE,
-        '#collapsed' => FALSE,
-        '#tree' => TRUE
-      );
-    
-      $form['advanced']['update_items'] = array(
-        '#type' => 'checkbox',
-        '#title' => t('Update news items'),
-        '#description' => t('If the same news item is found in the feed on the next update the contents will overwrite the previous version stored here.'),
-        '#default_value' => $edit['update_items'] ? $edit['update_items'] : FALSE,
-      );
-    
-      $form['advanced']['processor'] = array('#type' => 'value', '#value' => $edit['processor']);
-    
-      $form['advanced']['stripads'] = array(
-        '#type' => 'checkbox',
-        '#title' => t('Strip Adverts'),
-        '#description' => t('Strip out ads from certain advertisers, namely Pheedo, Google AdSense, and certain types of Doubleclick ads.'),
-        '#default_value' => $edit['stripads'] ? $edit['stripads'] : TRUE,
-      );
-      break;
-      
+      return drupal_get_form('feedmanager_form_feed_edit', $edit);
     case 'add':
-      $form['url'] = array('#type' => 'textfield',
-        '#title' => t('URL'),
-        '#default_value' => $edit['url'],
-        '#size' => 100,
-        '#description' => t('The fully-qualified URL of the feed.'),
-        '#required' => TRUE,
-      );
-      
-      // We set feeds to not update until they have been edited
-      $form['refresh'] = array('#type' => 'value', '#value' => -1);
-      
-      $processors = module_invoke_all('feedapi', $feed, 'processor_name');
-      $form['processor'] = array(
-        '#type' => 'select',
-        '#title' => t('Processor'),
-        '#description' => t("Each feed can have it's items generated by a different processor. This allows you to generate different types of content per feed - such as nodes or traditional aggregator items. Re-edit the feed to see processor specific settings."),
-        '#options' => $processors,
-        '#default_value' => $edit['processor'],
-        '#size' => 1,
-        '#required' => TRUE,
-      );
-      break;
+      return drupal_get_form('feedmanager_form_feed_add', $edit);
   }
-  
+}
+
+function feedmanager_form_feed_add($edit) {
+  $form['url'] = array('#type' => 'textfield',
+    '#title' => t('URL'),
+    '#default_value' => $edit['url'],
+    '#size' => 100,
+    '#description' => t('The fully-qualified URL of the feed.'),
+    '#required' => TRUE,
+  );
+
+  // We set feeds to not update until they have been edited
+  $form['refresh'] = array('#type' => 'value', '#value' => -1);
+
+  $processors = module_invoke_all('feedapi', $feed, 'processor_name');
+
+  $form['processor'] = array(
+    '#type' => 'select',
+    '#title' => t('Processor'),
+    '#description' => t("Each feed can have it's items generated by a different processor. This allows you to generate different types of content per feed - such as nodes or traditional aggregator items. Re-edit the feed to see processor specific settings."),
+    '#options' => $processors,
+    '#default_value' => $edit['processor'],
+    '#size' => 1,
+    '#required' => TRUE,
+  );
+
   $form['submit'] = array(
     '#type'          => 'submit',
     '#value'         => t('Submit'),
     '#weight'        => 35,
   );
-  
+
   if ($edit['fid']) {
     $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'), '#weight' => 19);
     $form['fid'] = array('#type' => 'value', '#value' => $edit['fid']);
   }
 
-  return drupal_get_form('feedmanager_form_feed_'.$op, $form);
+  return $form;
 }
 
+function feedmanager_form_feed_edit($edit) {
+  $form['title'] = array('#type' => 'textfield',
+    '#title' => t('Title'),
+    '#default_value' => $edit['title'],
+    '#maxlength' => 64,
+    '#description' => t('The name of the feed; typically the name of the web site you syndicate content from.'),
+    '#required' => TRUE,
+  );
+
+  $form['url'] = array('#type' => 'textfield',
+    '#title' => t('URL'),
+    '#default_value' => $edit['url'],
+    '#size' => 100,
+    '#description' => t('The fully-qualified URL of the feed.'),
+    '#attributes' => array('readonly' => 'readonly')
+  );
+
+  $form['description'] = array('#type' => 'textarea',
+    '#title' => t('Description'),
+    '#default_value' => $edit['description'],
+    '#rows' => 5,
+    '#description' => t('As supplied by the RSS feed.'),
+  );
+
+  $period = array(0 => t('never')) + drupal_map_assoc(array(300, 900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
+  if ($edit['refresh'] == -1) {
+    $edit['refresh'] = 3600;
+  }
+  $form['refresh'] = array('#type' => 'select',
+    '#title' => t('Update interval'),
+    '#default_value' => $edit['refresh'],
+    '#options' => $period,
+    '#description' => t('The refresh interval indicating how often you want to update this feed. Requires %cron.', array('%cron' => l('crontab', 'admin/settings') )),
+  );
+
+  $period = array(0 => t('never')) + drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
+  $form['expires'] = array(
+    '#type' => 'select',
+    '#title' => t('Discard news items older than'),
+    '#default_value' => $edit['expires'],
+    '#options' => $period,
+    '#description' => t('Older news items will be automatically discarded.  Requires %cron.', array('%cron' => l('crontab', 'admin/settings') ))
+  );
+
+  // Handling of categories:
+  $form += feedmanager_freetag($edit);
+
+  $form['advanced'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Advanced'),
+    '#description' => t('These settings are specific to the type of feed processor you have selected.'),
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+    '#tree' => TRUE
+  );
+
+  $form['advanced']['update_items'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Update news items'),
+    '#description' => t('If the same news item is found in the feed on the next update the contents will overwrite the previous version stored here.'),
+    '#default_value' => $edit['update_items'] ? $edit['update_items'] : FALSE,
+  );
+
+  $form['advanced']['processor'] = array('#type' => 'value', '#value' => $edit['processor']);
+
+  $form['advanced']['stripads'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Strip Adverts'),
+    '#description' => t('Strip out ads from certain advertisers, namely Pheedo, Google AdSense, and certain types of Doubleclick ads.'),
+    '#default_value' => $edit['stripads'] ? $edit['stripads'] : TRUE,
+  );
+
+  $form['submit'] = array(
+    '#type'          => 'submit',
+    '#value'         => t('Submit'),
+    '#weight'        => 35,
+  );
+
+  if ($edit['fid']) {
+    $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'), '#weight' => 19);
+    $form['fid'] = array('#type' => 'value', '#value' => $edit['fid']);
+  }
+
+  return $form;
+}
 
 /**
  * Provides a freetagging form element.
