From 670219e1f0dfca1e3aa43a6d506e53f7b824f450 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Sat, 24 Oct 2009 17:56:05 -0600 Subject: [PATCH] Add Ckeditor RTE driver. --- framework/Editor/lib/Horde/Editor/Ckeditor.php | 80 ++++++++++++++++++++++++++ framework/Editor/package.xml | 6 +- 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 framework/Editor/lib/Horde/Editor/Ckeditor.php diff --git a/framework/Editor/lib/Horde/Editor/Ckeditor.php b/framework/Editor/lib/Horde/Editor/Ckeditor.php new file mode 100644 index 000000000..919ca2375 --- /dev/null +++ b/framework/Editor/lib/Horde/Editor/Ckeditor.php @@ -0,0 +1,80 @@ + + * @package Horde_Editor + */ +class Horde_Editor_Ckeditor extends Horde_Editor +{ + /** + * Constructor. + * + * @param array $params The following configuration parameters: + *
+     * 'basic' - (boolean) Load "basic" editor (a small javascript stub that
+     *           will download the full code on demand)?
+     * 'config' - (string) The javascript config hash used to indiciate the
+     *            config for this editor instance.
+     * '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
+     *               instead be stored for access via getJS().
+     * 
+ */ + public function __construct($params = array()) + { + $ck_file = empty($params['basic']) + ? 'ckeditor.js' + : 'ckeditor_basic.js'; + $ck_path = $GLOBALS['registry']->get('webroot', 'horde') . '/services/editor/ckeditor/'; + + if (empty($params['config'])) { + $params['config'] = '{}'; + } + + if (empty($params['no_notify'])) { + Horde::addScriptFile($ck_path . $ck_file, null, array('external' => true)); + if (isset($params['id'])) { + Horde::addInlineScript('CKEDITOR.replace(' . $params['id'] . ',' . $params['config'] . ')', 'load'); + } + } else { + $this->_js = ''; + if (isset($params['id'])) { + $this->_js .= Horde::wrapInlineScript(array('CKEDITOR.replace(' . $params['id'] . ',' . $params['config'] . ')'), 'load'); + } + } + } + + /** + * Does the current browser support this driver. + * + * @return boolean True if the browser supports the editor. + */ + public function supportedByBrowser() + { + global $browser; + + switch ($browser->getBrowser()) { + case 'webkit': + case 'msie': + case 'mozilla': + case 'opera': + // MSIE: 5.5+ + // Firefox: 1.5+ + // Opera: 9.5+ + // Safari: 3.0+ + return $browser->hasFeature('rte'); + + default: + return false; + } + } + +} diff --git a/framework/Editor/package.xml b/framework/Editor/package.xml index c52a0be93..acd722251 100644 --- a/framework/Editor/package.xml +++ b/framework/Editor/package.xml @@ -30,12 +30,15 @@ http://pear.php.net/dtd/package-2.0.xsd"> beta LGPL - * Initial Horde 4 package. + * Added CKEditor driver. + * Initial Horde 4 package. + + @@ -64,6 +67,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + -- 2.11.0