copy/paste typo
[moodle.git] / lib / form / htmleditor.php
CommitLineData
da6f8763 1<?php
2global $CFG;
3require_once("$CFG->libdir/form/textarea.php");
4
5/**
6 * HTML class for htmleditor type element
7 *
8 * @author Jamie Pratt
9 * @access public
10 */
11class moodleform_htmleditor extends moodleform_textarea{
80f962df 12 var $_type;
da6f8763 13 var $_elementTemplateType='default';
14 var $_canUseHtmlEditor;
15 var $_options=array('course'=>0);
16 function moodleform_htmleditor($elementName=null, $elementLabel=null, $attributes=null){
80f962df 17 parent::moodleform_textarea($elementName, $elementLabel, $attributes);
da6f8763 18 $this->_canUseHtmlEditor=can_use_html_editor();
19 if ($this->_canUseHtmlEditor){
80f962df 20 $this->_type='htmleditor';
21 //$this->_elementTemplateType='wide';
da6f8763 22 }else{
80f962df 23 $this->_type='textarea';
da6f8763 24 }
da6f8763 25 }
26 function getElementTemplateType(){
27 return $this->_elementTemplateType;
28 }
29 function toHtml(){
80f962df 30 if ($this->_canUseHtmlEditor){
31 ob_start();
32 use_html_editor($this->getName());
33 $script=ob_get_clean();
34 } else {
35 $script='';
36 }
da6f8763 37 if ($this->_flagFrozen) {
38 return $this->getFrozenHtml();
39 } else {
40 return $this->_getTabs() .
41 print_textarea($this->_canUseHtmlEditor,
42 $this->getAttribute('rows'),
43 $this->getAttribute('cols'),
44 $this->getAttribute('width'),
45 $this->getAttribute('height'),
46 $this->getName(),
47 preg_replace("/(\r\n|\n|\r)/", '&#010;',$this->getValue()),
48 $this->_options['course'],
49 true).$script;
50 }
51 } //end func toHtml
52
53}
54?>