1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
<?php
/**
* The Editor_htmlarea:: class provides an WYSIWYG editor for use
* in the Horde Framework.
*
* $Horde: framework/Editor/Editor/htmlarea.php,v 1.24.4.4 2006/01/01 21:28:14 jan Exp $
*
* Copyright 2003-2006 Nuno Loureiro <nuno@co.sapo.pt>
* Copyright 2004-2006 Jan Schneider <jan@horde.org>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Nuno Loureiro <nuno@co.sapo.pt>
* @author Jan Schneider <jan@horde.org>
* @since Horde 3.0
* @package Horde_Editor
*/
class Horde_Editor_htmlarea extends Horde_Editor {
/**
* Constructor. Include the necessary javascript files.
*/
function Horde_Editor_htmlarea($params = array())
{
global $registry, $notification, $prefs;
Horde::addScriptFile('htmlarea.js', 'horde');
Horde::addScriptFile('/services/editor/htmlarea/htmlarea.js', 'horde', true);
$script = Horde::url(Util::addParameter($registry->get('webroot', 'horde') . '/services/javascript.php', 'app', 'horde'), true);
$js = 'HTMLArea.loadScript("' . Util::addParameter($script, 'file', 'htmlarea_lang.js', false) . '"); ';
$plugins = '';
if ($prefs->getValue('tableoperations')) {
$js .= 'HTMLArea.loadPlugin("TableOperations"); ' .
'HTMLArea.loadScript("' . Util::addParameter($script, 'file', 'htmlarea_table_lang.js', false) . '"); ';
$plugins .= 'editor.registerPlugin(TableOperations); ';
}
if ($prefs->getValue('contextmenu')) {
$js .= 'HTMLArea.loadPlugin("ContextMenu"); ' .
'HTMLArea.loadScript("' . Util::addParameter($script, 'file', 'htmlarea_context_lang.js', false) . '"); ';
$plugins .= 'editor.registerPlugin(ContextMenu); ';
}
if ($prefs->getValue('listtype')) {
$js .= 'HTMLArea.loadPlugin("ListType"); ' .
'HTMLArea.loadScript("' . Util::addParameter($script, 'file', 'htmlarea_listtype_lang.js', false) . '"); ';
$plugins .= 'editor.registerPlugin(ListType); ';
}
if ($prefs->getValue('anselimage') && $registry->hasMethod('images/listGalleries')) {
$js .= 'HTMLArea.loadPlugin("AnselImage"); ' .
'HTMLArea.loadScript("' . Util::addParameter($script, 'file', 'htmlarea_anselimage_lang.js', false) . '"); ';
$plugins .= 'editor.registerPlugin(AnselImage); ';
}
$js .= 'HTMLArea.onload = function() { ' .
'var config = new HTMLArea.Config() ;' .
'config.debug = false; ' .
'config.hideSomeButtons(" showhelp "); ';
if (isset($params['config'])) {
foreach ($params['config'] as $config => $value) {
$js .= 'config.' . $config . ' = "' . addslashes($value) . '";';
}
}
if (isset($params['id'])) {
$js .= 'var textareas = [document.getElementById("' . $params['id'] . '")]; ';
} else {
$js .= 'var textareas = document.getElementsByTagName("textarea"); ';
}
$js .= 'for (var i = textareas.length - 1; i >= 0; i--) { ' .
'var editor = new HTMLArea(textareas[i], config); ' .
$plugins .
'editor.generate()}}; ' .
'HTMLArea.init();';
$notification->push($js, 'javascript');
}
}
|