Index: adsense.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/adsense/adsense.module,v
retrieving revision 1.25
diff -u -F^f -r1.25 adsense.module
--- adsense.module	3 Dec 2005 03:29:28 -0000	1.25
+++ adsense.module	20 Jan 2006 20:31:13 -0000
@@ -175,82 +175,175 @@ function adsense_perm() {
 
 function adsense_settings() {
   cache_clear_all('adsense', TRUE);
-  $output .= form_textfield(t('Google AdSense Client ID'), 'adsense_client_id',
-    variable_get('adsense_client_id', ''), 25, 25,
-    t('This is the <strong>google_ad_client</strong> line in your Ad code, without the quotes. You must apply for an account with Google AdSense before you get this client ID. Please type it carefully. If you mistype it, your account will not get credited by Google for ads displayed on your site.'));
-
-  $output .= form_radios(t('Show Adsense on specific pages'), 'adsense_visibility',
-    variable_get('adsense_visibility', '0'), array(t('Show on every page except the listed pages.'),
-    t('Show on only the listed pages.')));
-
-  $output .= form_textarea(t('Pages'), 'adsense_access_pages',
-    variable_get('adsense_access_pages', ''), 70, 5,
-    t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are '<em>blog</em>' for the blog page and '<em>blog/*</em>' for every personal blog. '<em>&lt;front&gt;</em>' is the front page."));
 
-  $form_req = form_group(t('Required parameters'), $output);
+  // required parameters
+  $form['required'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Required parameters'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+  $form['required']['adsense_client_id'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Google AdSense Client ID'),
+    '#default_value' => variable_get('adsense_client_id', ''),
+    '#size' => 25,
+    '#maxlength' => 25,
+    '#description' => t('This is the <strong>google_ad_client</strong> line in your Ad code, without the quotes. You must apply for an account with Google AdSense before you get this client ID. Please type it carefully. If you mistype it, your account will not get credited by Google for ads displayed on your site.'),
+  );
+  $form['required']['adsense_visibility'] = array(
+    '#type' => 'radios',
+    '#title' => t('Show Adsense on specific pages'),
+    '#default_value' => variable_get('adsense_visibility', '0'),
+    '#options' => array(t('Show on every page except the listed pages.'),
+      t('Show on only the listed pages.')),
+  );
+  $form['required']['adsense_access_pages'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Pages'),
+    '#default_value' => variable_get('adsense_access_pages', ''),
+    '#cols' => 70,
+    '#rows' => 5,
+    '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are '<em>blog</em>' for the blog page and '<em>blog/*</em>' for every personal blog. '<em>&lt;front&gt;</em>' is the front page."),
+  );
+
+  // Ad types and colours
+  // TODO could we name the nested options in here better - this is a straight port from 4.6 ways for form-ing it
+  $form['types_colors'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Ad Type and Colors'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
 
   foreach(array(1,2,3) as $group) {
 
-    $output = form_radios(t('Ad Type'), 'adsense_ad_type_' . $group, 
-      variable_get('adsense_ad_type_' . $group, '000000'), array(t('Text'), t('Image'), t('Both')));
-
-    $output .= form_textfield(t('Ad Text Color'), 'adsense_color_text_' . $group,
-      variable_get('adsense_color_text_' . $group, '000000'), 6, 6);
-
-    $output .= form_textfield(t('Ad Border Color'), 'adsense_color_border_' . $group,
-      variable_get('adsense_color_border_' . $group, '336699'), 6, 6);
-
-    $output .= form_textfield(t('Ad Background Color'), 'adsense_color_bg_' . $group,
-      variable_get('adsense_color_bg_' . $group, 'FFFFFF'), 6, 6);
-
-    $output .= form_textfield(t('Ad Title Color'), 'adsense_color_link_' . $group,
-      variable_get('adsense_color_link_' . $group, '336699'), 6, 6);
-
-    $output .= form_textfield(t('Ad URL Color'), 'adsense_color_url_' . $group,
-      variable_get('adsense_color_url_' . $group, 'FF8C00'), 6, 6);
-  
-    $output .= form_select(t('Alternate URL/Color'), 'adsense_alt_' . $group,
-      variable_get('adsense_alt_' . $group, 0),
-      array(t('None'), t('Alternate URL'), t('Alternate Color')));
-
-    $output .= form_textfield(t('Alternate info'), 'adsense_alt_info_' . $group,
-      variable_get('adsense_alt_info_' . $group, ''), 100, 100,
-      t('Enter either 6 letter alternate color code, or alternate URL to use'));
-
-    $form_group .= form_group(t('Group ' . $group . ' Attributes'), $output);
-  }
-
-  $form_type = form_group(t('Ad Type and Colors'), $form_group);
-
-  $output = '';
+    $form['types_colors'][$group .'_attributes'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Group ' . $group . ' Attributes'),
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
+    );
+    $form['types_colors'][$group .'_attributes']['adsense_ad_type_' . $group] = array(
+      '#type' => 'radios',
+      '#title' => t('Ad Type'),
+      '#default_value' => variable_get('adsense_ad_type_' . $group, '000000'),
+      '#options' => array(t('Text'), t('Image'), t('Both')),
+    );
+    $form['types_colors'][$group .'_attributes']['adsense_color_text_' . $group] = array(
+      '#type' => 'textfield',
+      '#title' => t('Ad Text Color'),
+      '#default_value' => variable_get('adsense_color_text_' . $group, '000000'),
+      '#size' => 6,
+      '#maxlength' => 6,
+    );
+    $form['types_colors'][$group .'_attributes']['adsense_color_border_' . $group] = array(
+      '#type' => 'textfield',
+      '#title' => t('Ad Border Color'),
+      '#default_value' => variable_get('adsense_color_border_' . $group, '336699'),
+      '#size' => 6,
+      '#maxlength' => 6,
+    );
+    $form['types_colors'][$group .'_attributes']['adsense_color_bg_' . $group] = array(
+      '#type' => 'textfield',
+      '#title' => t('Ad Background Color'),
+      '#default_value' => variable_get('adsense_color_bg_' . $group, 'FFFFFF'),
+      '#size' => 6,
+      '#maxlength' => 6,
+    );
+    $form['types_colors'][$group .'_attributes']['adsense_color_link_' . $group] = array(
+      '#type' => 'textfield',
+      '#title' => t('Ad Title Color'),
+      '#default_value' => variable_get('adsense_color_link_' . $group, '336699'),
+      '#size' => 6,
+      '#maxlength' => 6,
+    );
+    $form['types_colors'][$group .'_attributes']['adsense_color_url_' . $group] = array(
+      '#type' => 'textfield',
+      '#title' => t('Ad URL Color'),
+      '#default_value' => variable_get('adsense_color_url_' . $group, 'FF8C00'),
+      '#size' => 6,
+      '#maxlength' => 6,
+    );
+    $form['types_colors'][$group .'_attributes']['adsense_alt_' . $group] = array(
+      '#type' => 'select',
+      '#title' => t('Alternate URL/Color'),
+      '#default_value' => variable_get('adsense_alt_' . $group, 0),
+      '#options' => array(t('None'), t('Alternate URL'), t('Alternate Color')),
+    );
+    $form['types_colors'][$group .'_attributes']['adsense_alt_info_' . $group] = array(
+      '#type' => 'textfield',
+      '#title' => t('Alternate info'),
+      '#default_value' => variable_get('adsense_alt_info_' . $group, ''),
+      '#size' => 100,
+      '#maxlength' => 100,
+      '#description' => t('Enter either 6 letter alternate color code, or alternate URL to use'),
+    );
+  }
+
+  $form['channels'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Custom Channels'),
+    '#description' => t('Enter up to 5 custom channels that you have configured in Google AdSense. If you are not using Custom Channels, or you are only using URL channels, then leave this empty'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
   foreach(array(1,2,3,4,5) as $channel) {
-    $output .= form_textfield(t('Custom Channel ID'), 'adsense_ad_channel_' . $channel, 
-      variable_get('adsense_ad_channel_' . $channel, ''), 30, 30);
-    }
-
-  $form_channel = form_group(t('Custom Channels'), $output, t('Enter up to 5 custom channels that you have configured in Google AdSense. If you are not using Custom Channels, or you are only using URL channels, then leave this empty'));
-
-  $output = form_checkbox (t('Disable Google AdSense ads?'), 'adsense_disable', 1,
-    variable_get('adsense_disable', '0'), t('This disables all display of Google AdSense Ads from your web site. This is useful in certain situations, such as site upgrades, or if you make a copy of the site for development and test purposes.'));
-
-  $output .= form_checkbox (t('Placeholder when ads are disabled?'), 'adsense_placeholder', 1,
-    variable_get('adsense_placeholder', '1'), t('This causes an empty box to be displayed in place of the ads when they are disabled.'));
-
-  $output .= form_textarea(t('Placeholder Text to display'), 'adsense_placeholder_text',
-    variable_get('adsense_placeholder_text', t('Google AdSense ad placeholder here')), 70, 5,
-    t('Enter any text to display as a placeholder when ads are disabled.'));
-
-  $output .= form_textfield(t('Ad limit per page'), 'adsense_page_ad_limit',
-    variable_get('adsense_page_ad_limit', 3) , 6, 6,
-    t('Google currently limits a page to 3 ad units'));
-  
-  $output .= form_checkbox (t('Enable Adsense Section targeting?'), 'adsense_section_targeting', 1,
-    variable_get('adsense_section_targeting', 1),
-    t('This better targets Google Ads to the teaser and body of nodes.'));
-
-  $form_adv = form_group(t('Advanced options'), $output);
+    $form['channels']['adsense_ad_channel_'. $channel] = array(
+      '#type' => 'textfield',
+      '#title' => t('Custom Channel ID'),
+      '#default_value' => variable_get('adsense_ad_channel_'. $channel, ''),
+      '#size' => 30,
+      '#maxlength' => 30,
+    );
+  }
+
+  // advanced options
+  $form['advanced'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Advanced options'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+  $form['advanced']['adsense_disable'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Disable Google AdSense ads?'),
+    '#return_value' => 1,
+    '#default_value' => variable_get('adsense_disable', '0'),
+    '#description' => t('This disables all display of Google AdSense Ads from your web site. This is useful in certain situations, such as site upgrades, or if you make a copy of the site for development and test purposes.'),
+  );
+  $form['advanced']['adsense_placeholder'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Placeholder when ads are disabled?'),
+    '#return_value' => 1,
+    '#default_value' => variable_get('adsense_placeholder', '1'),
+    '#description' => t('This causes an empty box to be displayed in place of the ads when they are disabled.'),
+  );
+  $form['advanced']['adsense_placeholder_text'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Placeholder Text to display'),
+    '#default_value' => variable_get('adsense_placeholder_text', t('Google AdSense ad placeholder here')),
+    '#cols' => 70,
+    '#rows' => 5,
+    '#description' => t('Enter any text to display as a placeholder when ads are disabled.'),
+  );
+  $form['advanced']['adsense_page_ad_limit'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Ad limit per page'),
+    '#default_value' => variable_get('adsense_page_ad_limit', 3),
+    '#size' => 6,
+    '#maxlength' => 6,
+    '#description' => t('Google currently limits a page to 3 ad units'),
+  );
+  $form['advanced']['adsense_section_targeting'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enable Adsense Section targeting?'),
+    '#return_value' => 1,
+    '#default_value' => variable_get('adsense_section_targeting', 1),
+    '#description' => t('This better targets Google Ads to the teaser and body of nodes.'),
+  );
 
-  return $form_req . $form_type . $form_channel . $form_adv;
+  return $form;
 }  
 
 function adsense_display($format = '160x600', $group = 1, $channel = 1) {
