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'] = '
'; - $element['format']['guidelines']['#suffix'] = '
'; - // Edge-case: Default format contains no input filters. - if (empty($element['format']['guidelines']['#value'])) { - $element['format']['guidelines']['#value'] = ' '; - } - } - else { - $element[$format]['#attributes']['class'] = (isset($element[$format]['#attributes']['class']) ? $element[$format]['#attributes']['class'] . ' ' : ''); - $element[$format]['#attributes']['class'] .= 'wysiwyg wysiwyg-format-' . $format . ' wysiwyg-editor-' . $editor . ' wysiwyg-field-' . $field['#id'] . ' wysiwyg-status-' . $status . ' wysiwyg-toggle-' . $toggle . $extra_class; - } + // Disable #resizable to avoid resizable behavior to hi-jack the UI, + // but load the behavior, so the 'none' editor can attach/detach it. + $resizable = 0; + if (!empty($field['#resizable'])) { + $resizable = 1; + $field['#resizable'] = FALSE; + drupal_add_js('misc/textarea.js'); + } + // Determine the available input formats. + foreach ($element['format']['#options'] as $format_id => $format_name) { + $format = 'format' . $format_id; + // Initialize default settings, defaulting to 'none' editor. + $settings[$format]['editor'] = 'none'; + $settings[$format]['status'] = 1; + $settings[$format]['toggle'] = 1; + $settings[$format]['resizable'] = $resizable; + // Fetch the profile associated to this text format. + $profile = wysiwyg_get_profile($format_id); + if ($profile) { + $settings[$format]['editor'] = $profile->editor; + $settings[$format]['status'] = (int) wysiwyg_user_get_status($profile); + if (isset($profile->settings['show_toggle'])) { + $settings[$format]['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 text format. + wysiwyg_add_plugin_settings($profile); + // Add profile settings for this text format. + wysiwyg_add_editor_settings($profile, $theme); + } - // If this element is 'format', do not recurse further. - continue; } - // Recurse into children. - wysiwyg_process_form($element); + // Use a prefix/suffix for a single text format, or attach to text + // format selector radio buttons. + if (!$element['format']['#access']) { + $element['format_guidelines']['format'] = array( + '#type' => 'hidden', + '#name' => $element['format']['#name'], + '#id' => $element['format']['#id'], + '#value' => $format_id, + '#attributes' => array('class' => array('wysiwyg')), + ); + $element['format_guidelines']['#attached']['js'][] = array( + 'data' => array('wysiwyg' => array('triggers' => array($element['format']['#id'] => $settings))), + 'type' => 'setting', + ); + } + else { + $element['format']['#attributes']['class'][] = 'wysiwyg'; + $element['format']['#attached']['js'][] = array( + 'data' => array('wysiwyg' => array('triggers' => array($element['format']['#id'] => $settings))), + 'type' => 'setting', + ); + } + // If this element is '#text_format', do not recurse further. + continue; } + // Recurse into children. + wysiwyg_process_form($form[$item]); } return $form; } @@ -254,7 +247,7 @@ function wysiwyg_load_editor($profile) { } foreach ($files as $file => $options) { if (is_array($options)) { - $options += array('type' => 'module', 'scope' => 'header', 'defer' => FALSE, 'cache' => TRUE, 'preprocess' => TRUE); + $options += array('type' => 'file', 'scope' => 'header', 'defer' => FALSE, 'cache' => TRUE, 'preprocess' => TRUE); drupal_add_js($editor['library path'] . '/' . $file, $options['type'], $options['scope'], $options['defer'], $options['cache'], $options['preprocess']); } else { @@ -284,7 +277,6 @@ function wysiwyg_load_editor($profile) { } drupal_add_js(array('wysiwyg' => array( - 'configs' => array($editor['name'] => array()), // @todo Move into (global) editor settings. // If JS compression is enabled, at least TinyMCE is unable to determine // its own base path and exec mode since it can't find the script name. @@ -303,6 +295,7 @@ function wysiwyg_load_editor($profile) { if (!isset($settings_added) && $loaded[$name]) { drupal_add_js(array('wysiwyg' => array( 'configs' => array(), + 'plugins' => array(), 'disable' => t('Disable rich-text'), 'enable' => t('Enable rich-text'), )), 'setting'); @@ -310,7 +303,7 @@ function wysiwyg_load_editor($profile) { $path = drupal_get_path('module', 'wysiwyg'); // Initialize our namespaces in the *header* to do not force editor // integration scripts to check and define Drupal.wysiwyg on its own. - drupal_add_js($path . '/wysiwyg.init.js', 'core'); + drupal_add_js($path . '/wysiwyg.init.js', array('weight' => JS_LIBRARY)); // The 'none' editor is a special editor implementation, allowing us to // attach and detach regular Drupal behaviors just like any other editor. @@ -322,7 +315,7 @@ function wysiwyg_load_editor($profile) { // and Drupal.wysiwygInit() must be executed AFTER editors registered // their callbacks and BEFORE Drupal.behaviors are applied, this must come // last. - drupal_add_js($path . '/wysiwyg.js', 'module', 'footer'); + drupal_add_js($path . '/wysiwyg.js', array('scope' => 'footer')); $settings_added = TRUE; } @@ -340,7 +333,9 @@ function wysiwyg_add_editor_settings($pr $config = wysiwyg_get_editor_config($profile, $theme); // drupal_to_js() does not properly convert numeric array keys, so we need // to use a string instead of the format id. - drupal_add_js(array('wysiwyg' => array('configs' => array($profile->editor => array('format' . $profile->format => $config)))), 'setting'); + if ($config) { + drupal_add_js(array('wysiwyg' => array('configs' => array($profile->editor => array('format' . $profile->format => $config)))), 'setting'); + } $formats[$profile->format] = TRUE; } } @@ -415,7 +410,9 @@ function wysiwyg_add_plugin_settings($pr // settings for native external plugins with required values. $settings_native = call_user_func($editor['plugin settings callback'], $editor, $profile, $profile_plugins_native); - drupal_add_js(array('wysiwyg' => array('plugins' => array('format' . $profile->format => array('native' => $settings_native)))), 'setting'); + if ($settings_native) { + drupal_add_js(array('wysiwyg' => array('plugins' => array('format' . $profile->format => array('native' => $settings_native)))), 'setting'); + } } // Process Drupal plugins. @@ -444,7 +441,9 @@ function wysiwyg_add_plugin_settings($pr // the settings for Drupal plugins with custom, required values. $settings_drupal = call_user_func($editor['proxy plugin settings callback'], $editor, $profile, $profile_plugins_drupal); - drupal_add_js(array('wysiwyg' => array('plugins' => array('format' . $profile->format => array('drupal' => $settings_drupal)))), 'setting'); + if ($settings_drupal) { + drupal_add_js(array('wysiwyg' => array('plugins' => array('format' . $profile->format => array('drupal' => $settings_drupal)))), 'setting'); + } } } @@ -547,15 +546,15 @@ function wysiwyg_get_css() { return $files; } // In node form previews, the theme has not been initialized yet. - init_theme(); + if (!empty($_POST)) { + drupal_theme_initialize(); + } $files = array(); - foreach (drupal_add_css() as $media => $css) { - if ($media != 'print') { - foreach ($css['theme'] as $filepath => $preprocess) { - if (file_exists($filepath)) { - $files[] = base_path() . $filepath; - } + foreach (drupal_add_css() as $filepath => $info) { + if ($info['weight'] >= CSS_THEME && $info['media'] != 'print') { + if (file_exists($filepath)) { + $files[] = base_path() . $filepath; } } } @@ -569,8 +568,8 @@ function wysiwyg_profile_load($format) { static $profiles; 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)) { + $result = db_query('SELECT format, editor, settings FROM {wysiwyg} WHERE format = :format', array(':format' => $format)); + foreach ($result as $profile) { $profile->settings = unserialize($profile->settings); $profiles[$profile->format] = $profile; } @@ -588,7 +587,7 @@ function wysiwyg_profile_load_all() { if (!isset($profiles)) { $profiles = array(); $result = db_query('SELECT format, editor, settings FROM {wysiwyg}'); - while ($profile = db_fetch_object($result)) { + foreach ($result as $profile) { $profile->settings = unserialize($profile->settings); $profiles[$profile->format] = $profile; } @@ -783,15 +782,15 @@ function wysiwyg_load_includes($type = ' $directories['wysiwyg'] = drupal_get_path('module', 'wysiwyg') . '/' . $type; $file_list = array(); foreach ($directories as $module => $path) { - $file_list[$module] = drupal_system_listing("$file" . '.inc$', $path, 'name', 0); + $file_list[$module] = drupal_system_listing("/{$file}.inc\$/", $path, 'name', 0); } // Load implementations. $info = array(); foreach (array_filter($file_list) as $module => $files) { foreach ($files as $file) { - include_once './' . $file->filename; - $result = _wysiwyg_process_include($module, $module . '_' . $file->name, dirname($file->filename), $hook); + include_once './' . $file->uri; + $result = _wysiwyg_process_include($module, $module . '_' . $file->name, dirname($file->uri), $hook); if (is_array($result)) { $info = array_merge($info, $result); } Index: editors/js/ckeditor-3.0.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/ckeditor-3.0.js,v retrieving revision 1.1 diff -u -p -r1.1 ckeditor-3.0.js --- editors/js/ckeditor-3.0.js 20 Jun 2009 20:28:20 -0000 1.1 +++ editors/js/ckeditor-3.0.js 26 Sep 2009 04:45:12 -0000 @@ -1,4 +1,5 @@ // $Id: ckeditor-3.0.js,v 1.1 2009/06/20 20:28:20 sun Exp $ +(function($) { /** * Attach this editor to a target element. @@ -32,3 +33,4 @@ Drupal.wysiwyg.editor.detach.ckeditor = } }; +})(jQuery); Index: editors/js/fckeditor-2.6.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/fckeditor-2.6.js,v retrieving revision 1.17 diff -u -p -r1.17 fckeditor-2.6.js --- editors/js/fckeditor-2.6.js 22 Jun 2009 03:00:07 -0000 1.17 +++ editors/js/fckeditor-2.6.js 26 Sep 2009 04:45:20 -0000 @@ -1,4 +1,5 @@ // $Id: fckeditor-2.6.js,v 1.17 2009/06/22 03:00:07 sun Exp $ +(function($) { /** * Attach this editor to a target element. @@ -154,3 +155,4 @@ Drupal.wysiwyg.editor.instance.fckeditor } }; +})(jQuery); Index: editors/js/jwysiwyg.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/jwysiwyg.js,v retrieving revision 1.3 diff -u -p -r1.3 jwysiwyg.js --- editors/js/jwysiwyg.js 1 Dec 2008 14:14:41 -0000 1.3 +++ editors/js/jwysiwyg.js 26 Sep 2009 04:45:41 -0000 @@ -1,4 +1,5 @@ // $Id: jwysiwyg.js,v 1.3 2008/12/01 14:14:41 sun Exp $ +(function($) { /** * Attach this editor to a target element. @@ -22,3 +23,4 @@ Drupal.wysiwyg.editor.detach.jwysiwyg = $field.show(); }; +})(jQuery); Index: editors/js/markitup.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/markitup.js,v retrieving revision 1.2 diff -u -p -r1.2 markitup.js --- editors/js/markitup.js 6 Jun 2009 05:56:34 -0000 1.2 +++ editors/js/markitup.js 26 Sep 2009 04:45:45 -0000 @@ -1,4 +1,5 @@ // $Id: markitup.js,v 1.2 2009/06/06 05:56:34 sun Exp $ +(function($) { /** * Attach this editor to a target element. @@ -26,3 +27,4 @@ Drupal.wysiwyg.editor.detach.markitup = } }; +})(jQuery); Index: editors/js/nicedit.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/nicedit.js,v retrieving revision 1.3 diff -u -p -r1.3 nicedit.js --- editors/js/nicedit.js 1 Dec 2008 14:14:41 -0000 1.3 +++ editors/js/nicedit.js 26 Sep 2009 04:45:50 -0000 @@ -1,4 +1,5 @@ // $Id: nicedit.js,v 1.3 2008/12/01 14:14:41 sun Exp $ +(function($) { /** * Attach this editor to a target element. @@ -35,3 +36,4 @@ Drupal.wysiwyg.editor.detach.nicedit = f } }; +})(jQuery); Index: editors/js/none.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/none.js,v retrieving revision 1.6 diff -u -p -r1.6 none.js --- editors/js/none.js 17 May 2009 00:13:21 -0000 1.6 +++ editors/js/none.js 26 Sep 2009 04:44:34 -0000 @@ -1,4 +1,5 @@ // $Id: none.js,v 1.6 2009/05/17 00:13:21 sun Exp $ +(function($) { /** * Attach this editor to a target element. @@ -17,8 +18,8 @@ Drupal.wysiwyg.editor.attach.none = func if (params.resizable) { $('#' + params.field).addClass('resizable'); $('#' + params.field).css({display: ''}); - if (Drupal.behaviors.textarea) { - Drupal.behaviors.textarea(); + if (Drupal.behaviors.textarea.attach) { + Drupal.behaviors.textarea.attach(); } } }; @@ -36,7 +37,7 @@ Drupal.wysiwyg.editor.attach.none = func */ Drupal.wysiwyg.editor.detach.none = function(context, params) { if (typeof params != 'undefined') { - var $textarea = $('#' + params.field, context).removeClass('textarea-processed'); + var $textarea = $('#' + params.field, context).removeOnce('textarea'); var $div = $textarea.parents('div.resizable-textarea'); $div.before($textarea); $div.remove(); @@ -68,3 +69,5 @@ Drupal.wysiwyg.editor.instance.none = { } } }; + +})(jQuery); Index: editors/js/openwysiwyg.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/openwysiwyg.js,v retrieving revision 1.1 diff -u -p -r1.1 openwysiwyg.js --- editors/js/openwysiwyg.js 6 Jun 2009 05:20:09 -0000 1.1 +++ editors/js/openwysiwyg.js 26 Sep 2009 04:46:54 -0000 @@ -3,6 +3,8 @@ // Reset $() to jQuery. Yuck! $ = jQuery; +(function($) { + /** * Attach this editor to a target element. */ @@ -95,3 +97,4 @@ WYSIWYG.viewText = function (n, id) { $ = jQuery; }; +})(jQuery); Index: editors/js/tinymce-2.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/tinymce-2.js,v retrieving revision 1.10 diff -u -p -r1.10 tinymce-2.js --- editors/js/tinymce-2.js 6 Mar 2009 03:22:37 -0000 1.10 +++ editors/js/tinymce-2.js 26 Sep 2009 04:47:02 -0000 @@ -1,4 +1,5 @@ // $Id: tinymce-2.js,v 1.10 2009/03/06 03:22:37 sun Exp $ +(function($) { /** * Initialize editor instances. @@ -196,3 +197,4 @@ Drupal.wysiwyg.editor.instance.tinymce = } }; +})(jQuery); Index: editors/js/tinymce-3.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/tinymce-3.js,v retrieving revision 1.17 diff -u -p -r1.17 tinymce-3.js --- editors/js/tinymce-3.js 13 Jun 2009 01:14:43 -0000 1.17 +++ editors/js/tinymce-3.js 26 Sep 2009 04:41:24 -0000 @@ -1,4 +1,5 @@ // $Id: tinymce-3.js,v 1.17 2009/06/13 01:14:43 sun Exp $ +(function($) { /** * Initialize editor instances. @@ -11,10 +12,6 @@ * An object containing editor settings for each input format. */ Drupal.wysiwyg.editor.init.tinymce = function(settings) { - // @see #454992: drupal_get_js() must not use 'q' as query string. - if (tinymce.query == 'q') { - tinymce.query = ''; - } // If JS compression is enabled, TinyMCE is unable to find its own base path // and exec mode, hence we need to define it manually. // @todo Move global library settings somewhere else. @@ -212,3 +209,4 @@ Drupal.wysiwyg.editor.instance.tinymce = } }; +})(jQuery); Index: editors/js/whizzywig.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/whizzywig.js,v retrieving revision 1.4 diff -u -p -r1.4 whizzywig.js --- editors/js/whizzywig.js 5 Feb 2009 01:34:35 -0000 1.4 +++ editors/js/whizzywig.js 26 Sep 2009 04:47:09 -0000 @@ -1,4 +1,5 @@ // $Id: whizzywig.js,v 1.4 2009/02/05 01:34:35 sun Exp $ +(function($) { var wysiwygWhizzywig = { currentField: null, fields: {} }; var buttonPath = null; @@ -103,3 +104,4 @@ Drupal.wysiwyg.editor.detach.whizzywig = } }; +})(jQuery); Index: editors/js/wymeditor.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/wymeditor.js,v retrieving revision 1.3 diff -u -p -r1.3 wymeditor.js --- editors/js/wymeditor.js 4 Jul 2009 11:06:32 -0000 1.3 +++ editors/js/wymeditor.js 26 Sep 2009 04:47:15 -0000 @@ -1,4 +1,5 @@ // $Id: wymeditor.js,v 1.3 2009/07/04 11:06:32 sun Exp $ +(function($) { /** * Attach this editor to a target element. @@ -52,3 +53,5 @@ Drupal.wysiwyg.editor.instance.wymeditor } } }; + +})(jQuery); Index: editors/js/yui.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/yui.js,v retrieving revision 1.1 diff -u -p -r1.1 yui.js --- editors/js/yui.js 8 Dec 2008 18:58:09 -0000 1.1 +++ editors/js/yui.js 26 Sep 2009 04:47:21 -0000 @@ -1,4 +1,5 @@ // $Id: yui.js,v 1.1 2008/12/08 18:58:09 sun Exp $ +(function($) { /** * Attach this editor to a target element. @@ -36,3 +37,4 @@ Drupal.wysiwyg.editor.detach.yui = funct } }; +})(jQuery);