diff --git a/editors/ckeditor.inc b/editors/ckeditor.inc index 8489512..02ea171 100644 --- a/editors/ckeditor.inc +++ b/editors/ckeditor.inc @@ -185,53 +185,70 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) { if (isset($config['toolbar_loc'])) { $settings['toolbarLocation'] = $config['toolbar_loc']; } + + $extra_plugins = array(); + $toolbar = array(); + $plugins = wysiwyg_get_plugins($editor['name']); + + foreach ((array)$config['extensions'] as $plugin => $buttons) { + foreach ($buttons as $button => $enabled) { + if (!isset($plugins[$plugin]['extensions'][$button])) { + continue; + } - if (!empty($config['buttons'])) { - $extra_plugins = array(); - $settings['toolbar'] = array(); - $plugins = wysiwyg_get_plugins($editor['name']); - foreach ($config['buttons'] as $plugin => $buttons) { - foreach ($buttons as $button => $enabled) { - // Iterate separately over buttons and extensions properties. - foreach (array('buttons', 'extensions') as $type) { - // Skip unavailable plugins. - if (!isset($plugins[$plugin][$type][$button])) { - continue; - } - // Add buttons. - if ($type == 'buttons') { - $settings['toolbar'][] = $button; - } - // Add external Drupal plugins to the list of extensions. - if ($type == 'buttons' && !empty($plugins[$plugin]['proxy'])) { - $extra_plugins[] = $button; - } - // Add external plugins to the list of extensions. - elseif ($type == 'buttons' && empty($plugins[$plugin]['internal'])) { - $extra_plugins[] = $plugin; - } - // Add internal buttons that also need to be loaded as extension. - elseif ($type == 'buttons' && !empty($plugins[$plugin]['load'])) { - $extra_plugins[] = $plugin; - } - // Add plain extensions. - elseif ($type == 'extensions' && !empty($plugins[$plugin]['load'])) { - $extra_plugins[] = $plugin; - } - // Allow plugins to add or override global configuration settings. - if (!empty($plugins[$plugin]['options'])) { - $settings = array_merge($settings, $plugins[$plugin]['options']); - } - } + // Add plain extensions. + if (!empty($plugins[$plugin]['load'])) { + $extra_plugins[] = $plugin; + } + + // Allow plugins to add or override global configuration settings. + if (!empty($plugins[$plugin]['options'])) { + $settings = array_merge($settings, $plugins[$plugin]['options']); } } - if (!empty($extra_plugins)) { - $settings['extraPlugins'] = implode(',', $extra_plugins); - } - // For now, all buttons are placed into one row. - if (!empty($settings['toolbar'])) { - $settings['toolbar'] = array($settings['toolbar']); + } + + foreach ((array)$config['toolbar'] as $buttons) { + $group = array(); + + foreach ($buttons as $buttonConfig) { + $plugin = $buttonConfig['plugin']; + $button = $buttonConfig['button']; + + if ($button == WYSIWYG_SEPARATOR) { + $group[] = '-'; + continue; + } + if (!isset($plugins[$plugin]['buttons'][$button])) { + continue; + } + + $group[] = $button; + + // Add external Drupal plugins to the list of extensions. + if (!empty($plugins[$plugin]['proxy']) || empty($plugins[$plugin]['internal']) || !empty($plugins[$plugin]['load'])) { + $extra_plugins[] = $button; + } + + // Allow plugins to add or override global configuration settings. + if (!empty($plugins[$plugin]['options'])) { + $settings = array_merge($settings, $plugins[$plugin]['options']); + } } + + $toolbar[] = $group; + $toolbar[] = '/'; // toolbar line break + } + + // remove the last '/' + if (end($toolbar) == '/') array_pop($toolbar); + + if (!empty($extra_plugins)) { + $settings['extraPlugins'] = implode(',', array_unique($extra_plugins)); + } + + if (!empty($toolbar)) { + $settings['toolbar'] = $toolbar; } return $settings; diff --git a/editors/tinymce.inc b/editors/tinymce.inc index 12c4fd6..7e47691 100644 --- a/editors/tinymce.inc +++ b/editors/tinymce.inc @@ -192,71 +192,82 @@ function wysiwyg_tinymce_settings($editor, $config, $theme) { $settings['content_css'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())); } } + + $plugins = wysiwyg_get_plugins($editor['name']); + $settings['extended_valid_elements'] = array(); + $toolbar = array(); + $extensions = array(); + + foreach ((array)$config['extensions'] as $plugin => $buttons) { + foreach ($buttons as $button => $enabled) { + if (!isset($plugins[$plugin],$plugins[$plugin]['extensions'],$plugins[$plugin]['extensions'][$button])) { + continue; + } - // Find the enabled buttons and the button row they belong on. - // Also map the plugin metadata for each button. - // @todo What follows is a pain; needs a rewrite. - if (!empty($config['buttons']) && is_array($config['buttons'])) { - // $settings['buttons'] are stacked into - // $settings['theme_advanced_buttons1'] later. - // @todo Add a toolbar designer based on jQuery UI. - $settings['buttons'] = array(); - // Only array keys in $settings['extensions'] matter; added to - // $settings['plugins'] later. - $settings['extensions'] = array(); - // $settings['extended_valid_elements'] are just stacked, unique'd later, - // and transformed into a comma-separated string in - // wysiwyg_add_editor_settings(). - // @todo Needs a complete plugin API redesign using arrays for - // tag => attributes definitions and array_merge_recursive(). - $settings['extended_valid_elements'] = array(); + // Add plain extensions. + if (!empty($plugins[$plugin]['load'])) { + $extensions[$plugin] = 1; + } - $plugins = wysiwyg_get_plugins($editor['name']); - foreach ($config['buttons'] as $plugin => $buttons) { - foreach ($buttons as $button => $enabled) { - // Iterate separately over buttons and extensions properties. - foreach (array('buttons', 'extensions') as $type) { - // Skip unavailable plugins. - if (!isset($plugins[$plugin][$type][$button])) { - continue; - } - // Add buttons. - if ($type == 'buttons') { - $settings['buttons'][] = $button; - } - // Add external Drupal plugins to the list of extensions. - if ($type == 'buttons' && !empty($plugins[$plugin]['proxy'])) { - $settings['extensions'][_wysiwyg_tinymce_plugin_name('add', $button)] = 1; - } - // Add external plugins to the list of extensions. - else if ($type == 'buttons' && empty($plugins[$plugin]['internal'])) { - $settings['extensions'][_wysiwyg_tinymce_plugin_name('add', $plugin)] = 1; - } - // Add internal buttons that also need to be loaded as extension. - else if ($type == 'buttons' && !empty($plugins[$plugin]['load'])) { - $settings['extensions'][$plugin] = 1; - } - // Add plain extensions. - else if ($type == 'extensions' && !empty($plugins[$plugin]['load'])) { - $settings['extensions'][$plugin] = 1; - } - // Allow plugins to add valid HTML elements. - if (!empty($plugins[$plugin]['extended_valid_elements'])) { - $settings['extended_valid_elements'] = array_merge($settings['extended_valid_elements'], $plugins[$plugin]['extended_valid_elements']); - } - // Allow plugins to add or override global configuration settings. - if (!empty($plugins[$plugin]['options'])) { - $settings = array_merge($settings, $plugins[$plugin]['options']); - } - } + // Allow plugins to add valid HTML elements. + if (!empty($plugins[$plugin]['extended_valid_elements'])) { + $settings['extended_valid_elements'] = array_merge($settings['extended_valid_elements'], $plugins[$plugin]['extended_valid_elements']); + } + + // Allow plugins to add or override global configuration settings. + if (!empty($plugins[$plugin]['options'])) { + $settings = array_merge($settings, $plugins[$plugin]['options']); } } - // Clean-up. - $settings['extended_valid_elements'] = array_unique($settings['extended_valid_elements']); - if ($settings['extensions']) { - $settings['plugins'] = array_keys($settings['extensions']); + } + + foreach ((array)$config['toolbar'] as $buttons) { + $group = array(); + + foreach ($buttons as $buttonConfig) { + $plugin = $buttonConfig['plugin']; + $button = $buttonConfig['button']; + + if ($button == WYSIWYG_SEPARATOR) { + $group[] = '|'; + continue; + } + if (!isset($plugins[$plugin]['buttons'][$button])) { + continue; + } + + $group[] = $button; + + // Add external Drupal plugins to the list of extensions. + if (!empty($plugins[$plugin]['proxy'])) { + $extensions[_wysiwyg_tinymce_plugin_name('add', $button)] = 1; + } + // Add external plugins to the list of extensions. + else if (empty($plugins[$plugin]['internal'])) { + $extensions[_wysiwyg_tinymce_plugin_name('add', $plugin)] = 1; + } + // Add internal buttons that also need to be loaded as extension. + else if (!empty($plugins[$plugin]['load'])) { + $extensions[$plugin] = 1; + } + + // Allow plugins to add or override global configuration settings. + if (!empty($plugins[$plugin]['options'])) { + $settings = array_merge($settings, $plugins[$plugin]['options']); + } + + // Allow plugins to add valid HTML elements. + if (!empty($plugins[$plugin]['extended_valid_elements'])) { + $settings['extended_valid_elements'] = array_merge($settings['extended_valid_elements'], $plugins[$plugin]['extended_valid_elements']); + } } - unset($settings['extensions']); + + $toolbar[] = $group; + } + + $settings['extended_valid_elements'] = array_unique($settings['extended_valid_elements']); + if ($extensions) { + $settings['plugins'] = array_keys($extensions); } // Add theme-specific settings. @@ -273,22 +284,17 @@ function wysiwyg_tinymce_settings($editor, $config, $theme) { if (isset($config['block_formats'])) { $settings['theme_advanced_blockformats'] = $config['block_formats']; } - if (isset($settings['buttons'])) { - // These rows explicitly need to be set to be empty, otherwise TinyMCE - // loads its default buttons of the advanced theme for each row. - $settings += array( - 'theme_advanced_buttons1' => array(), - 'theme_advanced_buttons2' => array(), - 'theme_advanced_buttons3' => array(), - ); - // @todo Allow to sort/arrange editor buttons. - for ($i = 0; $i < count($settings['buttons']); $i++) { - $settings['theme_advanced_buttons1'][] = $settings['buttons'][$i]; + if ($toolbar) { + for ($i = 0;$i < count($toolbar);$i++) { + $group = $toolbar[$i]; + + foreach ($group as $button) { + $settings['theme_advanced_buttons'.($i+1)][] = $button; + } } } break; } - unset($settings['buttons']); // Convert the config values into the form expected by TinyMCE. foreach ($settings as $key => $value) { diff --git a/images/add.png b/images/add.png new file mode 100644 index 0000000..6332fef Binary files /dev/null and b/images/add.png differ diff --git a/images/draggable.png b/images/draggable.png new file mode 100644 index 0000000..47e8a02 Binary files /dev/null and b/images/draggable.png differ diff --git a/images/remove.png b/images/remove.png new file mode 100644 index 0000000..1514d51 Binary files /dev/null and b/images/remove.png differ diff --git a/wysiwyg-toolbar-designer.tpl.php b/wysiwyg-toolbar-designer.tpl.php new file mode 100644 index 0000000..d15e2fd --- /dev/null +++ b/wysiwyg-toolbar-designer.tpl.php @@ -0,0 +1,37 @@ + array( + 'callbackUrl' => url('admin/settings/wysiwyg/profile/'.arg(4).'/toolbar/save'), + 'toolbar' => $toolbar +)),'setting'); + +?> +
+

 

+
+ +
+ * +
+ +
+ + +
 
+
+ +
+   +   +
+ +

+
+ +   + +
+
\ No newline at end of file diff --git a/wysiwyg.admin.inc b/wysiwyg.admin.inc index 26e3b6f..1b43af7 100644 --- a/wysiwyg.admin.inc +++ b/wysiwyg.admin.inc @@ -7,9 +7,9 @@ */ /** - * Form builder for Wysiwyg profile form. + * Prepare default property for profile */ -function wysiwyg_profile_form($form_state, $profile) { +function wysiwyg_profile_default($profile) { // Merge in defaults. $profile = (array) $profile; $profile += array( @@ -46,10 +46,97 @@ function wysiwyg_profile_form($form_state, $profile) { ); $profile = (object) $profile; + return $profile; +} + +/** + * Profile designer callback + */ +function wysiwyg_profile_toolbar($profile) { + $profile = wysiwyg_profile_default($profile); + $formats = filter_formats(); + $editor = wysiwyg_get_editor($profile->editor); + drupal_set_title(t('%editor profile for %format', array('%editor' => $editor['title'], '%format' => $formats[$profile->format]->name))); + + $plugins = wysiwyg_get_plugins($profile->editor); + + // get all available buttons + $buttons = array(); + + // Separator + $buttons[] = array( + 'plugin' => 'default', + 'button' => WYSIWYG_SEPARATOR, + 'title' => t('Separator'), + ); + + foreach ($plugins as $name => $meta) { + if (isset($meta['buttons']) && is_array($meta['buttons'])) { + foreach ($meta['buttons'] as $button => $title) { + $buttons[] = array( + 'plugin' => $name, + 'button' => $button, + 'title' => $title, + ); + } + } + } + + $toolbar = (array)$profile->settings['toolbar']; + + $output = theme('wysiwyg_profile_toolbar',$buttons,$toolbar); + + return $output; +} + +function wysiwyg_profile_toolbar_save($profile) { + $profile = wysiwyg_profile_default($profile); + $plugins = wysiwyg_get_plugins($profile->editor); + $format = $profile->format; + + $rawToolbar = explode("\n",trim($_POST['toolbar'])); + $toolbar = array(); + + foreach ($rawToolbar as $rawGroup) { + $group = array(); + $buttons = explode('|',$rawGroup); + + foreach ($buttons as $button) { + list($plugin,$name) = explode('.',$button,2); + + if ($name != WYSIWYG_SEPARATOR && !isset($plugins[$plugin],$plugins[$plugin]['buttons'][$name])) { + continue; + } + + $group[] = array( + 'button' => $name, + 'plugin' => $plugin, + ); + } + + if (count($group)) + $toolbar[] = $group; + } + + $values = $profile->settings; + $values['toolbar'] = count($toolbar) ? $toolbar : null; + db_query("UPDATE {wysiwyg} SET settings = '%s' WHERE format = %d", serialize($values), $format); + + echo drupal_json(array('status' => 'ok', 'toolbar' => $toolbar)); +} + +/** + * Form builder for Wysiwyg profile form. + */ +function wysiwyg_profile_form($form_state, $profile) { + $profile = wysiwyg_profile_default($profile); + $formats = filter_formats(); $editor = wysiwyg_get_editor($profile->editor); drupal_set_title(t('%editor profile for %format', array('%editor' => $editor['title'], '%format' => $formats[$profile->format]->name))); + $form_state['storage']['profile'] = $profile; + $form['format'] = array('#type' => 'value', '#value' => $profile->format); $form['input_format'] = array('#type' => 'value', '#value' => $formats[$profile->format]->name); $form['editor'] = array('#type' => 'value', '#value' => $profile->editor); @@ -98,9 +185,9 @@ function wysiwyg_profile_form($form_state, $profile) { '#description' => t('The language to use for the editor interface. Language codes are based on the ISO-639-2 format.'), ); - $form['buttons'] = array( + $form['extensions'] = array( '#type' => 'fieldset', - '#title' => t('Buttons and plugins'), + '#title' => t('Extensions'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#tree' => TRUE, @@ -108,36 +195,14 @@ function wysiwyg_profile_form($form_state, $profile) { ); $plugins = wysiwyg_get_plugins($profile->editor); - // Generate the button list. + // Generate the extension list foreach ($plugins as $name => $meta) { - if (isset($meta['buttons']) && is_array($meta['buttons'])) { - foreach ($meta['buttons'] as $button => $title) { - $icon = ''; - if (!empty($meta['path'])) { - // @todo Button icon locations are different in editors, editor versions, - // and contrib/custom plugins (like Image Assist, f.e.). - $img_src = $meta['path'] . "/images/$name.gif"; - // Handle plugins that have more than one button. - if (!file_exists($img_src)) { - $img_src = $meta['path'] . "/images/$button.gif"; - } - $icon = file_exists($img_src) ? '' : ''; - } - $title = (isset($meta['url']) ? l($title, $meta['url'], array('target' => '_blank')) : $title); - $title = (!empty($icon) ? $icon . ' ' . $title : $title); - $form['buttons'][$name][$button] = array( - '#type' => 'checkbox', - '#title' => $title, - '#default_value' => !empty($profile->settings['buttons'][$name][$button]) ? $profile->settings['buttons'][$name][$button] : FALSE, - ); - } - } - else if (isset($meta['extensions']) && is_array($meta['extensions'])) { + if (isset($meta['extensions']) && is_array($meta['extensions'])) { foreach ($meta['extensions'] as $extension => $title) { - $form['buttons'][$name][$extension] = array( + $form['extensions'][$name][$extension] = array( '#type' => 'checkbox', '#title' => isset($meta['url']) ? l($title, $meta['url'], array('target' => '_blank')) : $title, - '#default_value' => !empty($profile->settings['buttons'][$name][$extension]) ? $profile->settings['buttons'][$name][$extension] : FALSE, + '#default_value' => !empty($profile->settings['extensions'][$name][$extension]) ? $profile->settings['extensions'][$name][$extension] : FALSE, ); } } @@ -296,24 +361,25 @@ function wysiwyg_profile_form($form_state, $profile) { * @see wysiwyg_profile_form() */ function wysiwyg_profile_form_submit($form, &$form_state) { + $profile = $form_state['storage']['profile']; $values = $form_state['values']; - if (isset($values['buttons'])) { + if (isset($values['extensions'])) { // Store only enabled buttons for each plugin. - foreach ($values['buttons'] as $plugin => $buttons) { - $values['buttons'][$plugin] = array_filter($values['buttons'][$plugin]); + foreach ($values['extensions'] as $plugin => $buttons) { + $values['extensions'][$plugin] = array_filter($values['extensions'][$plugin]); } // Store only enabled plugins. - $values['buttons'] = array_filter($values['buttons']); + $values['extensions'] = array_filter($values['extensions']); } + + $values['extensions'] = (array)$values['extensions']; + // Remove input format name. $format = $values['format']; $input_format = $values['input_format']; $editor = $values['editor']; - unset($values['format'], $values['input_format'], $values['editor']); - // Remove FAPI values. - // @see system_settings_form_submit() - unset($values['submit'], $values['form_id'], $values['op'], $values['form_token'], $values['form_build_id']); + $values = array_merge($profile->settings, wysiwyg_profile_clean($values)); // Insert new profile data. db_query("UPDATE {wysiwyg} SET settings = '%s' WHERE format = %d", serialize($values), $format); @@ -351,7 +417,11 @@ function theme_wysiwyg_admin_button_table($form) { $rows[] = $row; } - $output = theme('table', array(), $rows, array('width' => '100%')); + if (count($rows)) { + $output = theme('table', array(), $rows, array('width' => '100%')); + } else { + $output = ''; + } return $output; } @@ -529,3 +599,15 @@ function wysiwyg_profile_delete($format) { db_query("DELETE FROM {wysiwyg} WHERE format = %d", $format); } +/** + * Clean submitted setting values + */ +function wysiwyg_profile_clean($values) { + unset($values['format'], $values['input_format'], $values['editor']); + + // Remove FAPI values. + // @see system_settings_form_submit() + unset($values['submit'], $values['form_id'], $values['op'], $values['form_token'], $values['form_build_id']); + + return $values; +} \ No newline at end of file diff --git a/wysiwyg.admin_toolbar.css b/wysiwyg.admin_toolbar.css new file mode 100644 index 0000000..1d4dfb4 --- /dev/null +++ b/wysiwyg.admin_toolbar.css @@ -0,0 +1,76 @@ +/* $Id$ */ + +#toolbar-groups { + padding: 1em 1em 0 1em; +} + +#toolbar-groups .toolbar-group { + border: 1px dashed gray; + padding: 0.2em; + min-height: 2em; + position: relative; + margin-bottom: 0.5em; +} + +#toolbar-actions { + margin: 1em 0 1em 1em; +} + +.toolbar-group-template { + display: none; +} + +#toolbar-groups .group-handler { + margin-top: 0.2em; + float: left; +} + +#toolbar-available-buttons { + border: 1px dashed silver; + padding: 1em; +} + +#wysiwyg-toolbar-designer .add-toolbar-group { + display: inline-block; + background: url(images/add.png); + width: 16px; + height: 16px; + right: 0.2em; + top: 0.2em; + text-decoration: none; +} + +#wysiwyg-toolbar-designer .remove-group { + display: block; + background: url(images/remove.png); + width: 16px; + height: 16px; + position: absolute; + right: 0.2em; + top: 0.2em; + text-decoration: none; +} + +#wysiwyg-toolbar-designer .handler { + background: url(images/draggable.png) no-repeat 0 4px; + width: 16px; + height: 16px; + display: inline-block; + text-decoration: none; +} + +#wysiwyg-toolbar-designer .wysiwyg-button { + border: 1px solid silver; + display: inline-block; + margin: 0.2em 0.2em 0.2em 0; + padding: 0 0.5em; + height: 20px; +} + +#wysiwyg-toolbar-designer .ahah-progress, #wysiwyg-toolbar-designer div.warning { + display: none; /* hide by default */ +} + +.toolbar-hover { + border: 1px dashed black; +} \ No newline at end of file diff --git a/wysiwyg.admin_toolbar.js b/wysiwyg.admin_toolbar.js new file mode 100644 index 0000000..06ac187 --- /dev/null +++ b/wysiwyg.admin_toolbar.js @@ -0,0 +1,143 @@ +// $Id$ + +Drupal.behaviors.wysiwygToolbarDesigner = function(context) { + var workspace = $('#wysiwyg-toolbar-designer'); + var designArea = $('#toolbar-groups'); + var changeNotification = $('#wysiwyg-toolbar-designer div.warning'); + var createGroup = function(item) { + item.addClass('toolbar-group').sortable({ + revert: true, + items: '.wysiwyg-button', + connectWith: '#toolbar-groups .toolbar-group', + stop: function(event,ui){ + changeNotification.fadeIn(); + } + }); + + item.droppable({ + accept: '.template-button', + drop: function(event,ui) { + var button = ui.draggable.clone(); + button.removeClass('template-button').addClass('toolbar-button'); + $(this).append(button).sortable('refresh'); + changeNotification.fadeIn(); + } + }); + + item.find('.remove-group').click(function() { + if ($(this).parent().find('.wysiwyg-button').length == 0 || confirm(Drupal.t("Do you want to remove this group ?"))) { + $(this).parent().remove(); + changeNotification.fadeIn(); + } + }); + }; + + var reset = function() { + $('.toolbar-group',designArea).remove(); + + for (var i in Drupal.settings.wysiwyg_admin.toolbar) { + var buttons = Drupal.settings.wysiwyg_admin.toolbar[i]; + + var group = $('.toolbar-group-template',workspace).clone().removeClass('toolbar-group-template'); + + for (var j in buttons) { + var buttonClass = '.wysiwyg-button-' + buttons[j].plugin + '-' + buttons[j].button; + var button = $(buttonClass,$('#toolbar-available-buttons')); + + if (button.length) { + button = button.clone(); + button.removeClass('template-button').addClass('toolbar-button'); + + group.append(button); + } + } + + createGroup(group); + designArea.append(group); + } + + changeNotification.fadeOut(); + } + + $('.add-toolbar-group',workspace).click(function(){ + // clone from toolbar template + var group = $('.toolbar-group-template',workspace).clone().removeClass('toolbar-group-template'); + createGroup(group); + + // append to final + designArea.append(group).sortable('refresh'); + changeNotification.fadeIn(); + }); + + $('#toolbar-available-buttons .wysiwyg-button').addClass('template-button').draggable({ + handle: '.handler', + helper: 'clone', + revert: 'invalid', + addClasses: false + }); + + $('#toolbar-available-buttons').droppable({ + accept: '.toolbar-button', + drop: function(event, ui) { + ui.draggable.remove(); + changeNotification.fadeIn(); + } + }); + + $('#toolbar-groups').sortable({ + items: '.toolbar-group', + handle: '.group-handler', + stop: function(event, ui) { + changeNotification.fadeIn(); + } + }); + + /* actions */ + $('#reset-design').click(function() { + if (!changeNotification.is(':hidden') && confirm(Drupal.t('Do you want to reset the changes ?'))) + reset(); + }); + + $('#save-design').click(function() { + // prepare toolbar settings + var toolbar = ""; + + designArea.find('.toolbar-group').each(function(key,groupDom){ + var group = ""; + + $('.wysiwyg-button',groupDom).each(function(key,button){ + var cls = /wysiwyg-button-([^-]+)-([^\s]+)/.exec($(button).attr('class')); + + group += cls[1] + "." + cls[2] + "|"; + }); + + toolbar += group + "\n"; + }); + + var button = $(this); + var progress = $('.ahah-progress',workspace); + button.attr('disabled','disabled'); + progress.show(); + + $.ajax({ + type: 'POST', + dataType: 'json', + url: Drupal.settings.wysiwyg_admin.callbackUrl, + data: {toolbar: toolbar}, + success: function(data){ + button.removeAttr('disabled'); + changeNotification.fadeOut(); + Drupal.settings.wysiwyg_admin.toolbar = data.toolbar; + }, + complete: function(request,status) { + if (status == 'error' || status == 'parsererror') { + alert("Error !!!"); + } + + progress.hide(); + } + }); + }); + + reset(); +}; diff --git a/wysiwyg.info b/wysiwyg.info index b25535a..bae855f 100644 --- a/wysiwyg.info +++ b/wysiwyg.info @@ -4,6 +4,9 @@ description = Allows users to edit contents with client-side editors. package = User interface core = 6.x +dependencies[] = jquery_ui +dependencies[] = jquery_update + ; Information added by drupal.org packaging script on 2010-03-09 version = "6.x-2.x-dev" core = "6.x" diff --git a/wysiwyg.module b/wysiwyg.module index 660936b..d31dcda 100644 --- a/wysiwyg.module +++ b/wysiwyg.module @@ -6,6 +6,8 @@ * Integrate client-side editors with Drupal. */ +define('WYSIWYG_SEPARATOR','Separator'); + /** * Implementation of hook_menu(). */ @@ -32,6 +34,24 @@ function wysiwyg_menu() { 'tab_parent' => 'admin/settings/wysiwyg/profile/%wysiwyg_profile', 'type' => MENU_LOCAL_TASK, ); + $items['admin/settings/wysiwyg/profile/%wysiwyg_profile/toolbar'] = array( + 'title' => 'Toolbar', + 'page callback' => 'wysiwyg_profile_toolbar', + 'page arguments' => array(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/toolbar/save'] = array( + 'title' => 'Toolbar', + 'page callback' => 'wysiwyg_profile_toolbar_save', + 'page arguments' => array(4), + 'access arguments' => array('administer filters'), + 'file' => 'wysiwyg.admin.inc', + 'type' => MENU_TASK, + ); $items['admin/settings/wysiwyg/profile/%wysiwyg_profile/delete'] = array( 'title' => 'Remove', 'page callback' => 'drupal_get_form', @@ -64,6 +84,10 @@ function wysiwyg_theme() { 'wysiwyg_profile_overview' => array( 'arguments' => array('form' => NULL), ), + 'wysiwyg_profile_toolbar' => array( + 'arguments' => array('buttons' => NULL, 'toolbar' => NULL), + 'template' => 'wysiwyg-toolbar-designer', + ), 'wysiwyg_admin_button_table' => array( 'arguments' => array('form' => NULL), ), @@ -545,6 +569,7 @@ function wysiwyg_get_editor_config($profile, $theme) { $context = array('editor' => $editor, 'profile' => $profile, 'theme' => $theme); drupal_alter('wysiwyg_editor_settings', $settings, $context); } + return $settings; }