Index: wysiwyg.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg.admin.inc,v
retrieving revision 1.12
diff -u -p -r1.12 wysiwyg.admin.inc
--- wysiwyg.admin.inc	4 Jun 2009 22:31:15 -0000	1.12
+++ wysiwyg.admin.inc	8 Jun 2009 04:06:24 -0000
@@ -7,35 +7,7 @@
  */
 
 /**
- * Callback handler for admin pages; menu callback.
- *
- * @todo Move into hook_menu(), resp. FAPI functions.
- */
-function wysiwyg_admin($arg = '', $format = '') {
-  switch ($arg) {
-    case 'edit':
-      if ($profile = wysiwyg_load_profile($format)) {
-        $breadcrumb = array();
-        $breadcrumb[] = l(t('Home'), NULL);
-        $breadcrumb[] = l(t('Administer'), 'admin');
-        $breadcrumb[] = l(t('Site configuration'), 'admin/settings');
-        $breadcrumb[] = l(t('Wysiwyg profiles'), 'admin/settings/wysiwyg/profile');
-        drupal_set_breadcrumb($breadcrumb);
-        return drupal_get_form('wysiwyg_profile_form', $profile);
-      }
-      break;
-
-    case 'delete':
-      return drupal_get_form('wysiwyg_profile_delete_confirm', $format);
-
-    case '':
-      return drupal_get_form('wysiwyg_profile_overview');
-  }
-  drupal_goto('admin/settings/wysiwyg/profile');
-}
-
-/**
- * Return an HTML form for profile configuration.
+ * Form builder for Wysiwyg profile form.
  */
 function wysiwyg_profile_form($form_state, $profile) {
   // Merge in defaults.
@@ -75,7 +47,8 @@ function wysiwyg_profile_form($form_stat
   $profile = (object) $profile;
 
   $formats = filter_formats();
-  drupal_set_title(t('%format Wysiwyg profile', array('%format' => $formats[$profile->format]->name)));
+  $editor = wysiwyg_get_editor($profile->editor);
+  drupal_set_title(t('%editor profile for %format', array('%editor' => $editor['title'], '%format' => $formats[$profile->format]->name)));
 
   $form = array();
   $form['format'] = array('#type' => 'value', '#value' => $profile->format);
@@ -342,7 +315,7 @@ function wysiwyg_profile_form_submit($fo
 
   drupal_set_message(t('Wysiwyg profile for %format has been saved.', array('%format' => $input_format)));
 
-  drupal_goto('admin/settings/wysiwyg/profile');
+  drupal_goto('admin/settings/wysiwyg');
 }
 
 /**
@@ -419,7 +392,8 @@ function wysiwyg_profile_overview() {
   }
 
   $formats = filter_formats();
-  $profiles = wysiwyg_load_profile();
+  // @todo Add wysiwyg_load_all_profiles()
+  $profiles = wysiwyg_profile_load();
   $form['formats']['#tree'] = TRUE;
   foreach ($formats as $id => $format) {
     $form['formats'][$id]['name'] = array(
@@ -434,10 +408,10 @@ function wysiwyg_profile_overview() {
     );
     if (isset($profiles[$id]) && !empty($profiles[$id]->editor)) {
       $form['formats'][$id]['edit'] = array(
-        '#value' => l(t('Edit'), 'admin/settings/wysiwyg/profile/edit/'. $profiles[$id]->format),
+        '#value' => l(t('Edit'), "admin/settings/wysiwyg/profile/$id/edit"),
       );
       $form['formats'][$id]['remove'] = array(
-        '#value' => l(t('Remove'), 'admin/settings/wysiwyg/profile/delete/'. $profiles[$id]->format),
+        '#value' => l(t('Remove'), "admin/settings/wysiwyg/profile/$id/delete"),
       );
     }
   }
@@ -485,16 +459,15 @@ function wysiwyg_profile_overview_submit
 /**
  * Delete editor profile confirmation form.
  */
-function wysiwyg_profile_delete_confirm(&$form_state, $format) {
-  $form = array();
-  $form['format'] = array('#type' => 'value', '#value' => $format);
+function wysiwyg_profile_delete_confirm(&$form_state, $profile) {
   $formats = filter_formats();
-  $form['name'] = array('#type' => 'value', '#value' => $formats[$format]->name);
+  $format = $formats[$profile->format];
+  $form['format'] = array('#type' => 'value', '#value' => $format);
   return confirm_form(
     $form,
-    t('Are you sure you want to remove the profile for %name?', array('%name' => $formats[$format]->name)),
-    'admin/settings/wysiwyg/profile',
-    t('This action cannot be undone.'), t('Remove'), t('Cancel')
+    t('Are you sure you want to remove the profile for %name?', array('%name' => $format->name)),
+    'admin/settings/wysiwyg',
+    t('This action cannot be undone.'), t('Delete'), t('Cancel')
   );
 }
 
@@ -504,9 +477,10 @@ function wysiwyg_profile_delete_confirm(
  * @see wysiwyg_profile_delete_confirm()
  */
 function wysiwyg_profile_delete_confirm_submit($form, &$form_state) {
-  wysiwyg_profile_delete($form_state['values']['format']);
-  drupal_set_message(t('Wysiwyg profile for %name has been deleted.', array('%name' => $form_state['values']['name'])));
-  $form_state['redirect'] = 'admin/settings/wysiwyg/profile';
+  $format = $form_state['values']['format'];
+  wysiwyg_profile_delete($format->format);
+  drupal_set_message(t('Wysiwyg profile for %name has been deleted.', array('%name' => $format->name)));
+  $form_state['redirect'] = 'admin/settings/wysiwyg';
 }
 
 /**
Index: wysiwyg.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg.module,v
retrieving revision 1.31
diff -u -p -r1.31 wysiwyg.module
--- wysiwyg.module	7 Jun 2009 23:16:02 -0000	1.31
+++ wysiwyg.module	8 Jun 2009 04:04:11 -0000
@@ -10,14 +10,40 @@
  * Implementation of hook_menu().
  */
 function wysiwyg_menu() {
-  $items = array();
-  $items['admin/settings/wysiwyg/profile'] = array(
+  $items['admin/settings/wysiwyg'] = array(
     'title' => 'Wysiwyg',
-    'page callback' => 'wysiwyg_admin',
-    'description' => 'Configure client-side editor profiles.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('wysiwyg_profile_overview'),
+    'description' => 'Configure client-side editors.',
     'access arguments' => array('administer filters'),
     'file' => 'wysiwyg.admin.inc',
   );
+  $items['admin/settings/wysiwyg/profile'] = array(
+    'title' => 'Profiles',
+    'description' => 'Configure client-side editors.',
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+  );
+  $items['admin/settings/wysiwyg/profile/%wysiwyg_profile/edit'] = array(
+    'title' => 'Edit',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('wysiwyg_profile_form', 4),
+    'access arguments' => array('administer filters'),
+    'file' => 'wysiwyg.admin.inc',
+    'tab_root' => 'admin/settings/wysiwyg/profile',
+    'tab_parent' => 'admin/settings/wysiwyg/profile/%wysiwyg_profile',
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['admin/settings/wysiwyg/profile/%wysiwyg_profile/delete'] = array(
+    'title' => 'Delete',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('wysiwyg_profile_delete_confirm', 4),
+    'access arguments' => array('administer filters'),
+    'file' => 'wysiwyg.admin.inc',
+    'tab_root' => 'admin/settings/wysiwyg/profile',
+    'tab_parent' => 'admin/settings/wysiwyg/profile/%wysiwyg_profile',
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 10,
+  );
   $items['wysiwyg/%'] = array(
     'page callback' => 'wysiwyg_dialog',
     'page arguments' => array(1),
@@ -51,12 +77,9 @@ function wysiwyg_theme() {
  */
 function wysiwyg_help($path, $arg) {
   switch ($path) {
-    case 'admin/settings/wysiwyg/profile':
-      if (empty($arg[4])) {
-        $output = '<p>'. t('A Wysiwyg profile can be associated to an input format. A Wysiwyg profile defines which client-side editor is loaded, what buttons or themes are enabled for the editor, how the editor is displayed, and a few other editor-specific functions.') .'</p>';
-        return $output;
-      }
-      break;
+    case 'admin/settings/wysiwyg':
+      $output = '<p>'. t('A Wysiwyg profile can be associated to an input format. A Wysiwyg profile defines which client-side editor is loaded, what buttons or themes are enabled for the editor, how the editor is displayed, and a few other editor-specific functions.') .'</p>';
+      return $output;
   }
 }
 
@@ -187,7 +210,7 @@ function wysiwyg_process_form(&$form) {
  * @see wysiwyg_load_editor(), wysiwyg_get_editor()
  */
 function wysiwyg_get_profile($format) {
-  if ($profile = wysiwyg_load_profile($format)) {
+  if ($profile = wysiwyg_profile_load($format)) {
     if (wysiwyg_load_editor($profile)) {
       return $profile;
     }
@@ -539,21 +562,30 @@ function wysiwyg_get_css() {
 }
 
 /**
- * Load all profiles. Just load one profile if $name is passed in.
+ * Load all profiles or one profile if $format is passed in.
  */
-function wysiwyg_load_profile($format = '') {
+function wysiwyg_profile_load($format = NULL) {
   static $profiles;
 
-  if (!isset($profiles)) {
+  if (!empty($format)) {
+    if (!isset($profiles) || !array_key_exists($format, $profiles)) {
+      $result = db_query('SELECT format, editor, settings FROM {wysiwyg} WHERE format = %d', $format);
+      while ($profile = db_fetch_object($result)) {
+        $profile->settings = unserialize($profile->settings);
+        $profiles[$profile->format] = $profile;
+      }
+    }
+  }
+  elseif (!isset($profiles)) {
     $profiles = array();
-    $result = db_query('SELECT * FROM {wysiwyg}');
+    $result = db_query('SELECT format, editor, settings FROM {wysiwyg}');
     while ($profile = db_fetch_object($result)) {
       $profile->settings = unserialize($profile->settings);
       $profiles[$profile->format] = $profile;
     }
   }
 
-  return ($format && isset($profiles[$format]) ? $profiles[$format] : ($format ? FALSE : $profiles));
+  return ($format && !empty($profiles[$format]) ? $profiles[$format] : ($format ? FALSE : $profiles));
 }
 
 /**
