? htmlarea_port_to_6.patch
Index: htmlarea.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/htmlarea/htmlarea.info,v
retrieving revision 1.2
diff -u -p -r1.2 htmlarea.info
--- htmlarea.info	18 Jun 2007 23:55:34 -0000	1.2
+++ htmlarea.info	20 Nov 2008 20:25:22 -0000
@@ -2,3 +2,4 @@
 name = "HTMLArea"
 description = "Allows Drupal to use the htmlarea to replace textarea fields"
 
+core = 6.x
\ No newline at end of file
Index: htmlarea.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/htmlarea/htmlarea.module,v
retrieving revision 1.104
diff -u -p -r1.104 htmlarea.module
--- htmlarea.module	5 Jun 2007 01:27:51 -0000	1.104
+++ htmlarea.module	20 Nov 2008 20:25:24 -0000
@@ -1,9 +1,12 @@
 <?php
 // $Id: htmlarea.module,v 1.104 2007/06/05 01:27:51 gordon Exp $ $Name:  $
 
-function htmlarea_help($section) {
+/*
+ * Implementation of hook_help().
+ */
+function htmlarea_help($path, $arg) {
 
-  switch($section) {
+  switch ($path) {
     case "admin/settings/htmlarea":
       if (!_htmlarea_get_jsdir()) {
         $output = t('<p>Xinha/HTMLArea is not installed, download Xinha from <a href="http://xinha.python-hosting.com/wiki/DownloadsPage">http://xinha.python-hosting.com/wiki/DownloadsPage</a> (recommended), and install it into the htmlarea module directory.</p>');
@@ -50,84 +53,81 @@ function htmlarea_help($section) {
   return $output;
 }
 
-function htmlarea_menu($maycache) {
-  $items = array();
-  if ($maycache) {
-    $items[] = array(
-      'path' => 'admin/settings/htmlarea',
-      'title' => t('HTMLArea/Xinha'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => 'htmlarea_settings',
-      'access' => user_access('administer site configuration'), 
-      'description' => t('Configure HTMLArea/Xinha'),
-    );
-    $items[] = array(
-      'path' => 'admin/settings/htmlarea/main', 
-      'title' => t('htmlarea'),
-      'callback' => 'htmlarea_settings', 
-      'type' => MENU_DEFAULT_LOCAL_TASK, 
-      'weight' => -10,
-    );
-    $items[] = array(
-      'path' => 'admin/settings/htmlarea/toolbar', 
-      'title' => t('toolbar'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => 'htmlarea_settings_toolbar',
-      'type' => MENU_LOCAL_TASK, 
-      'weight' => -1,
-    );
-    $items[] = array(
-      'path' => 'admin/settings/htmlarea/plugins', 
-      'title' => t('plugins'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('htmlarea_settings_plugins'), 
-      'type' => MENU_LOCAL_TASK
-    );
-    $items[] = array(
-      'path' => 'admin/settings/htmlarea/plugins/select', 
-      'title' => t('select'),
-      'callback' => 'htmlarea_settings_plugins', 
-      'type' => MENU_DEFAULT_LOCAL_TASK,
-      'weight' => -10
-    );
-    $items[] = array(
-      'path' => 'admin/settings/htmlarea/fontnames', 
-      'title' => t('font names'),
-      'callback' => 'drupal_get_form', 
-      'callback arguments' => array('htmlarea_settings_array', 'fontnames'),
-      'type' => MENU_LOCAL_TASK
-    );
-    $items[] = array(
-      'path' => 'admin/settings/htmlarea/fontsize', 
-      'title' => t('font size'),
-      'callback' => 'drupal_get_form', 
-      'callback arguments' => array('htmlarea_settings_array', 'fontsize'),
-      'type' => MENU_LOCAL_TASK
-    );
-    $items[] = array(
-      'path' => 'admin/settings/htmlarea/formatblock', 
-      'title' => t('format block'),
-      'callback' => 'drupal_get_form', 
-      'callback arguments' => array('htmlarea_settings_array', 'formatblock'),
-      'type' => MENU_LOCAL_TASK
-    );
-    $items[] = array(
-      'path' => 'admin/settings/htmlarea/custom', 
-      'title' => t('custom js'),
-      'callback' => 'drupal_get_form', 
-      'callback arguments' => array('htmlarea_settings_custom'), 
-      'weight' => 10,
-      'type' => MENU_LOCAL_TASK
-    );
-  }
-  else {
-    $plugins = variable_get('htmlarea_plugins', array());
-    foreach ($plugins as $plugin => $a) {
-      if ($a['enable']) {
-        $items = array_merge($items, module_invoke_all('htmlarea_plugin', $a['name'], 'menu'));
-      }
+/**
+ * Implementation of hook_menu()
+ */
+function htmlarea_menu() {
+  $items['admin/settings/htmlarea'] = array(
+    'title' => 'HTMLArea/Xinha',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('htmlarea_settings'),
+    'access arguments' => array('administer site configuration'), 
+    'description' => 'Configure HTMLArea/Xinha',
+  );
+  $items['admin/settings/htmlarea/main'] = array(
+    'title' => 'htmlarea',
+    'page callback' => 'htmlarea_settings', 
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10,
+  );
+  $items['admin/settings/htmlarea/toolbar'] = array(
+    'title' => 'toolbar',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('htmlarea_settings_toolbar'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => -1,
+  );
+  $items['admin/settings/htmlarea/plugins'] = array(
+    'title' => 'plugins',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('htmlarea_settings_plugins'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_LOCAL_TASK
+  );
+  $items['admin/settings/htmlarea/plugins/select'] = array(
+    'title' => 'select',
+    'page callback' => 'htmlarea_settings_plugins', 
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10
+  );
+  $items['admin/settings/htmlarea/fontnames'] = array(
+    'title' => 'font names',
+    'page callback' => 'drupal_get_form', 
+    'page arguments' => array('htmlarea_settings_array', 3),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_LOCAL_TASK
+  );
+  $items['admin/settings/htmlarea/fontsize'] = array(
+    'title' => 'font size',
+    'page callback' => 'drupal_get_form', 
+    'page arguments' => array('htmlarea_settings_array', 3),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_LOCAL_TASK
+  );
+  $items['admin/settings/htmlarea/formatblock'] = array(
+    'title' => 'format block',
+    'page callback' => 'drupal_get_form', 
+    'page arguments' => array('htmlarea_settings_array', 3),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_LOCAL_TASK
+  );
+  $items['admin/settings/htmlarea/custom'] = array(
+    'title' => 'custom js',
+    'page callback' => 'drupal_get_form', 
+    'page arguments' => array('htmlarea_settings_custom'),
+    'access arguments' => array('administer site configuration'),
+    'weight' => 10,
+    'type' => MENU_LOCAL_TASK
+  );
+  
+  $plugins = variable_get('htmlarea_plugins', array());
+  foreach ($plugins as $plugin => $a) {
+    if ($a['enable']) {
+      $items = array_merge($items, module_invoke_all('htmlarea_plugin', $a['name'], 'menu'));
     }
   }
+
   return $items;
 }
 
@@ -185,22 +185,22 @@ function htmlarea_user($type, $edit, &$u
  * Implementation of hook_htmlarea_plugin()
  */
 function htmlarea_htmlarea_plugin($plugin, $op) {
-  switch($op) {
+  switch ($op) {
     case 'menu':
-      switch(strtolower($plugin)) {
+      switch (strtolower($plugin)) {
         case 'css':
-          $items[] = array('path' => 'admin/settings/htmlarea/plugins/' .strtolower($plugin),
-            'title' => t('css'),
-            'callback' => 'htmlarea_settings_plugins_css', 
-            'access' => user_access('administer site configuration'), 
+          $items['admin/settings/htmlarea/plugins/'. strtolower($plugin)] = array(
+            'title' => 'css',
+            'page callback' => 'htmlarea_settings_plugins_css', 
+            'access arguments' => array('administer site configuration'), 
             'type' => MENU_LOCAL_TASK);
           break;
         case 'help created':
-          $items[] = array('path' => 'admin/settings/htmlarea/plugins/' .strtolower($plugin),
-            'title' => t(strtolower($plugin)),
-            'callback' => 'htmlarea_settings_plugins_help', 
-            'callback arguments' => array($plugin),
-            'access' => user_access('administer site configuration'), 
+          $items['admin/settings/htmlarea/plugins/'. strtolower($plugin)] = array(
+            'title' => strtolower($plugin),
+            'page callback' => 'htmlarea_settings_plugins_help', 
+            'page arguments' => array($plugin),
+            'access arguments' => array('administer site configuration'), 
             'type' => MENU_LOCAL_TASK);
           break;
       }
@@ -208,33 +208,33 @@ function htmlarea_htmlarea_plugin($plugi
       break;
     case 'execute':
       unset($output);
-      switch(strtolower($plugin)) {
+      switch (strtolower($plugin)) {
         case 'css':
           $plugins = variable_get('htmlarea_plugins_css', array());
           $param = "  editor.registerPlugin('$plugin', {\n";
-          $param.= "    combos : [\n";
+          $param .= "    combos : [\n";
           $combos = array();
           foreach ($plugins as $k => $v) {
-            $temp = "      { label : \"" .$v['data'] ."\",\n";
-            $temp.= "        options : { \"&mdash; None &mdash;\" : \"\"";
+            $temp = "      { label : \"". $v['data'] ."\",\n";
+            $temp .= "        options : { \"&mdash; None &mdash;\" : \"\"";
             if (is_array($v['css']) && $v['css'] != array()) {
-              $temp.= ",\n";
+              $temp .= ",\n";
               $css = array();
               foreach ($v['css'] as $ck => $cv) {
-                $css[] = "          \"" .$cv['data'] ."\" : \"" .$cv['value'] ."\"";
+                $css[] = "          \"". $cv['data'] ."\" : \"". $cv['value'] ."\"";
               }
-              $temp.= implode(",\n", $css) ."\n";
+              $temp .= implode(",\n", $css) ."\n";
             }
-            $temp.= "        }";
+            $temp .= "        }";
             if ($v['context'] != "") {
-              $temp.= ",\n        context : \"" .$v['context'] ."\"\n";
+              $temp .= ",\n        context : \"". $v['context'] ."\"\n";
             }
-            $temp.= "\n      }";
+            $temp .= "\n      }";
             $combos[] = $temp;
           }
-          $param.= implode(",\n", $combos) ."\n";
-          $param.= "    ]\n";
-          $param.= "  });";
+          $param .= implode(",\n", $combos) ."\n";
+          $param .= "    ]\n";
+          $param .= "  });";
           $output[] = $param;
           break;
         case 'uploadimage':
@@ -256,22 +256,22 @@ function htmlarea_settings() {
     $form['html_area_filtertags'] = array(
       '#type' => 'item',
       '#title' => t('Filter HTML tags'),
-      '#value' => t('The Filter HTML Tags is Enabled, This conflicts with htmlarea. '). l(t('Please disable'), 'admin/system/filters'),
+      '#value' => t('The Filter HTML Tags is Enabled, This conflicts with htmlarea. ') . l(t('Please disable'), 'admin/system/filters'),
     );
   }
 
   $form['htmlarea_user_default'] = array(
     '#type' => 'checkbox',
     '#title' => t('Default for New Users'),
-    '#return_value' => true,
-    '#default_value' => variable_get('htmlarea_user_default', true),
+    '#return_value' => TRUE,
+    '#default_value' => variable_get('htmlarea_user_default', TRUE),
     '#description' => t('Default setting which determines if a new user will be allowed to use htmlarea'),
   );
   $form['htmlarea_killwordonpaste'] = array(
     '#type' => 'checkbox',
     '#title' => t('kill word on paste'),
-    '#return_value' => true,
-    '#default_value' => variable_get('htmlarea_killwordonpaste', false),
+    '#return_value' => TRUE,
+    '#default_value' => variable_get('htmlarea_killwordonpaste', FALSE),
     '#description' => t('This option configures htmlarea so that when pasting from word documents will clean up the word html'),
   );
   $form['htmlarea_add_rev'] = array(
@@ -300,7 +300,7 @@ function htmlarea_settings() {
     '#title' => t('Page Style'),
     '#default_value' => variable_get('htmlarea_bodystyle', ''),
     '#size' => 100,
-    '#maxlength' => 100,
+    '#maxlength' => 200,
     '#description' => t('Set the style of the htmlarea body'),
   );
 
@@ -331,10 +331,10 @@ function htmlarea_settings() {
 }
 
 function htmlarea_settings_toolbar() {
-  $toolbar = _htmlarea_build_toolbar(true);
+  $toolbar = _htmlarea_build_toolbar(TRUE);
   usort($toolbar, "_htmlarea_sort");
 
-  $form['htmlarea_toolbar'] = array('#tree' => TRUE,);
+  $form['htmlarea_toolbar'] = array('#tree' => TRUE);
   foreach ($toolbar as $k => $v) {
     if (!($v['enabled'] == 0 && ($v['data'] == 'space' || $v['data'] == 'separator' || $v['data'] == 'linebreak'))) {
       // display name
@@ -372,7 +372,7 @@ function theme_htmlarea_settings_toolbar
   foreach (element_children($form['htmlarea_toolbar']) as $key) {
     $row = array();
     if (is_array($form['htmlarea_toolbar'][$key]['desc'])) {
-      $row[] = drupal_render($form['htmlarea_toolbar'][$key]['desc']) . drupal_render($form['htmlarea_toolbar'][$key]['data']);
+      $row[] = drupal_render($form['htmlarea_toolbar'][$key]['desc']);
       $row[] = drupal_render($form['htmlarea_toolbar'][$key]['enabled']);
       $row[] = drupal_render($form['htmlarea_toolbar'][$key]['weight']);
     }
@@ -386,38 +386,40 @@ function theme_htmlarea_settings_toolbar
   return $output;
 }
 
-function htmlarea_settings_toolbar_submit($form_id, $form_values) {
+function htmlarea_settings_toolbar_submit($form, &$form_state) {
   $op = $_POST['op'];
   if ($op == t('Add separator')) {
-    $form_values['htmlarea_toolbar'][] = array('data' => 'separator', 'weight' => '-1', 'enabled' => '1');
-    $form_values['op'] = t('Save configuration');
+    $form_state['values']['htmlarea_toolbar'][] = array('data' => 'separator', 'weight' => '-1', 'enabled' => '1');
+/* TODO The 'op' element in the form values is deprecated.
+   Each button can have #validate and #submit functions associated with it.
+   Thus, there should be one button that submits the form and which invokes
+   the normal form_id_validate and form_id_submit handlers. Any additional
+   buttons which need to invoke different validate or submit functionality
+   should have button-specific functions. */
+    $form_state['values']['op'] = t('Save configuration');
   }
   elseif ($op == t('Add space')) {
-    $form_values['htmlarea_toolbar'][] = array('data' => 'space', 'weight' => '-1', 'enabled' => '1');
-    $form_values['op'] = t('Save configuration');
+    $form_state['values']['htmlarea_toolbar'][] = array('data' => 'space', 'weight' => '-1', 'enabled' => '1');
+    $form_state['values']['op'] = t('Save configuration');
   }
   elseif ($op == t('Add linebreak')) {
-    $form_values['htmlarea_toolbar'][] = array('data' => 'linebreak', 'weight' => '-1', 'enabled' => '1');
-    $form_values['op'] = t('Save configuration');
+    $form_state['values']['htmlarea_toolbar'][] = array('data' => 'linebreak', 'weight' => '-1', 'enabled' => '1');
+    $form_state['values']['op'] = t('Save configuration');
   }
 
-  system_settings_form_submit($form_id, $form_values);
+  system_settings_form_submit($form_state['values']['form_id'], $form_state);
   drupal_goto('admin/settings/htmlarea/toolbar');
 }
 
 function htmlarea_settings_plugins() {
   // build list of plugins
-  $files = array_merge(file_scan_directory(_htmlarea_get_jsdir() . '/plugins', '.*', array('.', '..', 'CVS', '.svn'), 0, false), file_scan_directory(drupal_get_path('module', 'htmlarea') . '/plugins', '.*', array('.', '..', 'CVS', '.svn'), 0, false));
+  $files = array_merge(file_scan_directory(_htmlarea_get_jsdir() .'/plugins', '.*', array('.', '..', 'CVS', '.svn'), 0, FALSE), file_scan_directory(drupal_get_path('module', 'htmlarea') .'/plugins', '.*', array('.', '..', 'CVS', '.svn'), 0, FALSE));
   usort($files, '_htmlarea_sort_plugins');
   $plugins = variable_get('htmlarea_plugins', array());
 
-  $form['htmlarea_plugins'] = array('#tree' => TRUE,);
+  $form['htmlarea_plugins'] = array('#tree' => TRUE);
+
   foreach ($files as $f) {
-    // display name
-    $form['htmlarea_plugins'][$f->filename]['desc'] = array(
-      '#type' => 'item',
-      '#value' => $f->basename,
-    );
     // name saved with the enable setting
     $form['htmlarea_plugins'][$f->filename]['name'] = array(
       '#type' => 'value',
@@ -426,6 +428,7 @@ function htmlarea_settings_plugins() {
     // enable checkbox
     $form['htmlarea_plugins'][$f->filename]['enable'] = array(
       '#type' => 'checkbox',
+      '#title' => $f->basename,
       '#default_value' => $plugins[$f->filename]['enable'],
       '#return_value' => 1,
     );
@@ -442,7 +445,6 @@ function theme_htmlarea_settings_plugins
   foreach (element_children($form['htmlarea_plugins']) as $key) {
     $row = array();
     if (is_array($form['htmlarea_plugins'][$key]['desc'])) {
-      $row[] = drupal_render($form['htmlarea_plugins'][$key]['desc']) . drupal_render($form['htmlarea_plugins'][$key]['name']);
       $row[] = drupal_render($form['htmlarea_plugins'][$key]['enable']);
     }
     $rows[] = $row;
@@ -459,14 +461,14 @@ function theme_htmlarea_settings_plugins
  * Save the plugins settings, we can't use system_settings_form_submit() as the
  * form callback because it wouldn't call theme_htmlarea_settings_plugins().
  */
-function htmlarea_settings_plugins_submit($form_id, $form_values) {
-  system_settings_form_submit($form_id, $form_values);
+function htmlarea_settings_plugins_submit($form, &$form_state) {
+  system_settings_form_submit($form_state['values']['form_id'], $form_state['values']);
   drupal_goto('admin/settings/htmlarea/plugins');
 }
 
 function htmlarea_settings_plugins_css() {
   $edit = $_POST['edit'];
-  if($edit) {
+  if ($edit) {
     foreach ($edit["htmlarea_plugins_css"] as $k => $v) {
       if ($v['delete'] == '1' || $v['data'] == '') {
         unset($_POST['edit']["htmlarea_plugins_css"][$k]);
@@ -502,22 +504,22 @@ function htmlarea_settings_plugins_css()
     }
     $ck = count($v['css'])+1;
     $rows_css[] = array(array('data' => form_textfield('', "htmlarea_plugins_css][$k][css][$ck][data", "", 30, 30)), array('data' => form_textfield('', "htmlarea_plugins_css][$k][css][$ck][value", '', 30, 30)), array('data' => form_weight('', "htmlarea_plugins_css][$k][css][$ck][weight", 0)), array('data' => '&nbsp'));
-    $output.= form_item($v['data'], theme("table", $header_css, $rows_css));
+    $output .= form_item($v['data'], theme("table", $header_css, $rows_css));
   }
   $k = count($plugins)+1;
   $rows[] = array(array('data' => form_textfield('', "htmlarea_plugins_css][$k][data", "", 30, 30)), array('data' => form_textfield('', "htmlarea_plugins_css][$k][context", "", 30, 30)), array('data' => form_weight('', "htmlarea_plugins_css][$k][weight")), array('data' => '&nbsp;'));
   $output = form_item('', theme("table", $header, $rows), t("list of
-  different drop boxes that will be added to the toolbar")) .$output;
+  different drop boxes that will be added to the toolbar")) . $output;
   
   print theme("page", system_settings_form($output));
 }
 
-function htmlarea_settings_plugins_help($plugin) {
+function htmlarea_settings_plugins_help(&$form_state, $plugin) {
   print theme("page", "");
 }
 
-function htmlarea_settings_array($arg) {
-  switch($arg) {
+function htmlarea_settings_array($arg1, $arg) {
+  switch ($arg) {
     case "fontnames":
       $header_data = t('font name');
       $header_value = t('font family');
@@ -540,25 +542,23 @@ function htmlarea_settings_array($arg) {
   // add blank last row
   $data[] = array('data' => '', 'value' => '', 'weight' => '');
 
-  $form['htmlarea_' . $arg] = array('#tree' => TRUE,);
+  $form['htmlarea_'. $arg] = array('#tree' => TRUE);
   foreach ($data as $k => $v) {
-    $form['htmlarea_' . $arg][$k]['data'] = array(
+    $form['htmlarea_'. $arg][$k]['data'] = array(
       '#type' => 'textfield',
       '#default_value' => $v['data'],
       '#size' => 20,
-      '#maxlength' => 20,
     );
-    $form['htmlarea_' . $arg][$k]['value'] = array(
+    $form['htmlarea_'. $arg][$k]['value'] = array(
       '#type' => 'textfield',
       '#default_value' => $v['value'],
       '#size' => 20,
-      '#maxlength' => 20,
     );
-    $form['htmlarea_' . $arg][$k]['weight'] = array(
+    $form['htmlarea_'. $arg][$k]['weight'] = array(
       '#type' => 'weight',
       '#default_value' => $v['weight'],
     );
-    $form['htmlarea_' . $arg][$k]['delete'] = array(
+    $form['htmlarea_'. $arg][$k]['delete'] = array(
       '#type' => 'checkbox',
       '#return_value' => 1,
       '#default_value' => 0,
@@ -568,22 +568,16 @@ function htmlarea_settings_array($arg) {
   $form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults') );
 
   $form['args'] = array('#tree' => TRUE);
-  $form['args']['name'] = array(
-    '#type' => 'value',
-    '#value' => $arg,
-  );
-  $form['args']['header'] = array(
-    '#type' => 'value',
-    '#value' => array($header_data, $header_value, t('weight'), t('delete')),
-  );
+  $form['args']['#name'] = $arg;
+  $form['args']['#header'] = array($header_data, $header_value, t('weight'), t('delete'));
 
   return $form;
 }
 
 function theme_htmlarea_settings_array(&$form) {
-  if (isset($form['args']['name']['#value'])) {
-    $var = 'htmlarea_' . $form['args']['name']['#value'];
-    $header = $form['args']['header']['#value'];
+  if (isset($form['args']['#name'])) {
+    $var = 'htmlarea_'. $form['args']['#name'];
+    $header = $form['args']['#header'];
 
     foreach (element_children($form[$var]) as $key) {
       $row = array();
@@ -602,19 +596,19 @@ function theme_htmlarea_settings_array(&
   return $output;
 }
 
-function htmlarea_settings_array_submit($form_id, $form_values) {
+function htmlarea_settings_array_submit($form, &$form_state) {
   // unset any thing that was deleted
-  $arg = $form_values['args']['name'];
-  foreach ($form_values['htmlarea_' . $arg] as $k => $v) {
+  $arg = $form['args']['#name'];
+  foreach ($form_state['values']['htmlarea_'. $arg] as $k => $v) {
     if ($v['delete'] == '1' || $v['data'] == '') {
-      unset($form_values['htmlarea_' . $arg][$k]);
+      unset($form_state['values']['htmlarea_'. $arg][$k]);
     }
   }
   // remove our temp values
-  unset($form_values['args']);
+  unset($form_state['values']['args']);
 
-  system_settings_form_submit($form_id, $form_values);
-  drupal_goto('admin/settings/htmlarea/' . $arg);
+  system_settings_form_submit($form_state['values']['form_id'], $form_state);
+  drupal_goto('admin/settings/htmlarea/'. $arg);
 }
 
 function htmlarea_settings_custom() {
@@ -630,6 +624,34 @@ function htmlarea_settings_custom() {
 }
 
 /*
+ * Implementation of hook_theme().
+ */
+function htmlarea_theme() {
+  return array(
+    'htmlarea_settings_toolbar' => array(
+      'arguments' => array('form' => NULL)
+    ),
+    'htmlarea_settings_plugins' => array(
+      'arguments' => array('form' => NULL)
+    ),
+    'htmlarea_settings_array' => array(
+      'arguments' => array('form' => NULL)
+    )
+  );
+}
+
+/**
+ * Implementation of hook_form_alter().
+ */
+function htmlarea_form_alter(&$form, &$form_state) {
+  // Disable 'teaser' textarea.
+  if (isset($form['body_field'])) {
+    unset($form['body_field']['teaser_js']);
+    $form['body_field']['teaser_include'] = array();
+  }
+}
+
+/*
  * Internal Functions
  */
 
@@ -657,9 +679,9 @@ function _htmlarea_load_editor() {
     drupal_add_css(drupal_get_path('module', 'htmlarea') .'/htmlarea.css');
     $settings['htmlarea'] = array(
       'base' => base_path(),
-      'path' => base_path() ._htmlarea_get_jsdir(),
-      'use_xinha' => file_exists(_htmlarea_get_jsdir(). '/XinhaCore.js'),
-      'killWordOnPaste' => variable_get("htmlarea_killwordonpaste", false),
+      'path' => base_path() . _htmlarea_get_jsdir(),
+      'use_xinha' => file_exists(_htmlarea_get_jsdir() .'/XinhaCore.js'),
+      'killWordOnPaste' => variable_get("htmlarea_killwordonpaste", FALSE),
       'pageStyle' => variable_get("htmlarea_bodystyle", ""),
       'toolbar' => array(),
     );
@@ -671,7 +693,7 @@ function _htmlarea_load_editor() {
           foreach ($type as $method => $css) {
             foreach ($css as $style => $enabled) {
               if ($enabled) {
-                $styles[] = base_path(). $style;
+                $styles[] = base_path() . $style;
               }
             }
           }
@@ -680,7 +702,7 @@ function _htmlarea_load_editor() {
       $settings['htmlarea']['styles'] = $styles;
     }
 
-    $toolbar = _htmlarea_build_toolbar(false);
+    $toolbar = _htmlarea_build_toolbar(FALSE);
     $toolbar = array_filter($toolbar, '_htmlarea_filter_toolbar');
 
     $buttons = array();
@@ -734,15 +756,16 @@ function _htmlarea_load_editor() {
       drupal_add_js(_htmlarea_get_jsdir() .'/htmlarea.js', 'module', 'footer');
     }
     
-    if ($plugins = variable_get('htmlarea_plugins', NULL)) {
-      foreach ($plugins as $d => $a) {
+    if ($plugin_list = variable_get('htmlarea_plugins', NULL)) {
+      $plugins = array();
+      foreach ($plugin_list as $d => $a) {
         if ($a['enable']) {
           $plugins[] = $a['name'];
           $plugin = strtolower(preg_replace_callback('/([a-z])([A-Z])([a-z])/', '_htmlarea_plugin_preg', $a['name']));
-          $filename = $d .'/' .$plugin .".js";
+          $filename = $d .'/'. $plugin .".js";
           if (file_exists($filename)) {
             drupal_add_js($filename, 'module', 'footer');
-            $filename = $d .'/lang/' ._htmlarea_lang() .'.js';
+            $filename = $d .'/lang/'. _htmlarea_lang() .'.js';
             if (file_exists($filename)) {
               drupal_add_js($filename, 'module', 'footer');
             }
@@ -771,7 +794,7 @@ function _htmlarea_filter_toolbar($a) {
 function _htmlarea_defaults($field) {
   global $htmlarea_codeview, $base_url;
 
-  switch($field) {
+  switch ($field) {
     case "options":
       return array(
         array("data" => "fontname", "weight" => "0", "enabled" => "0"), 
@@ -855,13 +878,13 @@ function _htmlarea_defaults($field) {
     }
 }
 
-function _htmlarea_build_toolbar($cfg = false) {
+function _htmlarea_build_toolbar($cfg = FALSE) {
   $toolbar = variable_get("htmlarea_toolbar", NULL);
   if (!$toolbar) {
     $toolbar = _htmlarea_calc_weights(_htmlarea_defaults('options'));
   }
   elseif ($cfg) {
-    $icons = array(); $calcweights = false;
+    $icons = array(); $calcweights = FALSE;
     foreach ($toolbar as $item) {
       $icons[] = $item['data'];
     }
@@ -871,7 +894,7 @@ function _htmlarea_build_toolbar($cfg = 
           $item['data'] != 'separator' &&
           !in_array($item['data'], $icons)) {
         $toolbar[] = $item;
-        $calcweights = true;
+        $calcweights = TRUE;
       }
     }
     if ($calcweights) {
@@ -882,9 +905,9 @@ function _htmlarea_build_toolbar($cfg = 
 }
 
 function _htmlarea_calc_weights($toolbar, $weight = 0) {
-  $last = null;
+  $last = NULL;
   foreach ($toolbar as $k => $v) {
-    if ($last != null && strcmp($last, $v['data']) > 0) {
+    if ($last != NULL && strcmp($last, $v['data']) > 0) {
       $weight++;
     }
     $last = $v['data'];
@@ -900,8 +923,8 @@ function _htmlarea_is_changed($name = ''
   global $user;
   static $textarea;
 
-  if (_htmlarea_bad_browser() || (isset($user->htmlarea_isenabled) && $user->htmlarea_isenabled == 0) || (!isset($user->htmlarea_isenabled) && !variable_get("htmlarea_user_default", true)) || !_htmlarea_get_jsdir()) {
-    return false;
+  if (_htmlarea_bad_browser() || (isset($user->htmlarea_isenabled) && $user->htmlarea_isenabled == 0) || (!isset($user->htmlarea_isenabled) && !variable_get("htmlarea_user_default", TRUE)) || !_htmlarea_get_jsdir()) {
+    return FALSE;
   }
   $path = drupal_get_path_alias($_GET['q']) .'.';
   if ($name != '') {
@@ -909,12 +932,12 @@ function _htmlarea_is_changed($name = ''
     $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. variable_get('site_frontpage', 'node') .'\2'), preg_quote(variable_get('htmlarea_display', "admin/*"), '/')) .')$/';
     $ret = !(variable_get('htmlarea_visibility', 0) xor preg_match($regexp, $path));
     if ($ret) {
-      $textarea = true;
+      $textarea = TRUE;
     } 
     return $ret;
   }
   else {
-    return $textarea ? true : false;
+    return $textarea ? TRUE : FALSE;
   }
 }
 
@@ -922,20 +945,20 @@ function _htmlarea_lang() {
   global $user;
   if (module_exists('locale')) {
     if ($user->language) {
-      if (file_exists(_htmlarea_get_jsdir()."/lang/$user->language.js")) {
+      if (file_exists(_htmlarea_get_jsdir() ."/lang/$user->language.js")) {
         return $user->language;
       }
     }
     elseif (module_exists('i18n')) {
       $ulang = _i18n_get_lang();
-      if (file_exists(_htmlarea_get_jsdir()."/lang/$ulang.js")) {
+      if (file_exists(_htmlarea_get_jsdir() ."/lang/$ulang.js")) {
         return $ulang;
       }
     }
     else {
       $langs = (locale_supported_languages());
       $ulang = key($langs['name']);
-      if (file_exists(_htmlarea_get_jsdir()."/lang/$ulang.js")) {
+      if (file_exists(_htmlarea_get_jsdir() ."/lang/$ulang.js")) {
         return $ulang;
       }
     }
@@ -944,7 +967,7 @@ function _htmlarea_lang() {
 }
 
 function _htmlarea_plugin_preg($m) {
-  return $m[1] .'-' .$m[2]. $m[3];
+  return $m[1] .'-'. $m[2] . $m[3];
 }
 
 function _htmlarea_sort($a, $b) {
@@ -955,20 +978,17 @@ function _htmlarea_sort_plugins($a, $b) 
   return strcmp($a->basename, $b->basename);
 }
 
-// This is a temporary function to get around a bug in htmlarea 3.0beta
-// which will crash IE5.00 browsers
-
+/* This is a temporary function to get around a bug in htmlarea 3.0beta
+ * which will crash IE5.00 browsers
+ */
 function _htmlarea_bad_browser() {
-
   if (strpos($_SERVER['HTTP_USER_AGENT'], "Safari")) {
-    return true;
+    return TRUE;
   }
 
   if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE 5.0")) {
-    return true;
+    return TRUE;
   }
 
-  return false;
-}
-
-?>
+  return FALSE;
+}
\ No newline at end of file
Index: start_drupal.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/htmlarea/start_drupal.inc,v
retrieving revision 1.3
diff -u -p -r1.3 start_drupal.inc
--- start_drupal.inc	3 Sep 2005 05:41:44 -0000	1.3
+++ start_drupal.inc	20 Nov 2008 20:25:24 -0000
@@ -1,7 +1,6 @@
 <?php
-/*
-* $Id: start_drupal.inc,v 1.3 2005/09/03 05:41:44 gordon Exp $
-*/
+// $Id: start_drupal.inc,v 1.3 2005/09/03 05:41:44 gordon Exp $
+
 chdir('../../../../../'); /* We need to go to the root drupal directory so that 
                              we can include the drupal includes and have full 
                              access to the api and database. */ 
@@ -12,8 +11,7 @@ if (!file_exists('includes/bootstrap.inc
   chdir('..');
   $_SERVER['PHP_SELF'] = substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'));
 }
-$_SERVER['PHP_SELF'] = dirname($_SERVER['PHP_SELF']) .(dirname($_SERVER['PHP_SELF']) == "/" ? "" : "/") ."index.php";
+$_SERVER['PHP_SELF'] = dirname($_SERVER['PHP_SELF']) . (dirname($_SERVER['PHP_SELF']) == "/" ? "" : "/") ."index.php";
 
-require_once('includes/bootstrap.inc'); 
-drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
-?>
+module_load_include('nc', 'start_drupal', ''); 
+drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
\ No newline at end of file
