create tinymce init function so this can be optinaly run before the header is sent.

This commit is contained in:
Pim Snel 2005-06-30 09:10:15 +00:00
parent c1da59af08
commit 15e32ce762

View File

@ -53,6 +53,7 @@ class html
*/ */
var $wz_tooltip_included = False; var $wz_tooltip_included = False;
/** /**
* Constructor: initialised the class-vars * Constructor: initialised the class-vars
*/ */
@ -596,11 +597,30 @@ htmlareaConfig_'.$id.'.editorURL = '."'$this->phpgwapi_js_url/htmlarea/';";
return "<textarea name=\"$name\" id=\"$id\"$style>".$this->htmlspecialchars($content)."</textarea>\n"; return "<textarea name=\"$name\" id=\"$id\"$style>".$this->htmlspecialchars($content)."</textarea>\n";
} }
/**
* init the tinymce js-widget by adding the js file in the head of the page
*
* Please note: it need to be called before the call to phpgw_header() !!!
*
*/
function init_tinymce()
{
/* do stuff once */
if (!is_object($GLOBALS['phpgw']->js))
{
$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
}
if (!strstr($GLOBALS['phpgw_info']['flags']['java_script'],'tinyMCE'))
{
$GLOBALS['phpgw']->js->validate_file('tinymce','jscripts/tiny_mce/tiny_mce');
}
}
/** /**
* creates a textarea inputfield for the tinymce js-widget (returns the necessary html and js) * creates a textarea inputfield for the tinymce js-widget (returns the necessary html and js)
* *
* Please note: it need to be called before the call to phpgw_header() !!! * Please note: if you did not run init_tinymce already you this function need to be called before the call to phpgw_header() !!!
* *
* @param string $name name and id of the input-field * @param string $name name and id of the input-field
* @param string $content='' of the tinymce (will be run through htmlspecialchars !!!), default '' * @param string $content='' of the tinymce (will be run through htmlspecialchars !!!), default ''
@ -617,22 +637,14 @@ htmlareaConfig_'.$id.'.editorURL = '."'$this->phpgwapi_js_url/htmlarea/';";
$style = 'width:100%; min-width:500px; height:300px;'; $style = 'width:100%; min-width:500px; height:300px;';
} }
/* do stuff once */
$this->init_tinymce();
if (!$this->htmlarea_availible()) if (!$this->htmlarea_availible())
{ {
return $this->textarea($name,$content,'style="'.$style.'"'); return $this->textarea($name,$content,'style="'.$style.'"');
} }
if (!is_object($GLOBALS['phpgw']->js))
{
$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
}
/* do stuff once */
if (!strstr($GLOBALS['phpgw_info']['flags']['java_script'],'tinyMCE'))
{
$GLOBALS['phpgw']->js->validate_file('tinymce','jscripts/tiny_mce/tiny_mce');
}
/* do again and again */ /* do again and again */
return ' return '
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">