Bug #9369: Allow a javascript variable name to be used for ckeditor config
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 18 Jan 2011 18:44:50 +0000 (11:44 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 18 Jan 2011 18:45:14 +0000 (11:45 -0700)
framework/Editor/lib/Horde/Editor/Ckeditor.php
imp/compose.php
imp/lib/Ui/Editor.php

index 0a93715..10ca2bc 100644 (file)
@@ -19,8 +19,10 @@ class Horde_Editor_Ckeditor extends Horde_Editor
      * <pre>
      * '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));
index 71b8c5b..a878b8c 100644 (file)
@@ -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) {
index 58a7e29..7e60514 100644 (file)
@@ -28,6 +28,7 @@ class IMP_Ui_Editor
 
         $injector->getInstance('Horde_Editor')->initialize(array(
             'basic' => $basic,
+            'config' => 'IMP.ckeditor_config',
             'id' => $id
         ));