function wysiwyg_tinymce_settings_form in Wysiwyg 6.2
Same name and namespace in other branches
- 7.2 editors/tinymce.inc \wysiwyg_tinymce_settings_form()
Enhances the editor profile settings form for TinyMCE.
See also
http://www.tinymce.com/wiki.php/Configuration
1 string reference to 'wysiwyg_tinymce_settings_form'
- wysiwyg_tinymce_editor in editors/
tinymce.inc - Plugin implementation of hook_editor().
File
- editors/
tinymce.inc, line 153 - Editor integration functions for TinyMCE.
Code
function wysiwyg_tinymce_settings_form(&$form, &$form_state) {
$version = $form_state['wysiwyg']['editor']['installed version'];
$profile = $form_state['wysiwyg_profile'];
$settings = $profile->settings;
$default_settings = array(
'convert_fonts_to_spans' => TRUE,
'paste_convert_middot_lists' => TRUE,
'paste_max_consecutive_linebreaks' => 2,
'paste_retain_style_properties' => 'none',
'paste_remove_styles' => TRUE,
'paste_remove_styles_if_webkit' => TRUE,
'paste_strip_class_attributes' => 'mso',
'paste_text_linebreaktype' => 'combined',
'verify_html' => TRUE,
);
if (version_compare($version, '3.2.5', '>=')) {
$default_settings['autoresize_min_height'] = NULL;
$default_settings['autoresize_max_height'] = NULL;
}
if (version_compare($version, '3.3', '>=')) {
$default_settings['style_formats'] = '';
$default_settings['formats'] = '';
}
if (version_compare($version, '3.4b1', '>=')) {
$default_settings['indent'] = FALSE;
}
else {
$default_settings['apply_source_formatting'] = FALSE;
}
if (version_compare($version, '4', '>=')) {
$default_settings += array(
'block_formats' => '',
'image_advtab' => FALSE,
'paste_as_text' => FALSE,
'paste_data_images' => FALSE,
'resize' => TRUE,
'menu' => NULL,
'image_title' => TRUE,
);
}
else {
$default_settings += array(
'paste_auto_cleanup_on_paste' => TRUE,
'preformatted' => FALSE,
'remove_linebreaks' => TRUE,
// 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',
'theme_advanced_path' => TRUE,
'theme_advanced_statusbar_location' => 'bottom',
'theme_advanced_styles' => '',
'theme_advanced_resize_horizontal' => FALSE,
'theme_advanced_resizing' => TRUE,
'theme_advanced_toolbar_align' => 'left',
'theme_advanced_toolbar_location' => 'top',
);
}
$settings += $default_settings;
if (version_compare($version, '3.4b1', '<')) {
$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.') . ' ' . _wysiwyg_tinymce_get_setting_description('apply_source_formatting'),
);
}
else {
$form['output']['indent'] = array(
'#type' => 'checkbox',
'#title' => t('Indent source'),
'#default_value' => $settings['indent'],
'#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']['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 <code><HEAD></code> tags will be removed from HTML contents.') . (_wysiwyg_tinymce_is_v3() ? ' ' . _wysiwyg_tinymce_get_setting_description('verify_html') : ''),
);
$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.') . ' ' . _wysiwyg_tinymce_get_setting_description('convert_fonts_to_spans', 'content-filtering'),
);
if (version_compare($version, '4', '<')) {
$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.') . ' ' . _wysiwyg_tinymce_get_setting_description('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.') . ' ' . _wysiwyg_tinymce_get_setting_description('theme_advanced_toolbar_align'),
);
$form['appearance']['theme_advanced_statusbar_location'] = array(
'#type' => 'select',
'#title' => t('Status bar location'),
'#default_value' => $settings['theme_advanced_statusbar_location'],
'#options' => array(
'none' => t('Hide'),
'top' => t('Top'),
'bottom' => t('Bottom'),
),
'#description' => t('This option enables you to specify where the element statusbar with the path and resize tool should be located.') . ' ' . _wysiwyg_tinymce_get_setting_description('theme_advanced_statusbar_location'),
);
$form['appearance']['theme_advanced_path'] = array(
'#type' => 'checkbox',
'#title' => t('Enable the element path'),
'#default_value' => $settings['theme_advanced_path'],
'#return_value' => 1,
'#description' => t('This option gives you the ability to enable/disable the element path.') . ' ' . _wysiwyg_tinymce_get_setting_description('theme_advanced_path'),
'#states' => array(
'invisible' => array(
':input[name="theme_advanced_statusbar_location"]' => array(
'value' => 'none',
),
),
),
);
$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.') . ' ' . _wysiwyg_tinymce_get_setting_description('theme_advanced_resizing'),
'#states' => array(
'invisible' => array(
':input[name="theme_advanced_statusbar_location"]' => array(
'value' => 'none',
),
),
),
);
$form['appearance']['theme_advanced_resize_horizontal'] = array(
'#type' => 'checkbox',
'#title' => t('Enable horizontal resizing'),
'#default_value' => $settings['theme_advanced_resize_horizontal'],
'#return_value' => 1,
'#description' => t('This option gives you the ability to enable/disable the horizontal resizing. If enabled, the Path location toolbar must be set to "Top" or "Bottom" in order to display the resize icon.') . ' ' . _wysiwyg_tinymce_get_setting_description('theme_advanced_resize_horizontal'),
);
$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.') . ' ' . _wysiwyg_tinymce_get_setting_description('remove_linebreaks'),
);
$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.') . ' ' . _wysiwyg_tinymce_get_setting_description('preformatted'),
);
$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: <code>@format-list</code>.', array(
'@format-list' => 'p,h1,h2,h3,h4,h5,h6,div,blockquote,address,pre,code,dt,dd',
)) . ' ' . _wysiwyg_tinymce_get_setting_description('theme_advanced_blockformats'),
'#element_validate' => array(
'wysiwyg_tinymce_settings_form_validate_blockformats',
),
'#weight' => 30,
);
$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.<br />Enter one class on each line in the format: !format. Example: !example<br />If left blank, CSS classes are automatically imported from all loaded stylesheet(s).', array(
'!format' => '<code>[title]=[class]</code>',
'!example' => 'My heading=header1',
)) . ' ' . _wysiwyg_tinymce_get_setting_description('theme_advanced_styles'),
'#weight' => 40,
);
}
if (version_compare($version, '3.3', '>=')) {
if (version_compare($version, '4', '>=')) {
$form['css']['theme_advanced_styles']['#access'] = FALSE;
}
else {
$form['css']['theme_advanced_styles']['#description'] .= '<br />' . t('This setting is only used if <em>Style formats</em> is empty.');
}
$form['css']['style_formats'] = array(
'#type' => 'textarea',
'#title' => t('Style formats'),
'#default_value' => $settings['style_formats'],
'#description' => t('A JSON object containing advanced style formats for text and other elements to add to the editor. The value will be rendered as styles in the Formats dropdown.') . ' ' . _wysiwyg_tinymce_get_setting_description('style_formats', 'content-formatting'),
'#element_validate' => array(
'_wysiwyg_tinymce_settings_form_validate_style_formats',
),
'#weight' => 40,
);
$form['css']['formats'] = array(
'#type' => 'textarea',
'#title' => t('Formats'),
'#default_value' => $settings['formats'],
'#description' => t('This option enables you to override and add custom formats. A format is for example the style that get applied when you press the bold button inside the editor. TinyMCE has some built in formats that you can override, see the editor documentation for the complete list. The value to put in should be a JSON object containing format definitions.') . ' ' . _wysiwyg_tinymce_get_setting_description('formats', 'content-formatting'),
'#element_validate' => array(
'_wysiwyg_tinymce_settings_form_validate_formats',
),
'#weight' => 50,
);
}
if (version_compare($version, '4', '>=')) {
$form['image'] = array(
'#type' => 'fieldset',
'#title' => t('Image plugin'),
'#description' => t('Settings for the <a href="@url">@plugin</a> plugin.', array(
'@plugin' => 'image',
'@url' => _wysiwyg_tinymce_get_plugin_url('image'),
)),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'advanced',
);
$form['image']['image_advtab'] = array(
'#type' => 'checkbox',
'#title' => t('Advanced tab'),
'#default_value' => $settings['image_advtab'],
'#return_value' => 1,
'#description' => t('Enable the advanced tab in the image dialog.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('image', 'image_advtab'),
);
$form['image']['image_title'] = array(
'#type' => 'checkbox',
'#title' => t('Show title input'),
'#default_value' => $settings['image_title'],
'#return_value' => TRUE,
'#description' => t('Enable the image title in the image dialog.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('image', 'image_title'),
);
if (version_compare($version, '4.0.13', '>=')) {
$form['css']['style_formats_merge'] = array(
'#type' => 'checkbox',
'#title' => t('Merge style formats'),
'#default_value' => !empty($settings['style_formats_merge']),
'#return_value' => 1,
'#description' => t('Append the styles formats to the default set instead of replacing it completely.') . ' ' . _wysiwyg_tinymce_get_setting_description('style_formats_merge', 'content-formatting'),
'#weight' => 41,
);
}
$form['css']['block_formats'] = array(
'#type' => 'textfield',
'#title' => t('Block formats'),
'#default_value' => $settings['block_formats'],
'#size' => 40,
'#maxlength' => 250,
'#description' => t('Semi-colon separated list of block formats for the block listbox. The format is: <code>@format-list</code>.', array(
'@format-list' => 'Paragraph=p;Header 1=h1;Header 2=h2;Header 3=h3',
)) . ' ' . _wysiwyg_tinymce_get_setting_description('block_formats', 'content-formatting'),
'#weight' => 20,
);
}
$form['paste'] = array(
'#type' => 'fieldset',
'#title' => t('Paste plugin'),
'#description' => t('Settings for the <a href="@url">@plugin</a> plugin.', array(
'@plugin' => 'paste',
'@url' => _wysiwyg_tinymce_get_plugin_url('paste'),
)),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'advanced',
);
if (version_compare($version, '4', '<')) {
$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 <strong>not</strong> work without this.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('paste', 'paste_auto_cleanup_on_paste'),
'#element_validate' => array(
'wysiwyg_tinymce_settings_form_validate_blockformats',
),
);
}
$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 <strong>not</strong> work without this.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('paste', 'paste_auto_cleanup_on_paste'),
);
$form['paste']['paste_block_drop'] = array(
'#type' => 'checkbox',
'#title' => t('Block drag/drop'),
'#default_value' => !empty($settings['paste_block_drop']),
'#return_value' => 1,
'#description' => t('If enabled, blocks drag/drop from/to the editor and inside it.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('paste', 'paste_block_drop'),
);
$form['paste']['paste_retain_style_properties'] = array(
'#type' => 'textfield',
'#title' => t('Retain style properties'),
'#default_value' => $settings['paste_retain_style_properties'],
'#description' => t('Comma separated list of style properties to retain during the paste operation from Word. For example: "font-size,color". If you want to remove all style properties use an empty string "" or "none". If you want to keep all style properties, use "all" or "*".') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('paste', 'paste_retain_style_properties'),
);
$form['paste']['paste_strip_class_attributes'] = array(
'#type' => 'select',
'#title' => t('Strip class attributes'),
'#options' => array(
'none' => t('None'),
'all' => t('All'),
'mso' => t('MS Office'),
),
'#default_value' => $settings['paste_strip_class_attributes'],
'#description' => t('Enables you to strip the class attributes when pasted.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('paste', 'paste_strip_class*attributes'),
);
$form['paste']['paste_remove_spans'] = array(
'#type' => 'checkbox',
'#title' => t('Remove spans'),
'#default_value' => !empty($settings['paste_remove_spans']),
'#return_value' => 1,
'#description' => t('If enabled, removes all span elements when pasting.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('paste', 'paste_remove_spans'),
);
$form['paste']['paste_remove_styles'] = array(
'#type' => 'checkbox',
'#title' => t('Remove styles'),
'#default_value' => !empty($settings['paste_remove_styles']),
'#return_value' => 1,
'#description' => t('If enabled, removes all style information when pasting, regardless of browser type. Pasting from Word 2000 will cause TinyMCE to error.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('paste', 'paste_remove_styles'),
);
$form['paste']['paste_remove_styles_if_webkit'] = array(
'#type' => 'checkbox',
'#title' => t('Remove styles in WebKit'),
'#default_value' => !empty($settings['paste_remove_styles_if_webkit']),
'#return_value' => 1,
'#description' => t('If enabled, removes all style information when pasting in WebKit since it has a serious paste bug.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('paste', 'paste_remove_styles_if_webkit'),
);
$form['paste']['paste_convert_middot_lists'] = array(
'#type' => 'checkbox',
'#title' => t('Convert Word lists'),
'#default_value' => !empty($settings['paste_convert_middot_lists']),
'#return_value' => 1,
'#description' => t('If enabled, the paste plugin tries to convert Word lists into semantic XHTML list elements.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('paste', 'paste_convert_middot_lists'),
);
$form['paste']['paste_convert_headers_to_strong'] = array(
'#type' => 'checkbox',
'#title' => t('Convert headers to strong'),
'#default_value' => !empty($settings['paste_convert_headers_to_srong']),
'#return_value' => 1,
'#description' => t('If enabled, the paste plugin tries to convert Word headers to strong tags.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('paste', 'paste_convert_headers_to_strong'),
);
$form['paste']['paste_max_consecutive_linebreaks'] = array(
'#type' => 'textfield',
'#title' => t('Max consecutive linebreaks'),
'#size' => 5,
'#maxlength' => '10',
'#default_value' => !empty($settings['paste_max_consecutive_linebreaks']),
'#description' => t('The maximum number of consecutive linebreaks to use.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('paste', 'paste_max_consecutive_linebreaks'),
);
$form['paste']['paste_text_use_dialog'] = array(
'#type' => 'checkbox',
'#title' => t('Use dialog'),
'#default_value' => !empty($settings['paste_text_use_dialog']),
'#return_value' => 1,
'#description' => t('If enabled, uses legacy mode for the Paste as Text button. Will use a dialog instead of treating the button as a toggle.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('paste', 'paste_text_use_dialog'),
);
$form['paste']['paste_text_sticky'] = array(
'#type' => 'checkbox',
'#title' => t('Sticky "Paste text" button'),
'#default_value' => !empty($settings['paste_text_sticky']),
'#return_value' => 1,
'#description' => t('If enabled, keeps the "Paste text" button selected after pasting. Requires the "Paste text" button and "Process contents on paste" to be enabled.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('paste', 'paste_text_sticky'),
);
$form['paste']['paste_text_sticky_default'] = array(
'#type' => 'checkbox',
'#title' => t('Paste as plain text by default'),
'#default_value' => !empty($settings['paste_text_sticky_default']),
'#return_value' => 1,
'#description' => t('If enabled, the "Paste text" button is selected when the editor starts. Requires the "Paste text" button and "Process contents on paste" to be enabled.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('paste', 'paste_text_sticky_default'),
);
$form['paste']['paste_text_notifyalways'] = array(
'#type' => 'checkbox',
'#title' => t('Always notify when pasting plain text'),
'#default_value' => !empty($settings['paste_text_notifyalways']),
'#return_value' => 1,
'#description' => t('If enabled, users will be notified each time plain text pasting mode is enabled.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('paste', 'paste_text_notifyalways'),
);
$form['paste']['paste_text_linebreaktype'] = array(
'#type' => 'select',
'#title' => t('Linebreak type'),
'#options' => array(
'combined' => t('Combined'),
'p' => t('<p>'),
'br' => t('<br>'),
),
'#default_value' => $settings['paste_text_linebreaktype'],
'#description' => t('Converts plain text linebreaks to br or p elements.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('paste', 'paste_text_linebreaktype'),
);
if (version_compare($version, '4', '>=')) {
$form['appearance']['menu'] = array(
'#title' => t('Menu'),
'#type' => 'textarea',
'#default_value' => $settings['menu'],
'#description' => t('The options to use in the menu, as a JSON☆ structure. The <a href="@controls">available controls</a> and format for this setting can be found in the official settings description. Note: You must make sure the plugin providing a control is also enabled.', array(
'@controls' => url('https://www.tinymce.com/docs/advanced/editor-control-identifiers/#menucontrols'),
)) . ' ' . _wysiwyg_tinymce_get_setting_description('menu', 'editor-appearance'),
'#element_validate' => array(
'wysiwyg_tinymce_settings_form_validate_menu',
),
);
$form['appearance']['resize'] = array(
'#type' => 'select',
'#title' => t('Resizing'),
'#description' => t('This option gives you the ability to disable the resize handle or set it to resize both horizontal and vertically.') . ' ' . _wysiwyg_tinymce_get_setting_description('resize', 'editor-appearance'),
'#options' => array(
FALSE => t('Disabled'),
TRUE => t('Vertical'),
'both' => t('Horizontal and vertical'),
),
'#default_value' => $settings['resize'],
);
$form['paste']['paste_as_text'] = array(
'#type' => 'checkbox',
'#title' => t('Paste as text'),
'#default_value' => !empty($settings['paste_as_text']),
'#return_value' => 1,
'#description' => t('If enabled, the default state of the "Paste as text" edit menu option is enabled.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('paste', 'paste_as_text'),
);
$form['paste']['paste_data_images'] = array(
'#type' => 'checkbox',
'#title' => t('Paste inline images'),
'#default_value' => !empty($settings['paste_data_images']),
'#return_value' => 1,
'#description' => t('If enabled, users will be allowed to paste data:url (inline) images, embedding the actual images data with the text contents. This is normally not something people want, since say embedding a 600kb image will take a long time to upload, store the image in the database, block page loads, and prevent caching the image across multiple pages. Firefox is known to allow embedding images through pasting or drag and drop.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('plugin', 'paste_data_images'),
);
}
if (version_compare($version, '3.2.5', '>=')) {
$form['autoresize'] = array(
'#type' => 'fieldset',
'#title' => t('Autoresize plugin'),
'#description' => t('Settings for the <a href="@url">@plugin</a> plugin.', array(
'@plugin' => 'autoresize',
'@url' => _wysiwyg_tinymce_get_plugin_url('autoresize'),
)),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'advanced',
);
$form['autoresize']['autoresize_min_height'] = array(
'#title' => t('Min height'),
'#type' => 'textfield',
'#default_value' => $settings['autoresize_min_height'],
'#size' => 10,
'#description' => t('Minimum height value of the editor when it auto resizes.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('autoresize', 'autoresize_min_height'),
);
$form['autoresize']['autoresize_max_height'] = array(
'#title' => t('Max height'),
'#type' => 'textfield',
'#default_value' => $settings['autoresize_max_height'],
'#size' => 10,
'#description' => t('Maximum height value of the editor when it auto resizes.') . ' ' . _wysiwyg_tinymce_get_plugin_setting_description('autoresize', 'autoresize_max_height'),
);
}
}