Index: CHANGELOG.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/CHANGELOG.txt,v retrieving revision 1.165 diff -u -p -r1.165 CHANGELOG.txt --- CHANGELOG.txt 10 Aug 2009 23:11:05 -0000 1.165 +++ CHANGELOG.txt 26 Sep 2009 04:57:29 -0000 @@ -4,6 +4,11 @@ Wysiwyg x.x-x.x, xxxx-xx-xx --------------------------- +Wysiwyg 7.x-3.x, xxxx-xx-xx +--------------------------- +#585932 by sun: Ported to Drupal 7. + + Wysiwyg 6.x-3.x, xxxx-xx-xx --------------------------- #489156 by sun: Removed orphan global 'showToggle' JS setting. Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/README.txt,v retrieving revision 1.7 diff -u -p -r1.7 README.txt --- README.txt 21 Jun 2009 03:54:33 -0000 1.7 +++ README.txt 26 Sep 2009 05:37:12 -0000 @@ -21,22 +21,24 @@ Bug reports, feature suggestions and lat * Install as usual, see http://drupal.org/node/70151 for further information. -* Go to Administer > Site configuration > Wysiwyg, and follow the displayed - installation instructions to download and install one of the supported - editors. +* Go to Administer > Configuration and modules > Content authoring > Wysiwyg, + and follow the displayed installation instructions to download and install one + of the supported editors. -- CONFIGURATION -- -* Go to Administer > Site configuration > Input formats and +* Go to Administer > Configuration and modules > Content authoring > Text + formats and - either configure the Full HTML format, assign it to trusted roles, and disable "HTML filter", "Line break converter", and (optionally) "URL filter". - - or add a new input format, assign it to trusted roles, and ensure that above + - or add a new text format, assign it to trusted roles, and ensure that above mentioned input filters are disabled. -* Setup editor profiles in Administer > Site configuration > Wysiwyg. +* Setup editor profiles in Administer > Configuration and modules > Content + authoring > Wysiwyg. -- CONTACT -- Index: wysiwyg.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg.admin.inc,v retrieving revision 1.17 diff -u -p -r1.17 wysiwyg.admin.inc --- wysiwyg.admin.inc 18 Jul 2009 18:47:43 -0000 1.17 +++ wysiwyg.admin.inc 26 Sep 2009 00:43:26 -0000 @@ -9,7 +9,7 @@ /** * Form builder for Wysiwyg profile form. */ -function wysiwyg_profile_form($form_state, $profile) { +function wysiwyg_profile_form($form, &$form_state, $profile) { // Merge in defaults. $profile = (array) $profile; $profile += array( @@ -48,9 +48,8 @@ function wysiwyg_profile_form($form_stat $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))); + drupal_set_title(t('%editor profile for %format', array('%editor' => $editor['title'], '%format' => $formats[$profile->format]->name)), PASS_THROUGH); - $form = array(); $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); @@ -312,17 +311,17 @@ function wysiwyg_profile_form_submit($fo unset($values['submit'], $values['form_id'], $values['op'], $values['form_token'], $values['form_build_id']); // Insert new profile data. - db_query("UPDATE {wysiwyg} SET settings = '%s' WHERE format = %d", serialize($values), $format); + db_query("UPDATE {wysiwyg} SET settings = :settings WHERE format = :format", array(':settings' => serialize($values), ':format' => $format)); drupal_set_message(t('Wysiwyg profile for %format has been saved.', array('%format' => $input_format))); - $form_state['redirect'] = 'admin/settings/wysiwyg'; + $form_state['redirect'] = 'admin/config/content/wysiwyg'; } /** * Layout for the buttons in the Wysiwyg Editor profile form. */ -function theme_wysiwyg_admin_button_table(&$form) { +function theme_wysiwyg_admin_button_table($form) { $buttons = array(); // Flatten forms array. @@ -355,9 +354,8 @@ function theme_wysiwyg_admin_button_tabl /** * Display overview of setup Wysiwyg Editor profiles; menu callback. */ -function wysiwyg_profile_overview() { +function wysiwyg_profile_overview($form, &$form_state) { include_once './includes/install.inc'; - $form = array(); // Check which wysiwyg editors are installed. $editors = wysiwyg_get_all_editors(); @@ -405,7 +403,7 @@ function wysiwyg_profile_overview() { '#description' => (!$count ? t('There are no editor libraries installed currently. The following list contains a list of currently supported editors:') : ''), '#weight' => 10, ); - $form['status']['report'] = array('#type' => 'markup', '#value' => theme('status_report', $status)); + $form['status']['report'] = array('#markup' => theme('status_report', $status)); if (!$count) { return $form; @@ -414,22 +412,19 @@ function wysiwyg_profile_overview() { $formats = filter_formats(); $profiles = wysiwyg_profile_load_all(); $form['formats'] = array( - '#type' => 'fieldset', - '#title' => t('Wysiwyg profiles'), - '#description' => t('Once an editor has been associated with an input format, the editor association cannot be changed without first deleting the profile and then creating a new one. Delete a profile by clicking on the "delete" link and afterwards, set up a new profile as usual.'), + '#type' => 'item', + '#description' => t('To assign a different editor to a text format, click "delete" to remove the existing first.'), '#tree' => TRUE, ); foreach ($formats as $id => $format) { $form['formats'][$id]['name'] = array( - '#value' => check_plain($format->name), + '#markup' => check_plain($format->name), ); // Only display editor selection for associated input formats to avoid // confusion about disabled selection. if (isset($profiles[$id]) && !empty($profiles[$id]->editor)) { $form['formats'][$id]['editor'] = array( - '#type' => 'markup', - '#value' => $options[$profiles[$id]->editor], - '#id' => "edit-editor-$id", + '#markup' => $options[$profiles[$id]->editor], ); } else { @@ -437,15 +432,14 @@ function wysiwyg_profile_overview() { '#type' => 'select', '#default_value' => '', '#options' => $options, - '#id' => "edit-editor-$id", ); } if (isset($profiles[$id]) && !empty($profiles[$id]->editor)) { $form['formats'][$id]['edit'] = array( - '#value' => l(t('Edit'), "admin/settings/wysiwyg/profile/$id/edit"), + '#markup' => l(t('Edit'), "admin/config/content/wysiwyg/profile/$id/edit"), ); $form['formats'][$id]['delete'] = array( - '#value' => l(t('Delete'), "admin/settings/wysiwyg/profile/$id/delete"), + '#markup' => l(t('Delete'), "admin/config/content/wysiwyg/profile/$id/delete"), ); } } @@ -457,7 +451,7 @@ function wysiwyg_profile_overview() { /** * Return HTML for the Wysiwyg profile overview form. */ -function theme_wysiwyg_profile_overview(&$form) { +function theme_wysiwyg_profile_overview($form) { if (!isset($form['formats'])) { return; } @@ -473,8 +467,8 @@ function theme_wysiwyg_profile_overview( isset($format['delete']) ? drupal_render($format['delete']) : '', ); } - $form['formats']['#children'] = theme('table', $header, $rows); - $output .= drupal_render($form); + $form['formats']['table']['#markup'] = theme('table', $header, $rows); + $output .= drupal_render_children($form); return $output; } @@ -483,24 +477,26 @@ function theme_wysiwyg_profile_overview( */ function wysiwyg_profile_overview_submit($form, &$form_state) { foreach ($form_state['values']['formats'] as $format => $values) { - db_query("UPDATE {wysiwyg} SET editor = '%s' WHERE format = %d", $values['editor'], $format); - if (!db_affected_rows()) { - db_query("INSERT INTO {wysiwyg} (format, editor) VALUES (%d, '%s')", $format, $values['editor']); - } + db_merge('wysiwyg') + ->key(array('format' => $format)) + ->fields(array( + 'editor' => $values['editor'], + )) + ->execute(); } } /** * Delete editor profile confirmation form. */ -function wysiwyg_profile_delete_confirm(&$form_state, $profile) { +function wysiwyg_profile_delete_confirm($form, &$form_state, $profile) { $formats = filter_formats(); $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' => $format->name)), - 'admin/settings/wysiwyg', + 'admin/config/content/wysiwyg', t('This action cannot be undone.'), t('Remove'), t('Cancel') ); } @@ -514,13 +510,15 @@ function wysiwyg_profile_delete_confirm_ $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'; + $form_state['redirect'] = 'admin/config/content/wysiwyg'; } /** * Remove a profile from the database. */ function wysiwyg_profile_delete($format) { - db_query("DELETE FROM {wysiwyg} WHERE format = %d", $format); + db_delete('wysiwyg') + ->condition('format', $format) + ->execute(); } Index: wysiwyg.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg.info,v retrieving revision 1.3 diff -u -p -r1.3 wysiwyg.info --- wysiwyg.info 14 Jun 2009 18:21:48 -0000 1.3 +++ wysiwyg.info 16 Sep 2009 20:15:01 -0000 @@ -2,9 +2,12 @@ name = Wysiwyg description = Allows users to edit contents with client-side editors. package = User interface -dependencies[] = libraries -dependencies[] = ctools -dependencies[] = jquery_ui -dependencies[] = popups -dependencies[] = debug -core = 6.x +;dependencies[] = libraries +;dependencies[] = ctools +;dependencies[] = popups +;dependencies[] = debug +core = 7.x +files[] = wysiwyg.module +files[] = wysiwyg.install +files[] = wysiwyg.admin.inc +files[] = wysiwyg.dialog.inc Index: wysiwyg.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg.install,v retrieving revision 1.5 diff -u -p -r1.5 wysiwyg.install --- wysiwyg.install 18 Jul 2009 19:17:36 -0000 1.5 +++ wysiwyg.install 16 Sep 2009 22:25:29 -0000 @@ -5,7 +5,6 @@ * Implementation of hook_schema(). */ function wysiwyg_schema() { - $schema = array(); $schema['wysiwyg'] = array( 'description' => t('Stores Wysiwyg profiles.'), 'fields' => array( @@ -19,20 +18,6 @@ function wysiwyg_schema() { } /** - * Implementation of hook_install(). - */ -function wysiwyg_install() { - drupal_install_schema('wysiwyg'); -} - -/** - * Implementation of hook_uninstall() - */ -function wysiwyg_uninstall() { - drupal_uninstall_schema('wysiwyg'); -} - -/** * Implementation of hook_enable(). */ function wysiwyg_enable() { Index: wysiwyg.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg.js,v retrieving revision 1.16 diff -u -p -r1.16 wysiwyg.js --- wysiwyg.js 23 Jul 2009 16:36:33 -0000 1.16 +++ wysiwyg.js 26 Sep 2009 05:34:16 -0000 @@ -1,4 +1,5 @@ // $Id: wysiwyg.js,v 1.16 2009/07/23 16:36:33 sun Exp $ +(function($) { /** * Initialize editor libraries. @@ -37,39 +38,45 @@ Drupal.wysiwygInit = function() { * @param context * A DOM element, supplied by Drupal.attachBehaviors(). */ -Drupal.behaviors.attachWysiwyg = function(context) { - // This breaks in Konqueror. Prevent it from running. - if (/KDE/.test(navigator.vendor)) { - return; - } +Drupal.behaviors.attachWysiwyg = { + attach: function(context, settings) { + // This breaks in Konqueror. Prevent it from running. + if (/KDE/.test(navigator.vendor)) { + return; + } - $('.wysiwyg:not(.wysiwyg-processed)', context).each(function() { - var params = Drupal.wysiwyg.getParams(this); - var $this = $(this).addClass('wysiwyg-processed'); - // Directly attach this editor, if the input format is enabled or there is - // only one input format at all. - if (($this.is(':input') && $this.is(':checked')) || $this.is('div')) { - Drupal.wysiwygAttach(context, params); - } - // Attach onChange handlers to input format selector elements. - if ($this.is(':input')) { - $this.change(function() { - // If not disabled, detach the current and attach a new editor. - Drupal.wysiwygDetach(context, params); - Drupal.wysiwygAttach(context, params); - }); - // IE triggers onChange after blur only. - if ($.browser.msie) { - $this.click(function () { - this.blur(); + $('.wysiwyg', context).once('wysiwyg', function() { + if (!this.id || !this.value || typeof Drupal.settings.wysiwyg.triggers[this.id] === undefined) { + return; + } + var $this = $(this); + var params = Drupal.settings.wysiwyg.triggers[this.id]; + for (var format in params) { + params[format].format = format; + params[format].trigger = this.id; + params[format].field = params.field; + } + var format = 'format' + this.value; + // Directly attach this editor, if the input format is enabled or there is + // only one input format at all. + if ($this.is(':input')) { + Drupal.wysiwygAttach(context, params[format]); + } + // Attach onChange handlers to input format selector elements. + if ($this.is('select')) { + $this.change(function() { + // If not disabled, detach the current and attach a new editor. + Drupal.wysiwygDetach(context, params[format]); + format = 'format' + this.value; + Drupal.wysiwygAttach(context, params[format]); }); } - } - // Detach any editor when the containing form is submitted. - $('#' + params.field).parents('form').submit(function () { - Drupal.wysiwygDetach(context, params); + // Detach any editor when the containing form is submitted. + $('#' + params.field).parents('form').submit(function () { + Drupal.wysiwygDetach(context, params[format]); + }); }); - }); + } }; /** @@ -169,7 +176,7 @@ Drupal.wysiwygAttachToggleLink = functio // Before enabling the editor, detach default behaviors. Drupal.wysiwyg.editor.detach.none(context, params); // Attach new editor using parameters of the currently selected input format. - Drupal.wysiwyg.getParams($('.wysiwyg-field-' + params.field + ':checked, div.wysiwyg-field-' + params.field, context).get(0), params); + params = Drupal.settings.wysiwyg.triggers[params.trigger]['format' + $('#' + params.trigger).val()]; params.status = true; Drupal.wysiwygAttach(context, params); $(this).html(Drupal.settings.wysiwyg.disable).blur(); @@ -215,3 +222,4 @@ Drupal.wysiwyg.getParams = function(elem */ Drupal.wysiwygInit(); +})(jQuery); Index: wysiwyg.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg.module,v retrieving revision 1.39 diff -u -p -r1.39 wysiwyg.module --- wysiwyg.module 10 Aug 2009 23:11:05 -0000 1.39 +++ wysiwyg.module 26 Sep 2009 05:31:23 -0000 @@ -10,36 +10,36 @@ * Implementation of hook_menu(). */ function wysiwyg_menu() { - $items['admin/settings/wysiwyg'] = array( - 'title' => 'Wysiwyg', + $items['admin/config/content/wysiwyg'] = array( + 'title' => 'Wysiwyg 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', + $items['admin/config/content/wysiwyg/profile'] = array( + 'title' => 'List', 'type' => MENU_DEFAULT_LOCAL_TASK, ); - $items['admin/settings/wysiwyg/profile/%wysiwyg_profile/edit'] = array( + $items['admin/config/content/wysiwyg/profile/%wysiwyg_profile/edit'] = array( 'title' => 'Edit', 'page callback' => 'drupal_get_form', - 'page arguments' => array('wysiwyg_profile_form', 4), + 'page arguments' => array('wysiwyg_profile_form', 5), 'access arguments' => array('administer filters'), 'file' => 'wysiwyg.admin.inc', - 'tab_root' => 'admin/settings/wysiwyg/profile', - 'tab_parent' => 'admin/settings/wysiwyg/profile/%wysiwyg_profile', + 'tab_root' => 'admin/config/content/wysiwyg/profile', + 'tab_parent' => 'admin/config/content/wysiwyg/profile/%wysiwyg_profile', 'type' => MENU_LOCAL_TASK, ); - $items['admin/settings/wysiwyg/profile/%wysiwyg_profile/delete'] = array( + $items['admin/config/content/wysiwyg/profile/%wysiwyg_profile/delete'] = array( 'title' => 'Remove', 'page callback' => 'drupal_get_form', - 'page arguments' => array('wysiwyg_profile_delete_confirm', 4), + 'page arguments' => array('wysiwyg_profile_delete_confirm', 5), 'access arguments' => array('administer filters'), 'file' => 'wysiwyg.admin.inc', - 'tab_root' => 'admin/settings/wysiwyg/profile', - 'tab_parent' => 'admin/settings/wysiwyg/profile/%wysiwyg_profile', + 'tab_root' => 'admin/config/content/wysiwyg/profile', + 'tab_parent' => 'admin/config/content/wysiwyg/profile/%wysiwyg_profile', 'type' => MENU_LOCAL_TASK, 'weight' => 10, ); @@ -61,8 +61,12 @@ function wysiwyg_menu() { */ function wysiwyg_theme() { return array( - 'wysiwyg_profile_overview' => array('arguments' => array('form' => NULL)), - 'wysiwyg_admin_button_table' => array('arguments' => array('form' => NULL)), + 'wysiwyg_profile_overview' => array( + 'arguments' => array('form' => NULL), + ), + 'wysiwyg_admin_button_table' => array( + 'arguments' => array('form' => NULL), + ), 'wysiwyg_dialog_page' => array( 'arguments' => array('content' => NULL, 'show_messages' => TRUE), 'file' => 'wysiwyg.dialog.inc', @@ -76,7 +80,7 @@ function wysiwyg_theme() { */ function wysiwyg_help($path, $arg) { switch ($path) { - case 'admin/settings/wysiwyg': + case 'admin/config/content/wysiwyg': $output = '
' . t('A Wysiwyg profile is associated with an input format. A Wysiwyg profile defines which client-side editor is loaded with a particular input format, what buttons or themes are enabled for the editor, how the editor is displayed, and a few other editor-specific functions.') . '
'; return $output; } @@ -102,96 +106,85 @@ function wysiwyg_form_alter(&$form, &$fo } /** - * Process a textarea for Wysiwyg Editor. + * Process a form to attach wysiwyg editors. * - * This way, we can recurse into the form and search for certain, hard-coded - * elements that have been added by filter_form(). If an input format selector - * or input format guidelines element is found, we assume that the preceding - * element is the corresponding textarea and use it's #id for attaching - * client-side editors. + * Recurse into the form and if an text format-enabled element is found, use its + * #id for attaching client-side editors. * - * @see wysiwyg_elements(), filter_form() + * @see form_process_text_format() */ function wysiwyg_process_form(&$form) { - // Iterate over element children; resetting array keys to access last index. - if ($children = array_values(element_children($form))) { - foreach ($children as $index => $item) { - $element = &$form[$item]; - - // filter_form() always uses the key 'format'. We need a type-agnostic - // match to prevent false positives. Also, there must have been at least - // one element on this level. - if ($item === 'format' && $index > 0) { - // Make sure we either match a input format selector or input format - // guidelines (displayed if user has access to one input format only). - if ((isset($element['#type']) && $element['#type'] == 'fieldset') || isset($element['format']['guidelines'])) { - // The element before this element is the target form field. - $field = &$form[$children[$index - 1]]; - - // Disable #resizable to avoid resizable behavior to hi-jack the UI, - // but load the behavior, so the 'none' editor can attach/detach it. - $extra_class = ''; - if (!empty($field['#resizable'])) { - // Due to our CSS class parsing, we can add arbitrary parameters - // for each input format. - $extra_class = ' wysiwyg-resizable-1'; - $field['#resizable'] = FALSE; - drupal_add_js('misc/textarea.js'); - } + foreach (element_children($form) as $item) { + // filter_form() always uses the key 'format'. We need a type-agnostic + // match to prevent false positives. + if (isset($form[$item]['#text_format'])) { + $element = &$form[$item]['format']; + $field = &$form[$item]['value']; + $settings = array( + 'field' => $field['#id'], + ); - // Determine the available input formats. The last child element is a - // link to "More information about formatting options". When only one - // input format is displayed, we also have to remove formatting - // guidelines, stored in the child 'format'. - $formats = element_children($element); - array_pop($formats); - if (($key = array_search('format', $formats)) !== FALSE) { - unset($formats[$key]); - } - foreach ($formats as $format) { - // Default to 'none' editor (Drupal's default behaviors). - $editor = 'none'; - $status = 1; - $toggle = 1; - // Fetch the profile associated to this input format. - $profile = wysiwyg_get_profile($format); - if ($profile) { - $editor = $profile->editor; - $status = (int) wysiwyg_user_get_status($profile); - if (isset($profile->settings['show_toggle'])) { - $toggle = (int) $profile->settings['show_toggle']; - } - // Check editor theme (and reset it if not/no longer available). - $theme = wysiwyg_get_editor_themes($profile, (isset($profile->settings['theme']) ? $profile->settings['theme'] : '')); - - // Add plugin settings (first) for this input format. - wysiwyg_add_plugin_settings($profile); - // Add profile settings for this input format. - wysiwyg_add_editor_settings($profile, $theme); - } - - // Use a prefix/suffix for a single input format, or attach to input - // format selector radio buttons. - if (isset($element['format']['guidelines'])) { - $element['format']['guidelines']['#prefix'] = '