From 4d8a00f6ca6b844df40e9805cd1bbe383d183676 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 18 Jan 2011 11:44:50 -0700 Subject: [PATCH] Bug #9369: Allow a javascript variable name to be used for ckeditor config --- framework/Editor/lib/Horde/Editor/Ckeditor.php | 23 +++++++++++++---------- imp/compose.php | 3 +-- imp/lib/Ui/Editor.php | 1 + 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/framework/Editor/lib/Horde/Editor/Ckeditor.php b/framework/Editor/lib/Horde/Editor/Ckeditor.php index 0a937153d..10ca2bcaa 100644 --- a/framework/Editor/lib/Horde/Editor/Ckeditor.php +++ b/framework/Editor/lib/Horde/Editor/Ckeditor.php @@ -19,8 +19,10 @@ class Horde_Editor_Ckeditor extends Horde_Editor *
      * 'basic' - (boolean) Load "basic" editor (a small javascript stub that
      *           will download the full code on demand)?
-     * 'config' - (array) The javascript config hash used to indiciate the
-     *            config for this editor instance.
+     * 'config' - (mixed) If an array, the javascript config hash used to
+     *            indiciate the config for this editor instance. If a string,
+     *            will be used directly as the javascript config name to use
+     *            when loading (must exist elsewhere in page).
      * 'id' - (string) The ID of the text area to turn into an editor. If
      *        empty, won't automatically load the editor.
      * 'no_notify' - (boolean) Don't output JS code automatically. Code will
@@ -33,19 +35,20 @@ class Horde_Editor_Ckeditor extends Horde_Editor
             return;
         }
 
-        $params = array_merge(array(
-            'config' => array()
-        ), $params);
-
         $ck_file = empty($params['basic'])
             ? 'ckeditor.js'
             : 'ckeditor_basic.js';
         $ck_path = $GLOBALS['registry']->get('jsuri', 'horde') . '/';
 
-        /* Globally disable spell check as you type. */
-        $params['config']['scayt_autoStartup'] = false;
-
-        $params['config'] = Horde_Serialize::serialize($params['config'], Horde_Serialize::JSON);
+        if (isset($params['config'])) {
+            if (is_array($params['config'])) {
+                /* Globally disable spell check as you type. */
+                $params['config']['scayt_autoStartup'] = false;
+                $params['config'] = Horde_Serialize::serialize($params['config'], Horde_Serialize::JSON);
+            }
+        } else {
+            $params['config'] = array();
+        }
 
         if (empty($params['no_notify'])) {
             Horde::addScriptFile($ck_path . $ck_file, null, array('external' => true));
diff --git a/imp/compose.php b/imp/compose.php
index 71b8c5b57..a878b8ca4 100644
--- a/imp/compose.php
+++ b/imp/compose.php
@@ -1029,8 +1029,7 @@ if ($redirect) {
 }
 
 if ($rtemode && !$redirect) {
-    IMP_Ui_Editor::init();
-    Horde::addInlineScript('CKEDITOR.replace("composeMessage", IMP.ckeditor_config)', 'load');
+    IMP_Ui_Editor::init(false, 'composeMessage');
 }
 
 if ($showmenu) {
diff --git a/imp/lib/Ui/Editor.php b/imp/lib/Ui/Editor.php
index 58a7e29ef..7e60514ce 100644
--- a/imp/lib/Ui/Editor.php
+++ b/imp/lib/Ui/Editor.php
@@ -28,6 +28,7 @@ class IMP_Ui_Editor
 
         $injector->getInstance('Horde_Editor')->initialize(array(
             'basic' => $basic,
+            'config' => 'IMP.ckeditor_config',
             'id' => $id
         ));
 
-- 
2.11.0