reorderded htmlarea so different htmlarea's can be configured seperately

This commit is contained in:
Pim Snel 2004-10-07 23:09:52 +00:00
parent fd6b69d7a8
commit e7f0d8a133

View File

@ -250,41 +250,35 @@ class html
*/
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
if (!$this->htmlarea_availible())
{
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))
{
$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
}
/* do stuff once */
if (!strstr($GLOBALS['phpgw_info']['flags']['java_script'],'htmlarea'))
{
$GLOBALS['phpgw']->js->validate_file('htmlarea','htmlarea');
@ -304,7 +298,6 @@ class html
$GLOBALS['phpgw_info']['flags']['java_script_thirst'] .=
'<style type="text/css">@import url(' . $this->phpgwapi_js_url . '/htmlarea/htmlarea.css);</style>
<script type="text/javascript">
_editor_url = "'."$this->phpgwapi_js_url/htmlarea/".'";
// var htmlareaConfig = new HTMLArea.Config();
// htmlareaConfig.editorURL = '."'$this->phpgwapi_js_url/htmlarea/';
@ -318,7 +311,6 @@ _editor_url = "'."$this->phpgwapi_js_url/htmlarea/".'";
$base_href.'" />'."\n";
}
if (!empty($plugins))
{
foreach(explode(',',$plugins) as $plg_name)
@ -342,16 +334,29 @@ _editor_url = "'."$this->phpgwapi_js_url/htmlarea/".'";
'<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";
}
//$load_plugin_string .= 'HTMLArea.loadPlugin("'.$plg_name.'");'."\n";
$register_plugin_string .= 'ret_editor = editor.registerPlugin("'.$plg_name.'");'."\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";
$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'] .=
'<script type="text/javascript">
/** Replacement for the replace-helperfunction to make it possible to include plugins. */
HTMLArea.replace = function(id, config)
// Replacement for the replace-helperfunction to make it possible to include plugins.
HTMLArea.replace_'.$id.' = function(id, config)
{
var ta = HTMLArea.getElementById("textarea", id);
@ -370,17 +375,16 @@ HTMLArea.replace = function(id, config)
'.$load_plugin_string.'
var htmlareaConfig = new HTMLArea.Config();
var htmlareaConfig_'.$id.' = new HTMLArea.Config();
'.$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";
}
$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\"";