diff --git a/editors/ckeditor.inc b/editors/ckeditor.inc index 6ff60d5..05c8f00 100644 --- a/editors/ckeditor.inc +++ b/editors/ckeditor.inc @@ -135,36 +135,88 @@ function wysiwyg_ckeditor_themes($editor, $profile) { * @see http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.stylesSet */ function wysiwyg_ckeditor_settings_form(&$form, &$form_state) { - $form['output']['paste_auto_cleanup_on_paste']['#title'] = t('Force paste as plain text'); - $form['output']['paste_auto_cleanup_on_paste']['#description'] = t('If enabled, all pasting operations insert plain text into the editor, loosing any formatting information possibly available in the source text. Note: Paste from Word is not affected by this setting.'); + $profile = $form_state['wysiwyg_profile']; + $settings = $profile->settings; + $installed_version = $form_state['wysiwyg']['editor']['installed version']; - if (version_compare($form_state['wysiwyg']['editor']['installed version'], '3.6.0', '>=')) { + $ckeditor_defaults = array( + 'block_formats' => 'p,address,pre,h2,h3,h4,h5,h6,div', + ); + + $settings += $ckeditor_defaults; + + $form['appearance']['toolbarLocation'] = array( + '#type' => 'select', + '#title' => t('Toolbar location'), + '#default_value' => $settings['toolbarLocation'], + '#options' => array('bottom' => t('Bottom'), 'top' => t('Top')), + '#description' => t('This option controls whether the editor toolbar is displayed above or below the editing area.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'toolbarLocation', '@url' => url('http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-toolbarLocation'))), + ); + + $form['appearance']['resize_enabled'] = array( + '#type' => 'checkbox', + '#title' => t('Enable resizing button'), + '#default_value' => $settings['resize_enabled'], + '#return_value' => 1, + '#description' => t('This option gives you the ability to enable/disable the editor resizing feature.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'resize_enabled', '@url' => url('http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-resize_enabled'))), + ); + + $form['paste'] = array( + '#type' => 'fieldset', + '#title' => t('Paste plugin'), + '#description' => t('Settings for the paste plugin.'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#group' => 'advanced', + ); + + $form['paste']['forcePasteAsPlainText'] = array( + '#type' => 'checkbox', + '#title' => t('Force paste as plain text'), + '#default_value' => !empty($settings['forcePasteAsPlainText']), + '#return_value' => 1, + '#description' => t('If enabled, all pasting operations insert plain text into the editor, loosing any formatting information possibly available in the source text. Note: Paste from Word is not affected by this setting.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'forcePasteAsPlainText', '@url' => url('http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-forcePasteAsPlainText'))), + ); + + if (version_compare($installed_version, '3.6.0', '>=')) { $form['appearance']['default_toolbar_grouping'] = array( '#type' => 'checkbox', '#title' => t('Use default toolbar button grouping'), - '#default_value' => !empty($form_state['wysiwyg_profile']->settings['default_toolbar_grouping']), + '#default_value' => !empty($settings['default_toolbar_grouping']), '#return_value' => 1, '#description' => t('This option gives you the ability to enable/disable the usage of default groupings for toolbar buttons. If enabled, toolbar buttons will be placed into predetermined groups instead of all in a single group.'), ); } - if (version_compare($form_state['wysiwyg']['editor']['installed version'], '3.2.1', '>=')) { - // Replace CSS classes element description to explain the advanced syntax. - $form['css']['css_classes']['#description'] = t('Optionally define CSS classes for the "Font style" dropdown list.
Enter one class on each line in the format: !format. Example: !example
If left blank, CSS classes are automatically imported from loaded stylesheet(s).', array( - '!format' => '[label]=[element].[class]', - '!example' => 'Title=h1.title', - )); - $form['css']['css_classes']['#element_validate'][] = 'wysiwyg_ckeditor_settings_form_validate_css_classes'; - } - else { + if (version_compare($installed_version, '3.2.1', '>=')) { // Versions below 3.2.1 do not support Font styles at all. - $form['css']['css_classes']['#access'] = FALSE; + $form['css']['stylesSet'] = array( + '#type' => 'textarea', + '#title' => t('CSS classes'), + '#description' => t('Optionally define CSS classes for the "Font style" dropdown list.
Enter one class on each line in the format: !format. Example: !example
If left blank, CSS classes are automatically imported from loaded stylesheet(s).', array( + '@url' => url('http://docs.ckeditor.com/#!/api/CKEDITOR.stylesSet'), + '!format' => '[label]=[element].[class]', + '!example' => 'Title=h1.title', + )) . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'stylesSet', '@url' => url('http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-stylesSet'))), + '#default_value' => $settings['stylesSet'], + '#element_validate' => array('wysiwyg_ckeditor_settings_form_validate_stylessets'), + ); + } + + $form['css']['block_formats'] = array( + '#type' => 'textfield', + '#title' => t('Block formats'), + '#default_value' => $settings['block_formats'], + '#size' => 40, + '#maxlength' => 250, + '#description' => t('Comma separated list of HTML block formats. Possible values: @format-list.', array('@format-list' => 'p,h1,h2,h3,h4,h5,h6,div,blockquote,address,pre,code,dt,dd and other block elements')) . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'block_formats', '@url' => url('http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-format_tags'))), + ); } /** * #element_validate handler for CSS classes element altered by wysiwyg_ckeditor_settings_form(). */ -function wysiwyg_ckeditor_settings_form_validate_css_classes($element, &$form_state) { +function wysiwyg_ckeditor_settings_form_validate_stylessets($element, &$form_state) { if (wysiwyg_ckeditor_settings_parse_styles($element['#value']) === FALSE) { form_error($element, t('The specified CSS classes are syntactically incorrect.')); } @@ -237,7 +289,7 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) { // Add HTML block format settings; common block formats are already predefined // by CKEditor. if (isset($config['block_formats'])) { - $block_formats = explode(',', drupal_strtolower($config['block_formats'])); + $block_formats = explode(',', drupal_strtolower(preg_replace('@\s+@', '', $config['block_formats']))); $predefined_formats = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'pre', 'address', 'div'); foreach (array_diff($block_formats, $predefined_formats) as $tag) { $tag = trim($tag); @@ -246,10 +298,6 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) { $settings['format_tags'] = implode(';', $block_formats); } - if (isset($config['apply_source_formatting'])) { - $settings['apply_source_formatting'] = $config['apply_source_formatting']; - } - if (isset($config['css_setting'])) { // Versions below 3.0.1 could only handle one stylesheet. if (version_compare($editor['installed version'], '3.0.1.4391', '<')) { @@ -275,23 +323,28 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) { // @todo This should be a plugin setting, but Wysiwyg does not support // plugin-specific settings yet. if (!empty($config['buttons']['default']['Styles']) && version_compare($editor['installed version'], '3.2.1', '>=')) { - if ($styles = wysiwyg_ckeditor_settings_parse_styles($config['css_classes'])) { + if ($styles = wysiwyg_ckeditor_settings_parse_styles($config['stylesSet'])) { $settings['stylesSet'] = $styles; } } - if (isset($config['language'])) { - $settings['language'] = $config['language']; + $check_if_set = array( + 'apply_source_formatting', + 'forcePasteAsPlainText', + 'language', + ); + foreach ($check_if_set as $setting_name) { + if (isset($config[$setting_name])) { + $settings[$setting_name] = $config[$setting_name]; + } } - if (isset($config['resizing'])) { + + if (isset($config['resize_enabled'])) { // CKEditor performs a type-agnostic comparison on this particular setting. - $settings['resize_enabled'] = (bool) $config['resizing']; - } - if (isset($config['toolbar_loc'])) { - $settings['toolbarLocation'] = $config['toolbar_loc']; + $settings['resize_enabled'] = (bool) $config['resize_enabled']; } - if (isset($config['paste_auto_cleanup_on_paste'])) { - $settings['forcePasteAsPlainText'] = $config['paste_auto_cleanup_on_paste']; + if (isset($config['toolbarLocation'])) { + $settings['toolbarLocation'] = $config['toolbarLocation']; } $settings['toolbar'] = array(); @@ -367,7 +420,7 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) { } /** - * Parses CSS classes settings string into a stylesSet JavaScript settings array. + * Parses stylesSet settings string into a stylesSet JavaScript settings array. * * @param string $css_classes * A string containing CSS class definitions to add to the Style dropdown diff --git a/editors/epiceditor.inc b/editors/epiceditor.inc index af0a6dc..4d3ecb0 100644 --- a/editors/epiceditor.inc +++ b/editors/epiceditor.inc @@ -25,6 +25,7 @@ function wysiwyg_epiceditor_editor() { ), 'version callback' => 'wysiwyg_epiceditor_version', 'themes callback' => 'wysiwyg_epiceditor_themes', + 'settings form callback' => 'wysiwyg_epiceditor_settings_form', 'settings callback' => 'wysiwyg_epiceditor_settings', 'versions' => array( '0.1.1' => array( @@ -77,6 +78,16 @@ function wysiwyg_epiceditor_themes($editor, $profile) { } /** + * Enhances the editor profile settings form for EpicEditor. + * + */ +function wysiwyg_epiceditor_settings_form(&$form, &$form_state) { + $form['buttons']['#access'] = FALSE; + $form['basic']['language']['#access'] = FALSE; + $form['css']['#access'] = FALSE; +} + +/** * Return runtime editor settings for a given wysiwyg profile. * * @param $editor diff --git a/editors/fckeditor.inc b/editors/fckeditor.inc index 27bcb7b..ef0c5d3 100644 --- a/editors/fckeditor.inc +++ b/editors/fckeditor.inc @@ -21,6 +21,7 @@ function wysiwyg_fckeditor_editor() { ), 'version callback' => 'wysiwyg_fckeditor_version', 'themes callback' => 'wysiwyg_fckeditor_themes', + 'settings form callback' => 'wysiwyg_fckeditor_settings_form', 'settings callback' => 'wysiwyg_fckeditor_settings', 'plugin callback' => 'wysiwyg_fckeditor_plugins', 'plugin settings callback' => 'wysiwyg_fckeditor_plugin_settings', @@ -83,6 +84,67 @@ function wysiwyg_fckeditor_themes($editor, $profile) { } /** + * Enhances the editor profile settings form for FCKeditor. + * + * @see http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options + */ +function wysiwyg_fckeditor_settings_form(&$form, &$form_state) { + $profile = $form_state['wysiwyg_profile']; + $settings = $profile->settings; + $settings += array( + // Enabled by default. + 'AutoDetectPasteFromWord' => TRUE, + 'FontFormats' => 'p;address;pre;h2;h3;h4;h5;h6;div', + 'FormatOutput' => TRUE, + 'FormatSource' => TRUE, + ); + $form['output']['FormatSource'] = array( + '#type' => 'checkbox', + '#title' => t('Apply source formatting'), + '#default_value' => $settings['FormatSource'], + '#return_value' => 1, + '#description' => t('If enabled, the editor will re-format the HTML source code when switching to Source View.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'FormatSource', '@url' => url('http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options/FormatSource'))), + ); + $form['output']['FormatOutput'] = array( + '#type' => 'checkbox', + '#title' => t('Apply output formatting'), + '#default_value' => $settings['FormatOutput'], + '#return_value' => 1, + '#description' => t('If enabled, the editor will re-format the HTML source code output. Disabling this option could avoid conflicts with other input filters.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'FormatOutput', '@url' => url('http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options/FormatOutput'))), + ); + $form['css']['FontFormats'] = array( + '#type' => 'textfield', + '#title' => t('Block formats'), + '#default_value' => $settings['FontFormats'], + '#size' => 40, + '#maxlength' => 250, + '#description' => t('Semicolon separated list of HTML block formats. Possible values: @format-list.', array('@format-list' => 'p;h1;h2;h3;h4;h5;h6;div;address;pre')) . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'FontFormats', '@url' => url('http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options/FontFormats'))), + ); + $form['paste'] = array( + '#type' => 'fieldset', + '#title' => t('Paste plugin'), + '#description' => t('Settings for the paste plugin.'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#group' => 'advanced', + ); + $form['paste']['AutoDetectPasteFromWord'] = array( + '#type' => 'checkbox', + '#title' => t('Auto detect paste from Word'), + '#default_value' => $settings['AutoDetectPasteFromWord'], + '#return_value' => 1, + '#description' => t('If enabled, FCKeditor checks if pasted text comes from MS Word. If so the editor will launch the "Paste from Word" window. Only works in Internet Explorer.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'AutoDetectPasteFromWord', '@url' => url('http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options/AutoDetectPasteFromWord'))), + ); + $form['paste']['ForcePasteAsPlainText'] = array( + '#type' => 'checkbox', + '#title' => t('Force paste as plain text'), + '#default_value' => !empty($settings['ForcePasteAsPlainText']), + '#return_value' => 1, + '#description' => t('If enabled, forces the editor to discard all formatting when pasting text. It will also disable the Paste from Word operation.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'ForcePasteAsPlainText', '@url' => url('http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options/ForcePasteAsPlainText'))), + ); +} + +/** * Return runtime editor settings for a given wysiwyg profile. * * @param $editor @@ -117,14 +179,20 @@ function wysiwyg_fckeditor_settings($editor, $config, $theme) { 'IncludeLatinEntities' => FALSE, 'IncludeGreekEntities' => FALSE, ); - if (isset($config['block_formats'])) { - $settings['FontFormats'] = strtr($config['block_formats'], array(',' => ';')); + if (isset($config['FontFormats'])) { + $settings['FontFormats'] = preg_replace('@\s+@', '', $config['FontFormats']); + } + if (isset($config['FormatOutput'])) { + $settings['FormatOutput'] = $config['FormatOutput']; + } + if (isset($config['FormatSource'])) { + $settings['FormatSource'] = $config['FormatSource']; } - if (isset($config['apply_source_formatting'])) { - $settings['FormatOutput'] = $settings['FormatSource'] = $config['apply_source_formatting']; + if (isset($config['ForcePasteAsPlainText'])) { + $settings['ForcePasteAsPlainText'] = $config['ForcePasteAsPlainText']; } - if (isset($config['paste_auto_cleanup_on_paste'])) { - $settings['AutoDetectPasteFromWord'] = $config['paste_auto_cleanup_on_paste']; + if (isset($config['AutoDetectPasteFromWord'])) { + $settings['AutoDetectPasteFromWord'] = $config['AutoDetectPasteFromWord']; } if (isset($config['css_setting'])) { diff --git a/editors/jwysiwyg.inc b/editors/jwysiwyg.inc index fa65b74..ae7ebda 100644 --- a/editors/jwysiwyg.inc +++ b/editors/jwysiwyg.inc @@ -24,6 +24,7 @@ function wysiwyg_jwysiwyg_editor() { ), ), 'version callback' => 'wysiwyg_jwysiwyg_version', + 'settings form callback' => 'wysiwyg_jwysiwyg_settings_form', // @todo Wrong property; add separate properties for editor requisites. 'css path' => wysiwyg_get_path('jwysiwyg'), 'versions' => array( @@ -37,6 +38,15 @@ function wysiwyg_jwysiwyg_editor() { } /** + * Enhances the editor profile settings form for jWYSIWYG. + */ +function wysiwyg_jwysiwyg_settings_form(&$form, &$form_state) { + $form['buttons']['#access'] = FALSE; + $form['basic']['language']['#access'] = FALSE; + $form['css']['#access'] = FALSE; +} + +/** * Detect editor version. * * @param $editor diff --git a/editors/markitup.inc b/editors/markitup.inc index 57a37e8..72dab5a 100644 --- a/editors/markitup.inc +++ b/editors/markitup.inc @@ -26,6 +26,7 @@ function wysiwyg_markitup_editor() { ), 'version callback' => 'wysiwyg_markitup_version', 'themes callback' => 'wysiwyg_markitup_themes', + 'settings form callback' => 'wysiwyg_markitup_settings_form', 'settings callback' => 'wysiwyg_markitup_settings', 'plugin callback' => 'wysiwyg_markitup_plugins', 'versions' => array( @@ -82,6 +83,14 @@ function wysiwyg_markitup_themes($editor, $profile) { } /** + * Enhances the editor profile settings form for markItUp. + */ +function wysiwyg_markitup_settings_form(&$form, &$form_state) { + $form['basic']['language']['#access'] = FALSE; + $form['css']['#access'] = FALSE; +} + +/** * Return runtime editor settings for a given wysiwyg profile. * * @param $editor diff --git a/editors/nicedit.inc b/editors/nicedit.inc index 6acc800..8a77564 100644 --- a/editors/nicedit.inc +++ b/editors/nicedit.inc @@ -20,6 +20,7 @@ function wysiwyg_nicedit_editor() { ), ), 'version callback' => 'wysiwyg_nicedit_version', + 'settings form callback' => 'wysiwyg_nicedit_settings_form', 'settings callback' => 'wysiwyg_nicedit_settings', 'plugin callback' => 'wysiwyg_nicedit_plugins', 'versions' => array( @@ -46,6 +47,18 @@ function wysiwyg_nicedit_version($editor) { } /** + * Enhances the editor profile settings form for NicEdit. + * + * @see http://wiki.nicedit.com/w/page/515/Configuration%20Options + */ +function wysiwyg_nicedit_settings_form(&$form, &$form_state) { + $form['basic']['language']['#access'] = FALSE; + // NicEdit only supports loading a single stylesheet, and only in FF2. + // This essentially means we're dropping stylesheet support for NiceEdit. + $form['css']['#access'] = FALSE; +} + +/** * Return runtime editor settings for a given wysiwyg profile. * * @param $editor @@ -75,6 +88,7 @@ function wysiwyg_nicedit_settings($editor, $config, $theme) { } // Add editor content stylesheet. + // @todo Drop stylsheet support since it's only used in FF2. if (isset($config['css_setting'])) { if ($config['css_setting'] == 'theme') { $css = drupal_get_path('theme', variable_get('theme_default', NULL)) . '/style.css'; diff --git a/editors/openwysiwyg.inc b/editors/openwysiwyg.inc index c135b2c..c79f7ab 100644 --- a/editors/openwysiwyg.inc +++ b/editors/openwysiwyg.inc @@ -22,6 +22,7 @@ function wysiwyg_openwysiwyg_editor() { ), 'version callback' => 'wysiwyg_openwysiwyg_version', 'themes callback' => 'wysiwyg_openwysiwyg_themes', + 'settings form callback' => 'wysiwyg_openwysiwyg_settings_form', 'settings callback' => 'wysiwyg_openwysiwyg_settings', 'plugin callback' => 'wysiwyg_openwysiwyg_plugins', 'versions' => array( @@ -75,6 +76,31 @@ function wysiwyg_openwysiwyg_themes($editor, $profile) { } /** + * Enhances the editor profile settings form for openWYSIWYG. + */ +function wysiwyg_openwysiwyg_settings_form(&$form, &$form_state) { + $profile = $form_state['wysiwyg_profile']; + $settings = $profile->settings; + + $settings += array( + // Enabled by default. + 'StatusBarEnabled' => TRUE, + ); + + $form['basic']['language']['#access'] = FALSE; + + $form['css']['#description'] = t('Note: openWYSIWYG can only load a single stylesheet into the editor.'); + + $form['appearance']['StatusBarEnabled'] = array( + '#type' => 'checkbox', + '#title' => t('Enable statusbar'), + '#default_value' => $settings['StatusBarEnabled'], + '#return_value' => 1, + '#description' => t('When enabled, shows a statusbar.'), + ); +} + +/** * Return runtime editor settings for a given wysiwyg profile. * * @param $editor @@ -94,8 +120,8 @@ function wysiwyg_openwysiwyg_settings($editor, $config, $theme) { 'Width' => '100%', ); - if (isset($config['path_loc']) && $config['path_loc'] == 'none') { - $settings['StatusBarEnabled'] = FALSE; + if (isset($config['StatusBarEnabeld'])) { + $settings['StatusBarEnabled'] = $config['StatusBarEnabled']; } if (isset($config['css_setting'])) { @@ -127,11 +153,6 @@ function wysiwyg_openwysiwyg_settings($editor, $config, $theme) { } } - // @todo -// if (isset($config['block_formats'])) { -// $settings['DropDowns']['headings']['elements'] = explode(',', $config['block_formats']); -// } - return $settings; } diff --git a/editors/tinymce.inc b/editors/tinymce.inc index fc48174..7ec0927 100644 --- a/editors/tinymce.inc +++ b/editors/tinymce.inc @@ -28,6 +28,7 @@ function wysiwyg_tinymce_editor() { ), 'version callback' => 'wysiwyg_tinymce_version', 'themes callback' => 'wysiwyg_tinymce_themes', + 'settings form callback' => 'wysiwyg_tinymce_settings_form', 'init callback' => 'wysiwyg_tinymce_init', 'settings callback' => 'wysiwyg_tinymce_settings', 'plugin callback' => 'wysiwyg_tinymce_plugins', @@ -127,6 +128,153 @@ function wysiwyg_tinymce_themes($editor, $profile) { } /** + * Enhances the editor profile settings form for TinyMCE. + * + * @see http://www.tinymce.com/wiki.php/Configuration + */ +function wysiwyg_tinymce_settings_form(&$form, &$form_state) { + $profile = $form_state['wysiwyg_profile']; + $settings = $profile->settings; + $settings += array( + // Enabled by default. + 'apply_source_formatting' => FALSE, + // Also available, but buggy in TinyMCE 2.x: blockquote,code,dt,dd,samp. + 'theme_advanced_blockformats' => 'p,address,pre,h2,h3,h4,h5,h6,div', + 'convert_fonts_to_spans' => TRUE, + 'paste_auto_cleanup_on_paste' => TRUE, + 'theme_advanced_statusbar_location' => 'bottom', + 'preformatted' => FALSE, + 'remove_linebreaks' => TRUE, + 'theme_advanced_resizing' => TRUE, + 'theme_advanced_toolbar_align' => 'left', + 'theme_advanced_toolbar_location' => 'top', + 'verify_html' => TRUE, + ); + + $form['appearance']['theme_advanced_toolbar_location'] = array( + '#type' => 'select', + '#title' => t('Toolbar location'), + '#default_value' => $settings['theme_advanced_toolbar_location'], + '#options' => array('bottom' => t('Bottom'), 'top' => t('Top')), + '#description' => t('This option controls whether the editor toolbar is displayed above or below the editing area.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'theme_advanced_toolbar_location', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:theme_advanced_toolbar_location'))), + ); + + $form['appearance']['theme_advanced_toolbar_align'] = array( + '#type' => 'select', + '#title' => t('Button alignment'), + '#default_value' => $settings['theme_advanced_toolbar_align'], + '#options' => array('center' => t('Center'), 'left' => t('Left'), 'right' => t('Right')), + '#description' => t('This option controls the alignment of icons in the editor toolbar.'), + ); + + $form['appearance']['theme_advanced_statusbar_location'] = array( + '#type' => 'select', + '#title' => t('Path location'), + '#default_value' => $settings['theme_advanced_statusbar_location'], + '#options' => array('none' => t('Hide'), 'top' => t('Top'), 'bottom' => t('Bottom')), + '#description' => t('Where to display the path to HTML elements (i.e. body > table > tr > td).') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'theme_advanced_statusbar_location', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:theme_advanced_statusbar_location'))), + ); + + $form['appearance']['theme_advanced_resizing'] = array( + '#type' => 'checkbox', + '#title' => t('Enable resizing button'), + '#default_value' => $settings['theme_advanced_resizing'], + '#return_value' => 1, + '#description' => t('This option gives you the ability to enable/disable the resizing button. If enabled, the Path location toolbar must be set to "Top" or "Bottom" in order to display the resize icon.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'theme_advanced_resizing', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:theme_advanced_resizing'))), + ); + + $form['output']['verify_html'] = array( + '#type' => 'checkbox', + '#title' => t('Verify HTML'), + '#default_value' => $settings['verify_html'], + '#return_value' => 1, + '#description' => t('If enabled, potentially malicious code like <HEAD> tags will be removed from HTML contents.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'verify_html', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:preformatted'))), + ); + + $form['output']['preformatted'] = array( + '#type' => 'checkbox', + '#title' => t('Preformatted'), + '#default_value' => $settings['preformatted'], + '#return_value' => 1, + '#description' => t('If enabled, the editor will insert TAB characters on tab and preserve other whitespace characters just like a PRE element in HTML does.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'preformatted', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:preformatted'))), + ); + + $form['output']['convert_fonts_to_spans'] = array( + '#type' => 'checkbox', + '#title' => t('Convert <font> tags to styles'), + '#default_value' => $settings['convert_fonts_to_spans'], + '#return_value' => 1, + '#description' => t('If enabled, HTML tags declaring the font size, font family, font color and font background color will be replaced by inline CSS styles.') . ' ' . t('Uses the @setting setting internally.', array( + '@setting' => 'convert_fonts_to_spans', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:convert_fonts_to_spans'))), + ); + + $form['output']['remove_linebreaks'] = array( + '#type' => 'checkbox', + '#title' => t('Remove linebreaks'), + '#default_value' => $settings['remove_linebreaks'], + '#return_value' => 1, + '#description' => t('If enabled, the editor will remove most linebreaks from contents. Disabling this option could avoid conflicts with other input filters.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'remove_linebreaks', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:remove_linebreaks'))), + ); + + $form['output']['apply_source_formatting'] = array( + '#type' => 'checkbox', + '#title' => t('Apply source formatting'), + '#default_value' => $settings['apply_source_formatting'], + '#return_value' => 1, + '#description' => t('If enabled, the editor will re-format the HTML source code. Disabling this option could avoid conflicts with other input filters.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'apply_source_formatting', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:apply_source_formatting'))), + ); + + $form['css']['theme_advanced_styles'] = array( + '#type' => 'textarea', + '#title' => t('CSS classes'), + '#default_value' => $settings['theme_advanced_styles'], + '#description' => t('Optionally define CSS classes for the "Font style" dropdown list.
Enter one class on each line in the format: !format. Example: !example
If left blank, CSS classes are automatically imported from all loaded stylesheet(s).', + array( + '!format' => '[title]=[class]', + '!example' => 'My heading=header1', + ) + ) . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'theme_advanced_styles', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:theme_advanced_styles'))), + ); + + + $form['css']['theme_advanced_blockformats'] = array( + '#type' => 'textfield', + '#title' => t('Block formats'), + '#default_value' => $settings['theme_advanced_blockformats'], + '#size' => 40, + '#maxlength' => 250, + '#description' => t('Comma separated list of HTML block formats. Possible values: @format-list.', array('@format-list' => 'p,h1,h2,h3,h4,h5,h6,div,blockquote,address,pre,code,dt,dd')) . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'theme_advanced_blockformats', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:theme_advanced_blockformats'))), + '#element_validate' => array('wysiwyg_tinymce_settings_form_validate_blockformats'), + ); + + $form['paste'] = array( + '#type' => 'fieldset', + '#title' => t('Paste plugin'), + '#description' => t('Settings for the paste plugin.'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#group' => 'advanced', + ); + $form['paste']['paste_auto_cleanup_on_paste'] = array( + '#type' => 'checkbox', + '#title' => t('Process contents on paste'), + '#default_value' => !empty($settings['paste_auto_cleanup_on_paste']), + '#return_value' => 1, + '#description' => t('If enabled, contents will be automatically processed when you paste using Ctrl+V or similar methods. Cleaning up contents from MS Word or pasting as plain text will not work without this.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'paste_auto_cleanup_on_paste', '@url' => url('http://www.tinymce.com/wiki.php/Plugin3x:paste'))), + '#element_validate' => array('wysiwyg_tinymce_settings_form_validate_blockformats'), + ); +} + +/** + * #element_validate handler for theme_advanced_blockformats element added by wysiwyg_tinymce_settings_form(). + */ +function wysiwyg_tinymce_settings_form_validate_blockformats($element, &$form_state) { + // Remove any white-space from 'theme_advanced_blockformats' setting, since + // the editor relies on a comma-separated list to explode(). + form_set_value($element, preg_replace('@\s+@', '', $element['#value']), $form_state); +} + +/** * Returns an initialization JavaScript for this editor library. * * @param array $editor @@ -194,31 +342,27 @@ function wysiwyg_tinymce_settings($editor, $config, $theme) { // XML default characters '&', '<', '>'. 'entities' => '160,nbsp,173,shy,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm', ); - if (isset($config['apply_source_formatting'])) { - $settings['apply_source_formatting'] = $config['apply_source_formatting']; - } - if (isset($config['convert_fonts_to_spans'])) { - $settings['convert_fonts_to_spans'] = $config['convert_fonts_to_spans']; - } - if (isset($config['language'])) { - $settings['language'] = $config['language']; - } - if (isset($config['paste_auto_cleanup_on_paste'])) { - $settings['paste_auto_cleanup_on_paste'] = $config['paste_auto_cleanup_on_paste']; - } - if (isset($config['preformatted'])) { - $settings['preformatted'] = $config['preformatted']; - } - if (isset($config['remove_linebreaks'])) { - $settings['remove_linebreaks'] = $config['remove_linebreaks']; + $check_if_set = array( + 'apply_source_formatting', + 'convert_fonts_to_spans', + 'language', + 'paste_auto_cleanup_on_paste', + 'preformatted', + 'remove_linebreaks', + 'theme_advanced_blockformats', + ); + foreach ($check_if_set as $setting_name) { + if (isset($config[$setting_name])) { + $settings[$setting_name] = $config[$setting_name]; + } } if (isset($config['verify_html'])) { // TinyMCE performs a type-agnostic comparison on this particular setting. $settings['verify_html'] = (bool) $config['verify_html']; } - if (!empty($config['css_classes'])) { - $settings['theme_advanced_styles'] = implode(';', array_filter(explode("\n", str_replace("\r", '', $config['css_classes'])))); + if (!empty($config['theme_advanced_styles'])) { + $settings['theme_advanced_styles'] = implode(';', array_filter(explode("\n", str_replace("\r", '', $config['theme_advanced_styles'])))); } if (isset($config['css_setting'])) { @@ -301,14 +445,11 @@ function wysiwyg_tinymce_settings($editor, $config, $theme) { $settings += array( 'theme_advanced_resize_horizontal' => FALSE, 'theme_advanced_resizing_use_cookie' => FALSE, - 'theme_advanced_statusbar_location' => isset($config['path_loc']) ? $config['path_loc'] : 'bottom', - 'theme_advanced_resizing' => isset($config['resizing']) ? $config['resizing'] : 1, - 'theme_advanced_toolbar_location' => isset($config['toolbar_loc']) ? $config['toolbar_loc'] : 'top', - 'theme_advanced_toolbar_align' => isset($config['toolbar_align']) ? $config['toolbar_align'] : 'left', + 'theme_advanced_statusbar_location' => isset($config['theme_advanced_statusbar_location']) ? $config['theme_advanced_statusbar_location'] : 'bottom', + 'theme_advanced_resizing' => isset($config['theme_advanced_resizing']) ? $config['theme_advanced_resizing'] : 1, + 'theme_advanced_toolbar_location' => isset($config['theme_advanced_toolbar_location']) ? $config['theme_advanced_toolbar_location'] : 'top', + 'theme_advanced_toolbar_align' => isset($config['theme_advanced_toolbar_align']) ? $config['theme_advanced_toolbar_align'] : 'left', ); - 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. diff --git a/editors/whizzywig.inc b/editors/whizzywig.inc index acfc7de..3c627c4 100644 --- a/editors/whizzywig.inc +++ b/editors/whizzywig.inc @@ -20,6 +20,7 @@ function wysiwyg_whizzywig_editor() { ), ), 'version callback' => 'wysiwyg_whizzywig_version', + 'settings form callback' => 'wysiwyg_whizzywig_settings_form', 'settings callback' => 'wysiwyg_whizzywig_settings', 'plugin callback' => 'wysiwyg_whizzywig_plugins', 'versions' => array( @@ -63,6 +64,15 @@ function wysiwyg_whizzywig_version($editor) { } /** + * Enhances the editor profile settings form for Whizzywig. + */ +function wysiwyg_whizzywig_settings_form(&$form, &$form_state) { + $form['basic']['language']['#access'] = FALSE; + // @todo CSS settings are currently not used. + $form['css']['#access'] = FALSE; +} + +/** * Return runtime editor settings for a given wysiwyg profile. * * @param $editor @@ -102,6 +112,7 @@ function wysiwyg_whizzywig_settings($editor, $config, $theme) { } // Add editor content stylesheet. + // @todo CSS settings are currently not used. if (isset($config['css_setting'])) { if ($config['css_setting'] == 'theme') { $css = drupal_get_path('theme', variable_get('theme_default', NULL)) . '/style.css'; diff --git a/editors/wymeditor.inc b/editors/wymeditor.inc index 5f44d64..1ec6e5f 100644 --- a/editors/wymeditor.inc +++ b/editors/wymeditor.inc @@ -30,6 +30,7 @@ function wysiwyg_wymeditor_editor() { ), 'version callback' => 'wysiwyg_wymeditor_version', 'themes callback' => 'wysiwyg_wymeditor_themes', + 'settings form callback' => 'wysiwyg_wymeditor_settings_form', 'settings callback' => 'wysiwyg_wymeditor_settings', 'plugin callback' => 'wysiwyg_wymeditor_plugins', 'versions' => array( @@ -82,6 +83,31 @@ function wysiwyg_wymeditor_themes($editor, $profile) { } /** + * Enhances the editor profile settings form for WYMeditor. + * + * @see http://wymeditor.readthedocs.org/en/latest/version_1.0_and_0.5/getting_started/customize.html + */ +function wysiwyg_wymeditor_settings_form(&$form, &$form_state) { + $profile = $form_state['wysiwyg_profile']; + $settings = $profile->settings; + + $settings += array( + 'block_formats' => 'p,blockquote,pre,h2,h3,h4,h5,h6,div', + ); + + $form['css']['#description'] = t('Note: WYMeditor can only load a single stylesheet into the editor.'); + + $form['css']['block_formats'] = array( + '#type' => 'textfield', + '#title' => t('Block formats'), + '#default_value' => $settings['block_formats'], + '#size' => 40, + '#maxlength' => 250, + '#description' => t('Comma separated list of HTML block formats. Possible values: @format-list.', array('@format-list' => 'p,h1,h2,h3,h4,h5,h6,blockquote,pre,th')), + ); +} + +/** * Return runtime editor settings for a given wysiwyg profile. * * @param $editor @@ -158,7 +184,7 @@ function wysiwyg_wymeditor_settings($editor, $config, $theme) { 'blockquote' => 'Blockquote', 'th' => 'Table_Header', ); - foreach (explode(',', $config['block_formats']) as $tag) { + foreach (explode(',', preg_replace('@\s+@', '', $config['block_formats'])) as $tag) { if (isset($containers[$tag])) { $settings['containersItems'][] = array( 'name' => strtoupper($tag), @@ -169,6 +195,7 @@ function wysiwyg_wymeditor_settings($editor, $config, $theme) { } } + // Add editor content stylesheet. if (isset($config['css_setting'])) { if ($config['css_setting'] == 'theme') { // WYMeditor only supports one CSS file currently. diff --git a/editors/yui.inc b/editors/yui.inc index 36d0a59..1f7d889 100644 --- a/editors/yui.inc +++ b/editors/yui.inc @@ -42,6 +42,7 @@ function wysiwyg_yui_editor() { ), 'version callback' => 'wysiwyg_yui_version', 'themes callback' => 'wysiwyg_yui_themes', + 'settings form callback' => 'wysiwyg_yui_settings_form', 'load callback' => 'wysiwyg_yui_load', 'settings callback' => 'wysiwyg_yui_settings', 'plugin callback' => 'wysiwyg_yui_plugins', @@ -105,6 +106,44 @@ function wysiwyg_yui_themes($editor, $profile) { } /** + * Enhances the editor profile settings form for YUI. + * + * @see http://developer.yahoo.com/yui/docs/YAHOO.widget.Editor.html + */ +function wysiwyg_yui_settings_form(&$form, &$form_state) { + $profile = $form_state['wysiwyg_profile']; + $settings = $profile->settings; + $settings += array( + 'block_formats' => 'p,h1,h2,h3,h4,h5,h6', + ); + + $form['basic']['language']['#access'] = FALSE; + + $profile = $form_state['wysiwyg_profile']; + $settings = $profile->settings; + + $settings += array( + ); + + $form['appearance']['autoHeight'] = array( + '#type' => 'checkbox', + '#title' => t('Enable automatic height'), + '#default_value' => $settings['autoHeight'], + '#return_value' => 1, + '#description' => t('When enabled, removes the scrollbars from the edit area and resizes it to fit the content.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'autoHeight', '@url' => url('http://developer.yahoo.com/yui/docs/YAHOO.widget.SimpleEditor.html#config_autoHeight'))), + ); + + $form['css']['block_formats'] = array( + '#type' => 'textfield', + '#title' => t('Block formats'), + '#default_value' => $settings['block_formats'], + '#size' => 40, + '#maxlength' => 250, + '#description' => t('Comma separated list of HTML block formats. Possible values: @format-list.', array('@format-list' => 'p,h1,h2,h3,h4,h5,h6,')), + ); +} + +/** * Perform additional actions upon loading this editor. * * @param $editor @@ -143,11 +182,7 @@ function wysiwyg_yui_settings($editor, $config, $theme) { 'ptags' => TRUE, ); - if (isset($config['path_loc']) && $config['path_loc'] != 'none') { - $settings['dompath'] = $config['path_loc']; - } - // Enable auto-height feature when editor should be resizable. - if (!empty($config['resizing'])) { + if (!empty($config['autoHeight'])) { $settings['autoHeight'] = TRUE; } @@ -178,7 +213,7 @@ function wysiwyg_yui_settings($editor, $config, $theme) { 'h5' => array('text' => 'Heading 5', 'value' => 'h5'), 'h6' => array('text' => 'Heading 6', 'value' => 'h6'), ); - foreach (explode(',', $config['block_formats']) as $tag) { + foreach (explode(',', preg_replace('@\s+@', '', $config['block_formats'])) as $tag) { if (isset($headings[$tag])) { $extra['menu'][] = $headings[$tag]; } diff --git a/wysiwyg.admin.inc b/wysiwyg.admin.inc index 0a37063..77e6fdf 100644 --- a/wysiwyg.admin.inc +++ b/wysiwyg.admin.inc @@ -18,30 +18,16 @@ function wysiwyg_profile_form($form, &$form_state, $profile) { if (empty($profile['settings'])) { $profile['settings'] = array(); } - $profile['settings'] += array( + $settings = &$profile['settings']; + $settings += array( 'default' => TRUE, 'user_choose' => FALSE, 'show_toggle' => TRUE, - 'theme' => 'advanced', + 'theme' => '', 'language' => 'en', - 'access' => 1, - 'access_pages' => "node/*\nuser/*\ncomment/*", 'buttons' => array(), - 'toolbar_loc' => 'top', - 'toolbar_align' => 'left', - 'path_loc' => 'bottom', - 'resizing' => TRUE, - // Also available, but buggy in TinyMCE 2.x: blockquote,code,dt,dd,samp. - 'block_formats' => 'p,address,pre,h2,h3,h4,h5,h6,div', - 'verify_html' => TRUE, - 'preformatted' => FALSE, - 'convert_fonts_to_spans' => TRUE, - 'remove_linebreaks' => TRUE, - 'apply_source_formatting' => FALSE, - 'paste_auto_cleanup_on_paste' => FALSE, 'css_setting' => 'theme', 'css_path' => NULL, - 'css_classes' => NULL, ); $profile = (object) $profile; @@ -64,7 +50,7 @@ function wysiwyg_profile_form($form, &$form_state, $profile) { $form['basic']['default'] = array( '#type' => 'checkbox', '#title' => t('Enabled by default'), - '#default_value' => $profile->settings['default'], + '#default_value' => $settings['default'], '#return_value' => 1, '#description' => t('The default editor state for users having access to this profile. Users are able to override this state if the next option is enabled.'), ); @@ -72,7 +58,7 @@ function wysiwyg_profile_form($form, &$form_state, $profile) { $form['basic']['user_choose'] = array( '#type' => 'checkbox', '#title' => t('Allow users to choose default'), - '#default_value' => $profile->settings['user_choose'], + '#default_value' => $settings['user_choose'], '#return_value' => 1, '#description' => t('If allowed, users will be able to choose their own editor default state in their user account settings.'), ); @@ -80,20 +66,20 @@ function wysiwyg_profile_form($form, &$form_state, $profile) { $form['basic']['show_toggle'] = array( '#type' => 'checkbox', '#title' => t('Show enable/disable rich text toggle link'), - '#default_value' => $profile->settings['show_toggle'], + '#default_value' => $settings['show_toggle'], '#return_value' => 1, '#description' => t('Whether or not to show the enable/disable rich text toggle link below a textarea. If disabled, the user setting or global default is used (see above).'), ); $form['basic']['theme'] = array( '#type' => 'hidden', - '#value' => $profile->settings['theme'], + '#value' => $settings['theme'], ); $form['basic']['language'] = array( '#type' => 'select', '#title' => t('Interface language'), - '#default_value' => $profile->settings['language'], + '#default_value' => $settings['language'], ); // @see _locale_prepare_predefined_list() require_once DRUPAL_ROOT . '/includes/iso.inc'; @@ -139,7 +125,7 @@ function wysiwyg_profile_form($form, &$form_state, $profile) { $form['buttons'][$name][$button] = array( '#type' => 'checkbox', '#title' => $title, - '#default_value' => !empty($profile->settings['buttons'][$name][$button]) ? $profile->settings['buttons'][$name][$button] : FALSE, + '#default_value' => !empty($settings['buttons'][$name][$button]) ? $settings['buttons'][$name][$button] : FALSE, '#description' => isset($meta['url']) ? l($meta['url'], $meta['url']) : NULL, ); } @@ -149,7 +135,7 @@ function wysiwyg_profile_form($form, &$form_state, $profile) { $form['buttons'][$name][$extension] = array( '#type' => 'checkbox', '#title' => check_plain($title), - '#default_value' => !empty($profile->settings['buttons'][$name][$extension]) ? $profile->settings['buttons'][$name][$extension] : FALSE, + '#default_value' => !empty($settings['buttons'][$name][$extension]) ? $settings['buttons'][$name][$extension] : FALSE, '#description' => isset($meta['url']) ? l($meta['url'], $meta['url']) : NULL, ); } @@ -164,38 +150,6 @@ function wysiwyg_profile_form($form, &$form_state, $profile) { '#group' => 'advanced', ); - $form['appearance']['toolbar_loc'] = array( - '#type' => 'select', - '#title' => t('Toolbar location'), - '#default_value' => $profile->settings['toolbar_loc'], - '#options' => array('bottom' => t('Bottom'), 'top' => t('Top')), - '#description' => t('This option controls whether the editor toolbar is displayed above or below the editing area.'), - ); - - $form['appearance']['toolbar_align'] = array( - '#type' => 'select', - '#title' => t('Button alignment'), - '#default_value' => $profile->settings['toolbar_align'], - '#options' => array('center' => t('Center'), 'left' => t('Left'), 'right' => t('Right')), - '#description' => t('This option controls the alignment of icons in the editor toolbar.'), - ); - - $form['appearance']['path_loc'] = array( - '#type' => 'select', - '#title' => t('Path location'), - '#default_value' => $profile->settings['path_loc'], - '#options' => array('none' => t('Hide'), 'top' => t('Top'), 'bottom' => t('Bottom')), - '#description' => t('Where to display the path to HTML elements (i.e. body > table > tr > td).'), - ); - - $form['appearance']['resizing'] = array( - '#type' => 'checkbox', - '#title' => t('Enable resizing button'), - '#default_value' => $profile->settings['resizing'], - '#return_value' => 1, - '#description' => t('This option gives you the ability to enable/disable the resizing button. If enabled, the Path location toolbar must be set to "Top" or "Bottom" in order to display the resize icon.'), - ); - $form['output'] = array( '#type' => 'fieldset', '#title' => t('Cleanup and output'), @@ -204,54 +158,6 @@ function wysiwyg_profile_form($form, &$form_state, $profile) { '#group' => 'advanced', ); - $form['output']['verify_html'] = array( - '#type' => 'checkbox', - '#title' => t('Verify HTML'), - '#default_value' => $profile->settings['verify_html'], - '#return_value' => 1, - '#description' => t('If enabled, potentially malicious code like <HEAD> tags will be removed from HTML contents.'), - ); - - $form['output']['preformatted'] = array( - '#type' => 'checkbox', - '#title' => t('Preformatted'), - '#default_value' => $profile->settings['preformatted'], - '#return_value' => 1, - '#description' => t('If enabled, the editor will insert TAB characters on tab and preserve other whitespace characters just like a PRE element in HTML does.'), - ); - - $form['output']['convert_fonts_to_spans'] = array( - '#type' => 'checkbox', - '#title' => t('Convert <font> tags to styles'), - '#default_value' => $profile->settings['convert_fonts_to_spans'], - '#return_value' => 1, - '#description' => t('If enabled, HTML tags declaring the font size, font family, font color and font background color will be replaced by inline CSS styles.'), - ); - - $form['output']['remove_linebreaks'] = array( - '#type' => 'checkbox', - '#title' => t('Remove linebreaks'), - '#default_value' => $profile->settings['remove_linebreaks'], - '#return_value' => 1, - '#description' => t('If enabled, the editor will remove most linebreaks from contents. Disabling this option could avoid conflicts with other input filters.'), - ); - - $form['output']['apply_source_formatting'] = array( - '#type' => 'checkbox', - '#title' => t('Apply source formatting'), - '#default_value' => $profile->settings['apply_source_formatting'], - '#return_value' => 1, - '#description' => t('If enabled, the editor will re-format the HTML source code. Disabling this option could avoid conflicts with other input filters.'), - ); - - $form['output']['paste_auto_cleanup_on_paste'] = array( - '#type' => 'checkbox', - '#title' => t('Force cleanup on standard paste'), - '#default_value' => $profile->settings['paste_auto_cleanup_on_paste'], - '#return_value' => 1, - '#description' => t('If enabled, the default paste function (CTRL-V or SHIFT-INS) behaves like the "paste from word" plugin function.'), - ); - $form['css'] = array( '#type' => 'fieldset', '#title' => t('CSS'), @@ -260,19 +166,10 @@ function wysiwyg_profile_form($form, &$form_state, $profile) { '#group' => 'advanced', ); - $form['css']['block_formats'] = array( - '#type' => 'textfield', - '#title' => t('Block formats'), - '#default_value' => $profile->settings['block_formats'], - '#size' => 40, - '#maxlength' => 250, - '#description' => t('Comma separated list of HTML block formats. Possible values: @format-list.', array('@format-list' => 'p,h1,h2,h3,h4,h5,h6,div,blockquote,address,pre,code,dt,dd')), - ); - $form['css']['css_setting'] = array( '#type' => 'select', '#title' => t('Editor CSS'), - '#default_value' => $profile->settings['css_setting'], + '#default_value' => $settings['css_setting'], '#options' => array('theme' => t('Use theme CSS'), 'self' => t('Define CSS'), 'none' => t('Editor default CSS')), '#description' => t('Defines the CSS to be used in the editor area.
Use theme CSS - loads stylesheets from current site theme.
Define CSS - enter path for stylesheet files below.
Editor default CSS - uses default stylesheets from editor.'), ); @@ -280,19 +177,12 @@ function wysiwyg_profile_form($form, &$form_state, $profile) { $form['css']['css_path'] = array( '#type' => 'textfield', '#title' => t('CSS path'), - '#default_value' => $profile->settings['css_path'], + '#default_value' => $settings['css_path'], '#size' => 40, '#maxlength' => 255, '#description' => t('If "Define CSS" was selected above, enter path to a CSS file or a list of CSS files separated by a comma.') . '
' . t('Available tokens: %b (base path, eg: /), %t (path to theme, eg: themes/garland)') . '
' . t('Example:') . ' css/editor.css,/themes/garland/style.css,%b%t/style.css,http://example.com/external.css', ); - $form['css']['css_classes'] = array( - '#type' => 'textarea', - '#title' => t('CSS classes'), - '#default_value' => $profile->settings['css_classes'], - '#description' => t('Optionally define CSS classes for the "Font style" dropdown list.
Enter one class on each line in the format: !format. Example: !example
If left blank, CSS classes are automatically imported from all loaded stylesheet(s).', array('!format' => '[title]=[class]', '!example' => 'My heading=header1')), - ); - $form['advanced'] = array( '#type' => 'vertical_tabs', '#weight' => 50, @@ -322,6 +212,12 @@ function wysiwyg_profile_form($form, &$form_state, $profile) { $editor['settings form callback']($form, $form_state); } + foreach (array('appearance', 'output') as $fieldset) { + if (count(element_children($form[$fieldset])) == 0) { + $form[$fieldset]['#access'] = FALSE; + } + } + return $form; } @@ -340,9 +236,6 @@ function wysiwyg_profile_form_submit($form, &$form_state) { // Store only enabled plugins. $values['buttons'] = array_filter($values['buttons']); } - // Remove any white-space from 'block_formats' setting, since editor - // implementations rely on a comma-separated list to explode(). - $values['block_formats'] = preg_replace('@\s+@', '', $values['block_formats']); // Remove input format name. $format = $values['format']; diff --git a/wysiwyg.install b/wysiwyg.install index 9832b7d..87fc86f 100644 --- a/wysiwyg.install +++ b/wysiwyg.install @@ -340,3 +340,113 @@ function wysiwyg_update_7201() { } } } + +/** + * Update internal names of settings. + */ +function wysiwyg_update_7202() { + $query = db_select('wysiwyg', 'w') + ->fields('w', array('format', 'editor', 'settings')); + foreach ($query->execute() as $profile) { + $settings = unserialize($profile->settings); + $changed = FALSE; + switch ($profile->editor) { + case 'tinymce': + if (isset($settings['path_loc'])) { + $settings['theme_advanced_statusbar_location'] = $settings['path_loc']; + unset($settings['path_loc']); + $changed = TRUE; + } + if (isset($settings['toolbar_loc'])) { + $settings['theme_advanced_toolbar_location'] = $settings['toolbar_loc']; + unset($settings['toolbar_loc']); + $changed = TRUE; + } + if (isset($settings['toolbar_align'])) { + $settings['theme_advanced_toolbar_align'] = $settings['toolbar_align']; + unset($settings['toolbar_align']); + $changed = TRUE; + } + if (isset($settings['block_formats'])) { + $settings['theme_advanced_blockformats'] = $settings['block_formats']; + unset($settings['block_formats']); + $changed = TRUE; + } + if (isset($settings['css_classes'])) { + $settings['theme_advanced_styles'] = $settings['css_classes']; + unset($settings['css_classes']); + $changed = TRUE; + } + if (isset($settings['resizing'])) { + $settings['theme_advanced_resizing'] = $settings['resizing']; + unset($settings['resizing']); + $changed = TRUE; + } + break; + case 'ckeditor': + if (isset($settings['resizing'])) { + $settings['resize_enabled'] = $settings['resizing']; + unset($settings['resizing']); + $changed = TRUE; + } + if (isset($settings['toolbar_loc'])) { + $settings['toolbarLocation'] = $settings['toolbar_loc']; + unset($settings['toolbar_loc']); + $changed = TRUE; + } + if (isset($settings['paste_auto_cleanup_on_paste'])) { + $settings['forcePasteAsPlainText'] = $settings['paste_auto_cleanup_on_paste']; + unset($settings['paste_auto_cleanup_on_paste']); + $changed = TRUE; + } + if (isset($settings['css_classes'])) { + $settings['stylesSet'] = $settings['css_classes']; + unset($settings['css_classes']); + $changed = TRUE; + } + break; + case 'fckeditor': + if (isset($settings['apply_source_formatting'])) { + $settings['FormatSource'] = $settings['FormatOutput'] = $settings['apply_source_formatting']; + unset($settings['apply_source_formatting']); + $changed = TRUE; + } + if (isset($settings['paste_auto_cleanup_on_paste'])) { + $settings['ForcePasteAsPlainText'] = $settings['paste_auto_cleanup_on_paste']; + unset($settings['paste_auto_cleanup_on_paste']); + $changed = TRUE; + } + if (isset($settings['block_formats'])) { + $settings['FontFormats'] = strtr($settings['block_formats'], array(',' => ';')); + unset($settings['block_formats']); + $changed = TRUE; + } + break; + case 'yui': + // The resizing setting is triggering autoHeight instead of resize. + if (isset($settings['resizing'])) { + $settings['autoHeight'] = $settings['resizing']; + unset($settings['resizing']); + $changed = TRUE; + } + break; + case 'openwysiwyg': + if (isset($settings['path_loc'])) { + $settings['StatusBarEnabled'] = ($settings['path_loc'] != 'none' ); + unset($settings['path_loc']); + $changed = TRUE; + } + break; + default: + // Do not touch any other profiles since the extra settings won't hurt. + } + if ($changed) { + db_update('wysiwyg') + ->condition('format', $profile->format) + ->fields(array( + 'settings' => serialize($settings), + )) + ->execute(); + } + } +}