Index: .cvsignore =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/Attic/.cvsignore,v retrieving revision 1.1.2.1 diff -u -p -r1.1.2.1 .cvsignore --- .cvsignore 30 May 2008 02:49:54 -0000 1.1.2.1 +++ .cvsignore 14 Jul 2008 23:57:12 -0000 @@ -1 +1,2 @@ -tinymce \ No newline at end of file +tinymce +fckeditor \ No newline at end of file Index: wysiwyg_editor.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg_editor.admin.inc,v retrieving revision 1.1.2.11 diff -u -p -r1.1.2.11 wysiwyg_editor.admin.inc --- wysiwyg_editor.admin.inc 29 Jun 2008 22:24:31 -0000 1.1.2.11 +++ wysiwyg_editor.admin.inc 15 Jul 2008 00:35:14 -0000 @@ -55,6 +55,7 @@ function wysiwyg_editor_profile_form($ed $edit += array( 'name' => NULL, 'rids' => NULL, + 'editor' => 'tinymce', 'settings' => array( 'default' => TRUE, 'user_choose' => FALSE, @@ -117,6 +118,14 @@ function wysiwyg_editor_profile_form($ed '#required' => TRUE, ); + $form['basic']['editor'] = array( + '#type' => 'select', + '#title' => t('Editor'), + '#default_value' => $edit->settings['editor'], + '#options' => array('tinymce' => 'TinyMCE', 'fckeditor' => 'FCKeditor'), + '#description' => t('Choose an editor to use for this profile.'), + ); + $form['basic']['default'] = array( '#type' => 'select', '#title' => t('Default state'), @@ -486,9 +495,13 @@ function wysiwyg_editor_profile_overview $profiles = wysiwyg_editor_profile_load(); if ($profiles) { $roles = user_roles(FALSE, 'access wysiwyg editor'); - $header = array(t('Profile'), t('Roles'), t('Operations')); + $header = array(t('Profile'), t('Editor'), t('Roles'), t('Operations')); foreach ($profiles as $p) { - $rows[] = array(array('data' => $p->name, 'valign' => 'top'), array('data' => implode("
\n", $p->rids)), array('data' => l(t('Edit'), 'admin/settings/wysiwyg/profile/edit/'. urlencode($p->name)) .' '. l(t('Delete'), 'admin/settings/wysiwyg/profile/delete/'. urlencode($p->name)), 'valign' => 'top')); + $rows[] = array( + array('data' => $p->name, 'valign' => 'top'), + array('data' => $p->settings['editor'], 'valign' => 'top'), + array('data' => implode("
\n", $p->rids)), + array('data' => l(t('Edit'), 'admin/settings/wysiwyg/profile/edit/'. urlencode($p->name)) .' '. l(t('Delete'), 'admin/settings/wysiwyg/profile/delete/'. urlencode($p->name)), 'valign' => 'top')); } $output .= theme('table', $header, $rows); } Index: wysiwyg_editor.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg_editor.js,v retrieving revision 1.1.2.6 diff -u -p -r1.1.2.6 wysiwyg_editor.js --- wysiwyg_editor.js 8 Jul 2008 02:54:34 -0000 1.1.2.6 +++ wysiwyg_editor.js 15 Jul 2008 03:08:02 -0000 @@ -7,20 +7,30 @@ * calling tinyMCE.init() after the page is loaded breaks in IE 6. */ Drupal.wysiwygEditorInit = function () { - // If JS compression is enabled, TinyMCE is unable to find its own base path - // and exec mode, hence we need to define it manually. - tinyMCE.baseURL = Drupal.settings.wysiwygEditor.editorBasePath; - tinyMCE.srcMode = (Drupal.settings.wysiwygEditor.execMode == 'src' ? '_src' : ''); - tinyMCE.gzipMode = (Drupal.settings.wysiwygEditor.execMode == 'gzip'); - - for (var theme in Drupal.settings.wysiwygEditor.configs) { - // Clone so we are not passing by reference. Otherwise the - // settings will get overwritten. - var config = Drupal.wysiwygEditorCloneObject(Drupal.settings.wysiwygEditor.configs[theme]); - tinyMCE.init(config); - } - for (var plugin in Drupal.settings.wysiwygEditor.plugins) { - tinyMCE.loadPlugin(plugin, Drupal.settings.wysiwygEditor.plugins[plugin]); + for (var editor in Drupal.settings.wysiwygEditor.configs) { + switch (editor) { + case 'fckeditor': + break; + + case 'tinymce': + default: + // If JS compression is enabled, TinyMCE is unable to find its own base path + // and exec mode, hence we need to define it manually. + tinyMCE.baseURL = Drupal.settings.wysiwygEditor.editorBasePath; + tinyMCE.srcMode = (Drupal.settings.wysiwygEditor.execMode == 'src' ? '_src' : ''); + tinyMCE.gzipMode = (Drupal.settings.wysiwygEditor.execMode == 'gzip'); + + for (var theme in Drupal.settings.wysiwygEditor.configs[editor]) { + // Clone so we are not passing by reference. Otherwise the + // settings will get overwritten. + var config = Drupal.wysiwygEditorCloneObject(Drupal.settings.wysiwygEditor.configs[editor][theme]); + tinyMCE.init(config); + } + for (var plugin in Drupal.settings.wysiwygEditor.plugins) { + tinyMCE.loadPlugin(plugin, Drupal.settings.wysiwygEditor.plugins[plugin]); + } + break; + } } } @@ -30,49 +40,119 @@ Drupal.wysiwygEditorInit = function () { * This function can be called to process AJAX-loaded content. */ Drupal.wysiwygEditorAttach = function () { - for (var theme in Drupal.settings.wysiwygEditor.configs) { - var config = Drupal.wysiwygEditorCloneObject(Drupal.settings.wysiwygEditor.configs[theme]); - // Set configuration options for this theme. - for (var setting in config) { - tinyMCE.settings[setting] = config[setting]; + for (var editor in Drupal.settings.wysiwygEditor.configs) { + switch (editor) { + case 'fckeditor': + for (var theme in Drupal.settings.wysiwygEditor.configs[editor]) { + var config = Drupal.wysiwygEditorCloneObject(Drupal.settings.wysiwygEditor.configs[editor][theme]); + $('textarea.wysiwyg-' + theme + ':not(.wysiwyg-processed)').each(function () { + // Show toggle link if set. + if (Drupal.settings.wysiwygEditor.showToggle) { + Drupal.wysiwygEditorAttachToggleLink(this, editor, theme); + } + // Attach Wysiwyg Editor control if default is on. + if (Drupal.settings.wysiwygEditor.status) { + // @todo Convert string into variable name w/o overwriting string? + // workaround: build object via editors[this.id] = new ... + var oFCK_1 = new FCKeditor(this.id); + oFCK_1.BasePath = Drupal.settings.wysiwygEditor.editorBasePath +'/'; + //oFCK_1.Config['CustomConfigurationsPath'] = Drupal.settings.wysiwygEditor.editorBasePath + '/../../fckeditor/fckeditor.config.js'; + //oFCK_1.ToolbarSet = "DrupalFull"; + oFCK_1.Config['TextareaID'] = this.id; + oFCK_1.Config['SkinPath'] = oFCK_1.BasePath + 'editor/skins/default/'; + oFCK_1.Config['DefaultLanguage'] = "en"; + oFCK_1.Config['AutoDetectLanguage'] = true; + oFCK_1.Height = "420"; + oFCK_1.Config['ToolbarStartExpanded'] = true; + oFCK_1.Width = "100%"; + oFCK_1.Config['EnterMode'] = 'p'; + oFCK_1.Config['ShiftEnterMode'] = "br"; + oFCK_1.Config['FontFormats'] = config.theme_advanced_blockformats.replace(/,/g,';'); + oFCK_1.Config['FormatSource'] = config.apply_source_formatting; + oFCK_1.Config['FormatOutput'] = true; + oFCK_1.Config['LinkBrowser'] = false; + oFCK_1.Config['ImageBrowser'] = false; + oFCK_1.Config['FlashBrowser'] = false; + oFCK_1.Config['LinkUpload'] = false; + oFCK_1.Config['ImageUpload'] = false; + oFCK_1.Config['FlashUpload'] = false; + oFCK_1.Config['EditorAreaCSS'] = config.content_css; + oFCK_1.ReplaceTextarea(); + } + $(this).addClass('wysiwyg-processed'); + }); + } + break; + + case 'tinymce': + default: + for (var theme in Drupal.settings.wysiwygEditor.configs[editor]) { + var config = Drupal.wysiwygEditorCloneObject(Drupal.settings.wysiwygEditor.configs[editor][theme]); + // Set configuration options for this theme. + for (var setting in config) { + tinyMCE.settings[setting] = config[setting]; + } + $('textarea.wysiwyg-' + theme + ':not(.wysiwyg-processed)').each(function () { + // Show toggle link if set. + if (Drupal.settings.wysiwygEditor.showToggle) { + Drupal.wysiwygEditorAttachToggleLink(this, editor, theme); + } + // Attach Wysiwyg Editor control if default is on. + if (Drupal.settings.wysiwygEditor.status) { + tinyMCE.execCommand('mceAddControl', true, this.id); + } + $(this).addClass('wysiwyg-processed'); + }); + } + break; } - $('textarea.wysiwyg-' + theme + ':not(.wysiwyg-processed)').each(function () { - // Show toggle link if set. - if (Drupal.settings.wysiwygEditor.showToggle) { - Drupal.wysiwygEditorAttachToggleLink(this, theme); - } - // Attach Wysiwyg Editor control if default is on. - if (Drupal.settings.wysiwygEditor.status) { - tinyMCE.execCommand('mceAddControl', true, this.id); - } - $(this).addClass('wysiwyg-processed'); - }); } } /** * Toggle the Wysiwyg Editor control and related link text for a textarea. */ -Drupal.wysiwygEditorToggle = function (id, theme) { - if (tinyMCE.getEditorId(id) == null) { - var config = Drupal.wysiwygEditorCloneObject(Drupal.settings.wysiwygEditor.configs[theme]); - // Set configuration options for this theme. - for (var setting in config) { - tinyMCE.settings[setting] = config[setting]; - } - tinyMCE.addMCEControl($('#' + id).get(0), id); - $('#wysiwyg4' + id).html(Drupal.settings.wysiwygEditor.disable).blur(); - } - else { - tinyMCE.removeMCEControl(tinyMCE.getEditorId(id)); - $('#wysiwyg4' + id).html(Drupal.settings.wysiwygEditor.enable).blur(); +Drupal.wysiwygEditorToggle = function (id, editor, theme) { + switch (editor) { + case 'fckeditor': + // @todo Convert string into variable name w/o overwriting string? + var instance = FCKeditorAPI.GetInstance(id); + if ($('#edit-body').css('display') != 'none' || instance == null) { + instance.SetHTML($('#' + id).hide().val()); + $('#' + id + '___Frame').show(); + $('#wysiwyg4' + id).html(Drupal.settings.wysiwygEditor.disable).blur(); + } + else { + $('#' + id).val(instance.GetXHTML()).show(); + $('#' + id + '___Frame').hide(); + $('#wysiwyg4' + id).html(Drupal.settings.wysiwygEditor.enable).blur(); + } + break; + + case 'tinymce': + default: + // @todo Duplicate code identified; this cries for Drupal.wysiwygEditorAdd(). + if (tinyMCE.getEditorId(id) == null) { + var config = Drupal.wysiwygEditorCloneObject(Drupal.settings.wysiwygEditor.configs[editor][theme]); + // Set configuration options for this theme. + for (var setting in config) { + tinyMCE.settings[setting] = config[setting]; + } + tinyMCE.addMCEControl($('#' + id).get(0), id); + $('#wysiwyg4' + id).html(Drupal.settings.wysiwygEditor.disable).blur(); + } + else { + tinyMCE.removeMCEControl(tinyMCE.getEditorId(id)); + $('#wysiwyg4' + id).html(Drupal.settings.wysiwygEditor.enable).blur(); + } + break; } } /** * Append toggle link to textarea. */ -Drupal.wysiwygEditorAttachToggleLink = function (elt, theme) { +Drupal.wysiwygEditorAttachToggleLink = function (elt, editor, theme) { if (typeof(document.execCommand) == 'undefined') { $(elt).after('
' + Drupal.settings.wysiwygEditor.noWysiwyg + '
'); } @@ -81,7 +161,7 @@ Drupal.wysiwygEditorAttachToggleLink = f var a = document.createElement('a'); $(a) .click(function() { - Drupal.wysiwygEditorToggle(elt.id, theme); + Drupal.wysiwygEditorToggle(elt.id, editor, theme); }) .attr('id', 'wysiwyg4' + elt.id) .css('cursor', 'pointer') Index: wysiwyg_editor.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg_editor.module,v retrieving revision 1.1.2.16 diff -u -p -r1.1.2.16 wysiwyg_editor.module --- wysiwyg_editor.module 8 Jul 2008 02:54:34 -0000 1.1.2.16 +++ wysiwyg_editor.module 15 Jul 2008 01:32:04 -0000 @@ -80,52 +80,63 @@ function wysiwyg_editor_elements() { */ function wysiwyg_editor_load() { global $user; - static $loaded = FALSE; + static $loaded = array(); + $path_wysiwyg = drupal_get_path('module', 'wysiwyg_editor'); + $profile = wysiwyg_editor_profile_load(wysiwyg_editor_current_profile()); + $editor = $profile->settings['editor']; // We only load the Wysiwyg Editor js file once per page request. - if (!$loaded) { - $path_wysiwyg = drupal_get_path('module', 'wysiwyg_editor'); - // Hard-coded for now. - $path_editor = $path_wysiwyg .'/tinymce/jscripts/tiny_mce'; - $profile = wysiwyg_editor_profile_load(wysiwyg_editor_current_profile()); + if (!isset($loaded[$editor])) { $status = wysiwyg_editor_user_get_status($user, $profile); $enable = t('Enable rich-text'); $disable = t('Disable rich-text'); $no_wysiwyg = t('Your current web browser does not support WYSIWYG editing.'); - // TinyMCE ImageManager - if (user_access('access tinymce imagemanager') && is_dir($path_editor .'/plugins/imagemanager/')) { - drupal_add_js($path_editor .'/plugins/imagemanager/jscripts/mcimagemanager.js'); - } - - // TinyMCE FileManager - if (user_access('access tinymce filemanager') && is_dir($path_editor .'/plugins/filemanager/')) { - drupal_add_js($path_editor .'/plugins/filemanager/jscripts/mcfilemanager.js'); - } + switch ($editor) { + case 'fckeditor': + $path_editor = $path_wysiwyg .'/fckeditor'; + drupal_add_js($path_editor .'/fckeditor.js'); + $exec_mode = ''; + break; + + case 'tinymce': + default: + $path_editor = $path_wysiwyg .'/tinymce/jscripts/tiny_mce'; + + // TinyMCE ImageManager + if (user_access('access tinymce imagemanager') && is_dir($path_editor .'/plugins/imagemanager/')) { + drupal_add_js($path_editor .'/plugins/imagemanager/jscripts/mcimagemanager.js'); + } + // TinyMCE FileManager + if (user_access('access tinymce filemanager') && is_dir($path_editor .'/plugins/filemanager/')) { + drupal_add_js($path_editor .'/plugins/filemanager/jscripts/mcfilemanager.js'); + } - // TinyMCE Compressor >= 1.0.9 - if (file_exists($path_editor .'/tiny_mce_gzip.js')) { - drupal_add_js($path_editor .'/tiny_mce_gzip.js'); - $exec_mode = 'gzip'; - } - // TinyMCE Compressor < 1.0.9 - elseif (file_exists($path_editor .'/tiny_mce_gzip.php')) { - drupal_add_js($path_editor .'/tiny_mce_gzip.php'); - $exec_mode = 'gzip'; - } - else { - // @todo Turn this into a module setting. - drupal_add_js($path_editor .'/tiny_mce.js'); - $exec_mode = ''; - // drupal_add_js($path_editor .'/tiny_mce_src.js'); - // $exec_mode = 'src'; + // TinyMCE Compressor >= 1.0.9 + if (file_exists($path_editor .'/tiny_mce_gzip.js')) { + drupal_add_js($path_editor .'/tiny_mce_gzip.js'); + $exec_mode = 'gzip'; + } + // TinyMCE Compressor < 1.0.9 + elseif (file_exists($path_editor .'/tiny_mce_gzip.php')) { + drupal_add_js($path_editor .'/tiny_mce_gzip.php'); + $exec_mode = 'gzip'; + } + else { + // @todo Turn this into a module setting. + drupal_add_js($path_editor .'/tiny_mce.js'); + $exec_mode = ''; + // drupal_add_js($path_editor .'/tiny_mce_src.js'); + // $exec_mode = 'src'; + } + break; } // Add wysiwyg_editor.js to the footer to ensure it's executed after the // Drupal.settings array has been rendered and populated. drupal_add_js($path_wysiwyg .'/wysiwyg_editor.js', 'module', 'footer'); drupal_add_js(array('wysiwygEditor' => array( - 'configs' => array(), + 'configs' => array($editor => array()), 'showToggle' => $profile->settings['show_toggle'], 'disable' => $disable, 'enable' => $enable, @@ -206,7 +217,7 @@ function wysiwyg_editor_load_config($the $config[$key] = implode(',', $config[$key]); } } - drupal_add_js('Drupal.settings.wysiwygEditor.configs["'. $theme .'"] = '. drupal_to_js($config) .';', 'inline'); + drupal_add_js('Drupal.settings.wysiwygEditor.configs.'. $profile->settings['editor'] .'["'. $theme .'"] = '. drupal_to_js($config) .';', 'inline'); $themes[] = $theme; } }