mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-14 18:08:21 +01:00
reorderded htmlarea so different htmlarea's can be configured seperately
This commit is contained in:
parent
fd6b69d7a8
commit
e7f0d8a133
@ -1,19 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
* eGroupWare - HTML creation class *
|
* eGroupWare - HTML creation class *
|
||||||
* http://www.eGroupWare.org *
|
* http://www.eGroupWare.org *
|
||||||
* Written and (c) by Ralf Becker <RalfBecker@outdoor-training.de> *
|
* Written and (c) by Ralf Becker <RalfBecker@outdoor-training.de> *
|
||||||
* -------------------------------------------- *
|
* -------------------------------------------- *
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
* under the terms of the GNU General Public License as published by the *
|
* under the terms of the GNU General Public License as published by the *
|
||||||
* Free Software Foundation; either version 2 of the License, or (at your *
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
||||||
* option) any later version. *
|
* option) any later version. *
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
class html
|
class html
|
||||||
{
|
{
|
||||||
var $user_agent,$ua_version; // 'mozilla','msie','konqueror'
|
var $user_agent,$ua_version; // 'mozilla','msie','konqueror'
|
||||||
var $prefered_img_title;
|
var $prefered_img_title;
|
||||||
var $charset,$phpgwapi_js_url;
|
var $charset,$phpgwapi_js_url;
|
||||||
@ -250,41 +250,35 @@ class html
|
|||||||
*/
|
*/
|
||||||
function htmlarea($name,$content='',$style='',$base_href='',$plugins='',$custom_toolbar='')
|
function htmlarea($name,$content='',$style='',$base_href='',$plugins='',$custom_toolbar='')
|
||||||
{
|
{
|
||||||
|
|
||||||
/* initialize the custom toolbar like the default initialization below
|
|
||||||
$custom_toolbar = '[
|
|
||||||
[ "fontname", "space",
|
|
||||||
"fontsize", "space",
|
|
||||||
"formatblock", "space",
|
|
||||||
"bold", "italic", "underline", "separator",
|
|
||||||
"strikethrough", "subscript", "superscript", "separator",
|
|
||||||
"copy", "cut", "paste", "space", "undo", "redo" ],
|
|
||||||
|
|
||||||
[ "justifyleft", "justifycenter", "justifyright", "justifyfull", "separator",
|
|
||||||
"orderedlist", "unorderedlist", "outdent", "indent", "separator",
|
|
||||||
"forecolor", "hilitecolor", "textindicator", "separator",
|
|
||||||
"inserthorizontalrule", "createlink", "insertimage", "inserttable", "htmlmode", "separator",
|
|
||||||
"popupeditor", "separator", "showhelp", "about" ]
|
|
||||||
];';
|
|
||||||
*/
|
|
||||||
|
|
||||||
if($custom_toolbar)
|
|
||||||
{
|
|
||||||
$custom_toolbar='htmlareaConfig.toolbar = '.$custom_toolbar;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$style) $style = 'width:100%; min-width:500px; height:300px;';
|
|
||||||
// check if htmlarea is availible for the browser and use a textarea if not
|
// check if htmlarea is availible for the browser and use a textarea if not
|
||||||
if (!$this->htmlarea_availible())
|
if (!$this->htmlarea_availible())
|
||||||
{
|
{
|
||||||
return $this->textarea($name,$content,'style="'.$style.'"');
|
return $this->textarea($name,$content,'style="'.$style.'"');
|
||||||
}
|
}
|
||||||
if (!$plugins) $plugins = 'ContextMenu,TableOperations,SpellChecker';
|
|
||||||
|
$id = str_replace(array('[',']'),array('_',''),$name); // no brakets in the id allowed by js
|
||||||
|
|
||||||
|
if($custom_toolbar)
|
||||||
|
{
|
||||||
|
$custom_toolbar='htmlareaConfig_'.$id.'.toolbar = '.$custom_toolbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$style)
|
||||||
|
{
|
||||||
|
$style = 'width:100%; min-width:500px; height:300px;';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$plugins)
|
||||||
|
{
|
||||||
|
$plugins = 'ContextMenu,TableOperations,SpellChecker';
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_object($GLOBALS['phpgw']->js))
|
if (!is_object($GLOBALS['phpgw']->js))
|
||||||
{
|
{
|
||||||
$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
|
$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* do stuff once */
|
||||||
if (!strstr($GLOBALS['phpgw_info']['flags']['java_script'],'htmlarea'))
|
if (!strstr($GLOBALS['phpgw_info']['flags']['java_script'],'htmlarea'))
|
||||||
{
|
{
|
||||||
$GLOBALS['phpgw']->js->validate_file('htmlarea','htmlarea');
|
$GLOBALS['phpgw']->js->validate_file('htmlarea','htmlarea');
|
||||||
@ -303,12 +297,11 @@ class html
|
|||||||
|
|
||||||
$GLOBALS['phpgw_info']['flags']['java_script_thirst'] .=
|
$GLOBALS['phpgw_info']['flags']['java_script_thirst'] .=
|
||||||
'<style type="text/css">@import url(' . $this->phpgwapi_js_url . '/htmlarea/htmlarea.css);</style>
|
'<style type="text/css">@import url(' . $this->phpgwapi_js_url . '/htmlarea/htmlarea.css);</style>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
_editor_url = "'."$this->phpgwapi_js_url/htmlarea/".'";
|
||||||
_editor_url = "'."$this->phpgwapi_js_url/htmlarea/".'";
|
// var htmlareaConfig = new HTMLArea.Config();
|
||||||
// var htmlareaConfig = new HTMLArea.Config();
|
// htmlareaConfig.editorURL = '."'$this->phpgwapi_js_url/htmlarea/';
|
||||||
// htmlareaConfig.editorURL = '."'$this->phpgwapi_js_url/htmlarea/';
|
</script>\n";
|
||||||
</script>\n";
|
|
||||||
|
|
||||||
// set a base href to get relative image-pathes working
|
// set a base href to get relative image-pathes working
|
||||||
if ($base_href && $this->user_agent != 'msie') // HTMLarea does not work in IE with base href set !!!
|
if ($base_href && $this->user_agent != 'msie') // HTMLarea does not work in IE with base href set !!!
|
||||||
@ -318,7 +311,6 @@ _editor_url = "'."$this->phpgwapi_js_url/htmlarea/".'";
|
|||||||
$base_href.'" />'."\n";
|
$base_href.'" />'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!empty($plugins))
|
if (!empty($plugins))
|
||||||
{
|
{
|
||||||
foreach(explode(',',$plugins) as $plg_name)
|
foreach(explode(',',$plugins) as $plg_name)
|
||||||
@ -342,17 +334,30 @@ _editor_url = "'."$this->phpgwapi_js_url/htmlarea/".'";
|
|||||||
'<script type="text/javascript" src="'.ereg_replace('[?&]*click_history=[0-9a-f]*','',
|
'<script type="text/javascript" src="'.ereg_replace('[?&]*click_history=[0-9a-f]*','',
|
||||||
$GLOBALS['phpgw']->link("/phpgwapi/js/htmlarea/plugins/$plg_name/lang/lang.php",array('lang'=>$lang))).'"></script>'."\n";
|
$GLOBALS['phpgw']->link("/phpgwapi/js/htmlarea/plugins/$plg_name/lang/lang.php",array('lang'=>$lang))).'"></script>'."\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* do stuff for every htmlarea in the page */
|
||||||
|
|
||||||
|
if (!empty($plugins))
|
||||||
|
{
|
||||||
|
foreach(explode(',',$plugins) as $plg_name)
|
||||||
|
{
|
||||||
//$load_plugin_string .= 'HTMLArea.loadPlugin("'.$plg_name.'");'."\n";
|
//$load_plugin_string .= 'HTMLArea.loadPlugin("'.$plg_name.'");'."\n";
|
||||||
$register_plugin_string .= 'ret_editor = editor.registerPlugin("'.$plg_name.'");'."\n";
|
$register_plugin_string .= 'ret_editor = editor.registerPlugin("'.$plg_name.'");'."\n";
|
||||||
|
// $register_plugin_string .= 'editor.registerPlugin("'.$plg_name.'");'."\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME strange bug when plugins are registered fullscreen editor don't work anymore
|
||||||
$GLOBALS['phpgw_info']['flags']['java_script'] .=
|
$GLOBALS['phpgw_info']['flags']['java_script'] .=
|
||||||
'<script type="text/javascript">
|
'<script type="text/javascript">
|
||||||
|
|
||||||
/** Replacement for the replace-helperfunction to make it possible to include plugins. */
|
// Replacement for the replace-helperfunction to make it possible to include plugins.
|
||||||
HTMLArea.replace = function(id, config)
|
HTMLArea.replace_'.$id.' = function(id, config)
|
||||||
{
|
{
|
||||||
var ta = HTMLArea.getElementById("textarea", id);
|
var ta = HTMLArea.getElementById("textarea", id);
|
||||||
|
|
||||||
if(ta)
|
if(ta)
|
||||||
@ -366,21 +371,20 @@ HTMLArea.replace = function(id, config)
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
'.$load_plugin_string.'
|
'.$load_plugin_string.'
|
||||||
|
|
||||||
var htmlareaConfig = new HTMLArea.Config();
|
var htmlareaConfig_'.$id.' = new HTMLArea.Config();
|
||||||
|
|
||||||
'.$custom_toolbar.'
|
'.$custom_toolbar.'
|
||||||
|
|
||||||
htmlareaConfig.editorURL = '."'$this->phpgwapi_js_url/htmlarea/';";
|
htmlareaConfig_'.$id.'.editorURL = '."'$this->phpgwapi_js_url/htmlarea/';";
|
||||||
|
|
||||||
$GLOBALS['phpgw_info']['flags']['java_script'] .="</script>\n";
|
$GLOBALS['phpgw_info']['flags']['java_script'] .="</script>\n";
|
||||||
}
|
|
||||||
$id = str_replace(array('[',']'),array('_',''),$name); // no brakets in the id allowed by js
|
|
||||||
|
|
||||||
$GLOBALS['phpgw']->js->set_onload("HTMLArea.replace('$id',htmlareaConfig);");
|
|
||||||
|
$GLOBALS['phpgw']->js->set_onload("HTMLArea.replace_$id('$id',htmlareaConfig_$id);");
|
||||||
|
|
||||||
if (!empty($style)) $style = " style=\"$style\"";
|
if (!empty($style)) $style = " style=\"$style\"";
|
||||||
|
|
||||||
@ -690,4 +694,4 @@ htmlareaConfig.editorURL = '."'$this->phpgwapi_js_url/htmlarea/';";
|
|||||||
}
|
}
|
||||||
return "<label$id$accesskey $options>$content</label>";
|
return "<label$id$accesskey $options>$content</label>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user