Index: fckeditor.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/fckeditor.inc,v retrieving revision 1.7 diff -u -r1.7 fckeditor.inc --- editors/fckeditor.inc 21 Jan 2009 15:49:31 -0000 1.7 +++ editors/fckeditor.inc 22 Jan 2009 14:10:41 -0000 @@ -90,6 +90,8 @@ 'ToolbarStartExpanded' => TRUE, 'EnterMode' => 'p', 'ShiftEnterMode' => 'br', + 'CustomConfigurationsPath' => wysiwyg_get_path('editors/js/fckeditor.config.js', TRUE), + 'PluginsPath' => wysiwyg_get_path('plugins', TRUE), 'LinkBrowser' => FALSE, 'LinkUpload' => FALSE, 'ImageBrowser' => FALSE, @@ -118,6 +120,31 @@ $init['EditorAreaCSS'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())); } } + + $dynamic_buttons = array(); + $plugins = wysiwyg_get_plugins($editor['name']); + + if (!empty($config['buttons'])) { + foreach ($config['buttons'] as $plugin => $buttons) { + foreach ($buttons as $button => $enabled) { + // Iterate separately over buttons and extensions properties. + foreach (array('buttons', 'extensions') as $type) { + // Skip unavailable plugins. + if (!isset($plugins[$plugin][$type][$button])) { + continue; + } + // Add buttons. + if ($type == 'buttons') { + $dynamic_buttons[] = $button; + } + } + } + } + + if (!empty($dynamic_buttons)) { + $init['DynamicToolbar_buttons'] = implode(",", $dynamic_buttons); + } + } return $init; } @@ -154,6 +181,26 @@ */ function wysiwyg_fckeditor_plugins($editor) { return array( + 'default' => array( + 'buttons' => array( + 'Source' => t('Source'), 'DocProps' => t('DocProps'), 'Save' => t('Save'), 'NewPage' => t('NewPage'), + 'Preview' => t('Preview'), 'Templates' => t('Templates'), 'Cut' => t('Cut'), 'Copy' => t('Copy'), + 'Paste' => t('Paste'), 'PasteText' => t('PasteText'), 'PasteWord' => t('PasteWord'), 'Print' => t('Print'), + 'SpellCheck' => t('SpellCheck'), 'Undo' => t('Undo'), 'Redo' => t('Redo'), 'Find' => t('Find'), + 'Replace' => t('Replace'), 'SelectAll' => t('SelectAll'), 'RemoveFormat' => t('RemoveFormat'), 'Form' => t('Form'), + 'Checkbox' => t('Checkbox'), 'Radio' => t('Radio'), 'TextField' => t('TextField'), 'Textarea' => t('Textarea'), + 'Select' => t('Select'), 'Button' => t('Button'), 'ImageButton' => t('ImageButton'), 'HiddenField' => t('HiddenField'), + 'Bold' => t('Bold'), 'Italic' => t('Italic'), 'Underline' => t('Underline'), 'StrikeThrough' => t('StrikeThrough'), + 'Subscript' => t('Subscript'), 'Superscript' => t('Superscript'), 'OrderedList' => t('OrderedList'), 'UnorderedList' => t('UnorderedList'), + 'Outdent' => t('Outdent'), 'Indent' => t('Indent'), 'Blockquote' => t('Blockquote'), 'CreateDiv' => t('CreateDiv'), + 'JustifyLeft' => t('JustifyLeft'), 'JustifyCenter' => t('JustifyCenter'), 'JustifyRight' => t('JustifyRight'), 'JustifyFull' => t('JustifyFull'), + 'Link' => t('Link'), 'Unlink' => t('Unlink'), 'Anchor' => t('Anchor'), 'Image' => t('Image'), + 'Flash' => t('Flash'), 'Table' => t('Table'), 'Rule' => t('Rule'), 'Smiley' => t('Smiley'), + 'SpecialChar' => t('SpecialChar'), 'Style' => t('Style'), 'FontFormat' => t('FontFormat'), + 'FontName' => t('FontName'), 'FontSize' => t('FontSize'), 'TextColor' => t('TextColor'), 'BGColor' => t('BGColor'), + 'FitWindow' => t('FitWindow'), 'ShowBlocks' => t('ShowBlocks'), 'About' => t('About')), + 'internal' => TRUE, + ), ); } Index: js/fckeditor-2.6.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/fckeditor-2.6.js,v retrieving revision 1.9 diff -u -r1.9 fckeditor-2.6.js --- editors/js/fckeditor-2.6.js 21 Jan 2009 15:49:31 -0000 1.9 +++ editors/js/fckeditor-2.6.js 22 Jan 2009 14:10:41 -0000 @@ -12,6 +12,12 @@ for (var setting in settings) { FCKinstance.Config[setting] = settings[setting]; } + if (FCKinstance.Config['DynamicToolbar_buttons']) { + FCKinstance.ToolbarSet = 'DynamicToolbar'; + } + else { + FCKinstance.ToolbarSet = 'Wysiwyg'; + } // Attach editor. FCKinstance.ReplaceTextarea(); }; @@ -31,9 +37,5 @@ delete FCKeditorAPI.__Instances[params.field]; } } -// else { -// tinyMCE.triggerSave(); -// tinyMCE.remove(); -// } }; --- editors/js/fckeditor.config.js +++ editors/js/fckeditor.config.js @@ -0,0 +1,30 @@ +// $Id: fckeditor.config.js $ + +// This plugin is required to create toolbar dynamically +FCKConfig.Plugins.Add( 'fckeditor/dynamictoolbar' ) ; + +/** + * Below is a predefined toolbar that will be used if no buttons are selected in the Wysiwyg profile. + * For a list of all available buttons, check the "Default" toolbar in fckeditor/editor/fckconfig.js + */ +FCKConfig.ToolbarSets['Wysiwyg'] = [ +['Source'], +['Cut','Copy','Paste','PasteText','PasteWord'], +['Undo','Redo','-','Find','Replace'], +['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'], +['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'], +['JustifyLeft','JustifyCenter','JustifyRight'], +['Link','Unlink','Anchor'], +['Image','Flash','Table','Rule','SpecialChar'], +['FontFormat','FontName','FontSize'], +['TextColor','BGColor','FitWindow','ShowBlocks'] +] ; + +// Protect PHP code tags () so FCKeditor will not break them when switching from Source to WYSIWYG. +// Uncommenting this line doesn't mean the user will not be able to type PHP +// code in the source. This kind of prevention must be done in the server side +// (as does Drupal), so just leave this line as is. +FCKConfig.ProtectedSource.Add( /<\?[\s\S]*?\?>/g ) ; // PHP style server side code + +//Set to 'encode' if you want to obfuscate emails with javascript +FCKConfig.EMailProtection = 'none' ; --- plugins/fckeditor/dynamictoolbar/fckplugin.js +++ plugins/fckeditor/dynamictoolbar/fckplugin.js @@ -0,0 +1,25 @@ +// $Id: fckplugin.js $ + +/* + DynamicToolbar FCKEditor plugin, v1.1 (080810) + Copyright (c) 2008, Gonzalo Perez de la Ossa (http://dense13.com/) + License: http://www.opensource.org/licenses/mit-license.php +*/ + +FCKConfig.ToolbarSets["DynamicToolbar"] = []; + +if (FCKConfig['DynamicToolbar_buttons']) { + var lines, blocks; + lines = FCKConfig['DynamicToolbar_buttons'].split('|'); + + for (var i=0, l=lines.length ; i