3 require_once("$CFG->libdir/form/textarea.php");
6 * HTML class for htmleditor type element
11 class MoodleQuickForm_htmleditor
extends MoodleQuickForm_textarea
{
13 var $_canUseHtmlEditor;
14 var $_options=array('canUseHtmlEditor'=>'detect','rows'=>10, 'cols'=>45, 'width'=>0,'height'=>0);
15 function MoodleQuickForm_htmleditor($elementName=null, $elementLabel=null, $options=array(), $attributes=null){
16 parent
::MoodleQuickForm_textarea($elementName, $elementLabel, $attributes);
17 // set the options, do not bother setting bogus ones
18 if (is_array($options)) {
19 foreach ($options as $name => $value) {
20 if (array_key_exists($name, $this->_options
)) {
21 if (is_array($value) && is_array($this->_options
[$name])) {
22 $this->_options
[$name] = @array_merge
($this->_options
[$name], $value);
24 $this->_options
[$name] = $value;
29 if ($this->_options
['canUseHtmlEditor']=='detect'){
30 $this->_options
['canUseHtmlEditor']=can_use_html_editor();
32 if ($this->_options
['canUseHtmlEditor']){
33 $this->_type
='htmleditor';
34 //$this->_elementTemplateType='wide';
36 $this->_type
='textarea';
38 $this->_canUseHtmlEditor
= $this->_options
['canUseHtmlEditor'];
43 * set html for help button
46 * @param array $help array of arguments to make a help button
47 * @param string $function function name to call to get html
49 function setHelpButton($helpbuttonargs, $function='helpbutton'){
50 debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
54 //if ($this->_canUseHtmlEditor && !$this->_flagFrozen){
59 if ($this->_flagFrozen
) {
60 return $this->getFrozenHtml();
62 return $this->_getTabs() .
63 print_textarea($this->_canUseHtmlEditor
,
64 $this->_options
['rows'],
65 $this->_options
['cols'],
66 $this->_options
['width'],
67 $this->_options
['height'],
69 preg_replace("/(\r\n|\n|\r)/", '
',$this->getValue()),
72 $this->getAttribute('id'));
77 * What to display when element is frozen.
82 function getFrozenHtml()
84 $html = format_text($this->getValue());
85 return $html . $this->_getPersistantData();
86 } //end func getFrozenHtml