Commit 60486af7 authored by sun's avatar sun

#268562 by sun: Code clean-up; changed format for custom defined CSS classes...

#268562 by sun: Code clean-up; changed format for custom defined CSS classes and removed error-prone auto-layout of buttons in favor of aligning them in one row with a stylesheet; may break existing profiles.
parent 36986c6c
......@@ -6,6 +6,9 @@ Wysiwyg x.x-x.x, xxxx-xx-xx
Wysiwyg 6.x-x.x, xxxx-xx-xx
---------------------------
#268562 by sun: Code clean-up; changed format for custom defined CSS classes
and removed error-prone auto-layout of buttons in favor of aligning them in
one row with a stylesheet; may break existing profiles.
#270730 by hass, sun: Added German translation for Teaser break plugin.
#268838 by sun: Fixed PHP warning if no buttons are enabled for a profile.
#268838 by sun: Ported to Drupal 6.x.
......
......@@ -73,7 +73,8 @@ function wysiwyg_editor_profile_form($form_state, $edit) {
'toolbar_align' => 'left',
'path_loc' => 'bottom',
'resizing' => TRUE,
'block_formats' => 'p,address,pre,h2,h3,h4,h5,h6',
// 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,
......@@ -297,15 +298,6 @@ function wysiwyg_editor_profile_form($form_state, $edit) {
'#description' => t(' This option gives you the ability to enable/disable the resizing button. If enabled the <strong>Path location toolbar</strong> must be set to "top" or "bottom" in order to display the resize icon.'),
);
$form['appearance']['block_formats'] = array(
'#type' => 'textfield',
'#title' => t('Block formats'),
'#default_value' => $edit->settings['block_formats'],
'#size' => 40,
'#maxlength' => 250,
'#description' => t('Comma separated list of HTML block formats. You can only remove elements, not add.'),
);
$form['output'] = array(
'#type' => 'fieldset',
'#title' => t('Cleanup and output'),
......@@ -360,6 +352,15 @@ function wysiwyg_editor_profile_form($form_state, $edit) {
'#collapsed' => TRUE,
);
$form['css']['block_formats'] = array(
'#type' => 'textfield',
'#title' => t('Block formats'),
'#default_value' => $edit->settings['block_formats'],
'#size' => 40,
'#maxlength' => 250,
'#description' => t('Comma separated list of HTML block formats. You can only remove elements, not add.'),
);
$form['css']['css_setting'] = array(
'#type' => 'select',
'#title' => t('Editor CSS'),
......@@ -374,16 +375,14 @@ function wysiwyg_editor_profile_form($form_state, $edit) {
'#default_value' => $edit->settings['css_path'],
'#size' => 40,
'#maxlength' => 255,
'#description' => t('If "Define CSS" has been selected above, enter path to a CSS file or a list of CSS files seperated by a comma.') .'<br />'. t('Available tokens: %b (base path, f.e.: /), %t (path to theme, f.e.: themes/garland)') .'<br />'. t('Examples:') .' css/editor.css,/themes/garland/style.css,%t/style.css,http://example.com/custom.css',
'#description' => t('If "Define CSS" has been selected above, enter path to a CSS file or a list of CSS files seperated by a comma.') .'<br />'. t('Available tokens: %b (base path, f.e.: /), %t (path to theme, f.e.: themes/garland)') .'<br />'. t('Examples:') .' css/editor.css,/themes/garland/style.css,%b%t/style.css,http://example.com/external.css',
);
$form['css']['css_classes'] = array(
'#type' => 'textfield',
'#type' => 'textarea',
'#title' => t('CSS classes'),
'#default_value' => $edit->settings['css_classes'],
'#size' => 40,
'#maxlength' => 255,
'#description' => t('Adds CSS classes to the "styles" droplist. Format is: &lt;title&gt;=&lt;class&gt;;<br/> Example: Header 1=header1;Header 2=header2;Header 3=header3 (note: no trailing \';\')<br />Leave blank to automatically import list of CSS classes from style sheet.'),
'#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')),
);
$form['submit'] = array(
......@@ -428,10 +427,10 @@ function wysiwyg_editor_profile_form_submit($form, &$form_state) {
}
if (isset($form_state['values']['old_name'])) {
drupal_set_message(t('Wysiwyg Editor profile has been updated.'));
drupal_set_message(t('Wysiwyg Editor profile %name has been updated.', array('%name' => $form_state['values']['name'])));
}
else {
drupal_set_message(t('Wysiwyg Editor profile has been created.'));
drupal_set_message(t('Wysiwyg Editor profile %name has been created.', array('%name' => $form_state['values']['name'])));
}
drupal_goto('admin/settings/wysiwyg/profile');
}
......
/* $Id$ */
/* TinyMCE */
.mceToolbarTop a, .mceToolbarBottom a { float: left; }
.mceSeparatorLine { float: left; margin-top: 3px; }
.mceSelectList { float: left; margin-bottom: 1px; }
#mce_editor_0_table, #mce_editor_1_table { clear: left; }
......@@ -132,6 +132,8 @@ function wysiwyg_editor_load() {
'noWysiwyg' => $no_wysiwyg,
'status' => $status,
)), 'setting');
// Add our stylesheet to stack editor buttons into one row.
drupal_add_css($path_wysiwyg .'/wysiwyg_editor.css');
// We have to do this because of some unfocused CSS in certain themes.
// @see http://drupal.org/node/18879
......@@ -403,7 +405,7 @@ function wysiwyg_editor_config($profile, $theme) {
}
if ($settings['css_classes']) {
$init['theme_advanced_styles'] = $settings['css_classes'];
$init['theme_advanced_styles'] = implode(';', array_filter(explode("\n", str_replace("\r", '', $settings['css_classes']))));
}
if ($settings['css_setting'] == 'theme') {
......@@ -475,42 +477,17 @@ function wysiwyg_editor_config($profile, $theme) {
unset($init['extensions']);
}
// Shuffle buttons around so that row 1 always has the most buttons,
// followed by row 2, etc. Note: These rows need to be set to NULL otherwise
// Wysiwyg Editor loads its own buttons inherited from the theme.
// Note: These rows need to be set to NULL otherwise TinyMCE loads its
// own buttons as defined in advanced theme.
$init += array(
'theme_advanced_buttons1' => array(),
'theme_advanced_buttons2' => array(),
'theme_advanced_buttons3' => array(),
);
$row = $button_count = 1;
for ($i = 0; $i < count($init['buttons']); $i++) {
if (!isset($init['theme_advanced_buttons'. $row])) {
$init['theme_advanced_buttons'. $row] = array();
}
$init['theme_advanced_buttons'. $row][] = $init['buttons'][$i];
if (strpos($init['buttons'][$i], 'font') !== FALSE) {
$button_count += 5;
}
if ($button_count < 23) {
$button_count++;
}
else {
$row++;
$button_count = 1;
}
$init['theme_advanced_buttons1'][] = $init['buttons'][$i];
}
unset($init['buttons']);
// Minimum number of buttons per row.
$min_btns = 5;
foreach (range($row, 1) as $row) {
if (count($init['theme_advanced_buttons'. $row]) < $min_btns) {
// Squish the rows together, since row is empty.
$init['theme_advanced_buttons'. ($row - 1)] = array_merge($init['theme_advanced_buttons'. ($row - 1)], $init['theme_advanced_buttons'. $row]);
$init['theme_advanced_buttons'. $row] = array();
}
}
}
break;
}
......
......@@ -19,7 +19,7 @@ function wysiwyg_editor_wysiwyg_plugin($editor) {
return array(
'default' => array(
'path' => $path_editor .'/themes/advanced',
'buttons' => array('bold' => t('Bold'), 'italic' => t('Italic'), 'underline' => t('Underline'), 'strikethrough' => t('Strike-through'), 'justifyleft' => t('Justify left'), 'justifycenter' => t('Justify center'), 'justifyright' => t('Justify right'), 'justifyfull' => t('Justify full'), 'bullist' => t('Bullet list'), 'numlist' => t('Numbered list'), 'outdent' => t('Outdent'), 'indent' => t('Indent'), 'undo' => t('Undo'), 'redo' => t('Redo'), 'link' => t('Link'), 'unlink' => t('Unlink'), 'anchor' => t('Anchor'), 'image' => t('Image'), 'cleanup' => t('Clean-up'), 'forecolor' => t('Forecolor'), 'backcolor' => t('Backcolor'), 'sup' => t('Sup'), 'sub' => t('Sub'), 'code' => t('Code'), 'hr' => t('Horizontal rule'), 'cut' => t('Cut'), 'copy' => t('Copy'), 'paste' => t('Paste'), 'visualaid' => t('Visual aid'), 'removeformat' => t('Remove format'), 'charmap' => t('Char map'), 'help' => t('Help')),
'buttons' => array('bold' => t('Bold'), 'italic' => t('Italic'), 'underline' => t('Underline'), 'strikethrough' => t('Strike-through'), 'justifyleft' => t('Align left'), 'justifycenter' => t('Align center'), 'justifyright' => t('Align right'), 'justifyfull' => t('Justify'), 'bullist' => t('Bullet list'), 'numlist' => t('Numbered list'), 'outdent' => t('Outdent'), 'indent' => t('Indent'), 'undo' => t('Undo'), 'redo' => t('Redo'), 'link' => t('Link'), 'unlink' => t('Unlink'), 'anchor' => t('Anchor'), 'image' => t('Image'), 'cleanup' => t('Clean-up'), 'forecolor' => t('Forecolor'), 'backcolor' => t('Backcolor'), 'sup' => t('Sup'), 'sub' => t('Sub'), 'code' => t('Source code'), 'hr' => t('Horizontal rule'), 'cut' => t('Cut'), 'copy' => t('Copy'), 'paste' => t('Paste'), 'visualaid' => t('Visual aid'), 'removeformat' => t('Remove format'), 'charmap' => t('Char map'), 'help' => t('Help')),
'internal' => TRUE,
),
'advhr' => array(
......@@ -89,7 +89,7 @@ function wysiwyg_editor_wysiwyg_plugin($editor) {
),
'font' => array(
'path' => $path_editor .'/plugins/font',
'buttons' => array('formatselect' => t('Font format'), 'fontselect' => t('Font'), 'fontsizeselect' => t('Font size'), 'styleselect' => t('Font style')),
'buttons' => array('formatselect' => t('HTML block format'), 'fontselect' => t('Font'), 'fontsizeselect' => t('Font size'), 'styleselect' => t('Font style')),
'extended_valid_elements' => array('font[face|size|color|style],span[class|align|style]'),
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/font',
'internal' => TRUE,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment