Index: taxonomy_image.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/taxonomy_image/taxonomy_image.module,v
retrieving revision 1.11
diff -u -r1.11 taxonomy_image.module
--- taxonomy_image.module	28 Aug 2005 18:23:25 -0000	1.11
+++ taxonomy_image.module	18 Feb 2006 07:39:26 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: taxonomy_image.module
+// $Id$ taxonomy_image.module
 
 /*
 ** taxonomy_image.module:
@@ -153,31 +153,87 @@
   return $items;
 }
 
+/**
+ * Implementation of hook_user().
+ */
 function taxonomy_image_user($type, $edit, $user) {
   switch ($type) {
-    case 'edit_form':
+    case 'form':
       if (user_access('can disable taxonomy images')) {
-        $form = form_checkbox(t('Disable images'), 'taxonomy_image_disable_images', 1, $user->taxonomy_image_disable_images, t('Check this box to disable the display of content images.'));
-        return array(t('Content images') => $form);
+        $form['content_images'] = array(
+          '#type' => 'fieldset',
+          '#title' => t('Content images'),
+        );
+        $form['content_images']['taxonomy_image_disable_images'] = array(
+          '#type' => 'checkbox',
+          '#title' => t('Disable images'),
+          '#return_value' => 1,
+          '#default_value' => $user->taxonomy_image_disable_images,
+          '#description' => t('Check this box to disable the display of content images.'),
+        );
+        return $form;
       }
       break;
   }
 }
 
+/**
+ * Implementation of hook_settings().
+ */
 function taxonomy_image_settings() {
   if (!file_check_directory(file_create_path(variable_get('taxonomy_image_path', 'category_pictures')), FILE_CREATE_DIRECTORY)) {
     $error = theme('error', t('The picture directory does not exist, or is not writable.'));
   }
 
-  $group .= form_textfield(t('Picture image path'), 'taxonomy_image_path', variable_get('taxonomy_image_path', 'category_pictures'), 45, 255, t('Subdirectory in the directory "%dir" where category pictures will be stored.', array('%dir' => variable_get('file_directory_path', 'files') . '/')) . $error);
-  $group .= form_radios(t('Picture resize'), 'taxonomy_image_resize', variable_get('taxonomy_image_resize', 0), array(3 => 'Exact', 2 => 'Not less than', 1 => 'Not greater than', 0 => 'Disabled'), t('This option allows you to control the size of pictures displayed by this module.  If set to \'disabled\', pictures will not be resized, displayed exactly as they are uploaded.  If set to \'not greater than\', pictures larger than the specified size will be scaled down.  If set to \'not less than\', pictures smaller than the specified size will be scaled up.  If set to \'exact\', pictures will be resized to exactly the specified dimension(s).'));
-  $group .= form_textfield(t('Picture height'), 'taxonomy_image_height', variable_get('taxonomy_image_height', ''), 5, 6, t('Specify a height in pixels.  If left blank or set to 0 this field is ignored.'));
-  $group .= form_textfield(t('Picture width'), 'taxonomy_image_width', variable_get('taxonomy_image_width', ''), 5, 6, t('Specify a width in pixels.  If left blank or set to 0 this field is ignored.'));
-  $output = form_group(t('Pictures'), $group);
+  $form['pictures'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Pictures'),
+  );
+  $form['pictures']['taxonomy_image_path'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Picture image path'),
+    '#default_value' => variable_get('taxonomy_image_path', 'category_pictures'),
+    '#size' => 45,
+    '#maxlength' => 255,
+    '#description' => t('Subdirectory in the directory "%dir" where category pictures will be stored.', array('%dir' => variable_get('file_directory_path', 'files') . '/')) . $error,
+  );
+  $form['pictures']['taxonomy_image_resize'] = array(
+    '#type' => 'radios',
+    '#title' => t('Picture resize'),
+    '#default_value' => variable_get('taxonomy_image_resize', 0),
+    '#options' => array(3 => 'Exact', 2 => 'Not less than', 1 => 'Not greater than', 0 => 'Disabled'),
+    '#description' => t('This option allows you to control the size of pictures displayed by this module.  If set to \'disabled\', pictures will not be resized, displayed exactly as they are uploaded.  If set to \'not greater than\', pictures larger than the specified size will be scaled down.  If set to \'not less than\', pictures smaller than the specified size will be scaled up.  If set to \'exact\', pictures will be resized to exactly the specified dimension(s).'),
+  );
+  $form['pictures']['taxonomy_image_height'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Picture height'),
+    '#default_value' => variable_get('taxonomy_image_height', ''),
+    '#size' => 5,
+    '#maxlength' => 6,
+    '#description' => t('Specify a height in pixels.  If left blank or set to 0 this field is ignored.'),
+  );
+  $form['pictures']['taxonomy_image_width'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Picture width'),
+    '#default_value' => variable_get('taxonomy_image_width', ''),
+    '#size' => 5,
+    '#maxlength' => 6,
+    '#description' => t('Specify a width in pixels.  If left blank or set to 0 this field is ignored.'),
+  );
+
+  $form['advanced'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Advanced'),
+  );
+  $form['advanced']['taxonomy_image_recursive'] = array(
+    '#type' => 'radios',
+    '#title' => t('Recursive image display'),
+    '#default_value' => variable_get('taxonomy_image_recursive', 0),
+    '#options' => array(1 => 'Enabled', 0 => 'Disabled'),
+    '#description' => t('When enabled, taxonomy_image_display() will recursively search for an image to display, starting with the passed in term, then trying the term\'s parents.  This functionality is only useful if you have defined hierarchical taxonomies, and multiple terms within a tree will share the same image.  If this doesn\'t mean anything to you, leave this option disabled.'),
+  );
 
-  $group = form_radios(t('Recursive image display'), 'taxonomy_image_recursive', variable_get('taxonomy_image_recursive', 0), array(1 => 'Enabled', 0 => 'Disabled'), t('When enabled, taxonomy_image_display() will recursively search for an image to display, starting with the passed in term, then trying the term\'s parents.  This functionality is only useful if you have defined hierarchical taxonomies, and multiple terms within a tree will share the same image.  If this doesn\'t mean anything to you, leave this option disabled.'));
-  $output .= form_group(t('Advanced'), $group);
-  return $output;
+  return $form;
 }
 
 function taxonomy_image_file_download($file) {
@@ -225,7 +281,7 @@
   switch ($op) {
     case 'image':
       if (arg(3) == 'add' || arg(3) == 'edit') { 
-        $output = taxonomy_image_form(object2array(taxonomy_image_get_term(arg(4))));
+        $output = taxonomy_image_form((array)(taxonomy_image_get_term(arg(4))));
         break;
       }
       $output = taxonomy_image_overview();
@@ -286,24 +342,46 @@
 
 function taxonomy_image_form($edit = array()) {
 
-  unset ($form);
+  $form['#method'] = 'post';
+  $form['#action'] = 0;
+  $form['#attributes'] = array('enctype' => 'multipart/form-data');
 
   // A path may be set when the image doesn't exist if using recursion
   if (!is_null($edit['path']) && _taxonomy_image_exists($edit['tid'])) {
     $group = taxonomy_image_display($edit['tid']) .'<br />';
-    $group .= form_submit(t('Delete'));
-    $form = form_group(t('Current image'), $group);
+    $form['current_image'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Current Image'),
+    );
+    $form['current_image']['delete'] = array(
+      '#type' => 'submit',
+      '#value' => t('Delete'),
+    );
     drupal_set_title(t('Edit image'));
   }
-
-  $group = form_file(t('Taxonomy image file'), 'path', 40, t('The image file you wish to associate with the \'%term\' term.', array('%term' => $edit['name'])));
-  $group .= form_submit(t('Save'));
+  
+  $form['new_image'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Upload new image'),
+  );
+  $form['new_image']['path'] = array(
+    '#type' => 'file',
+    '#title' => t('Taxonomy image file'),
+    '#size' => 40,
+    '#description' => t("The image file you wish to associate with the '%term' term.", array('%term' => $edit['name'])),
+  );
+  $form['new_image']['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save'),
+  );
   if (!is_null($edit['tid'])) {
-    $group .= form_hidden('tid', $edit['tid']);
+    $form['new_image']['tid'] = array(
+      '#type' => 'hidden',
+      '#value' => $edit['tid'],
+    );
   }
-  $form .= form_group(t('Upload new image'), $group);
 
-  return form($form, 'post', 0, array('enctype' => 'multipart/form-data'));
+  return drupal_get_form('taxonomy_image_form', $form);
 }
 
 function taxonomy_image_save($edit) {
