Make logout work without needing openssl MDL-8070
[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 */
7f40a229 11class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{
80f962df 12 var $_type;
da6f8763 13 var $_elementTemplateType='default';
14 var $_canUseHtmlEditor;
5ae70385 15 var $_options=array('canUseHtmlEditor'=>'detect','rows'=>10, 'cols'=>65, 'width'=>0,'height'=>0, 'course'=>0);
7f40a229 16 function MoodleQuickForm_htmleditor($elementName=null, $elementLabel=null, $options=array(), $attributes=null){
17 parent::MoodleQuickForm_textarea($elementName, $elementLabel, $attributes);
5ae70385 18 // set the options, do not bother setting bogus ones
19 if (is_array($options)) {
20 foreach ($options as $name => $value) {
21 if (isset($this->_options[$name])) {
22 if (is_array($value) && is_array($this->_options[$name])) {
23 $this->_options[$name] = @array_merge($this->_options[$name], $value);
24 } else {
25 $this->_options[$name] = $value;
26 }
27 }
28 }
29 }
30 if ($this->_options['canUseHtmlEditor']=='detect'){
31 $this->_options['canUseHtmlEditor']=can_use_html_editor();
32 }
33 if ($this->_options['canUseHtmlEditor']){
80f962df 34 $this->_type='htmleditor';
35 //$this->_elementTemplateType='wide';
da6f8763 36 }else{
80f962df 37 $this->_type='textarea';
da6f8763 38 }
da6f8763 39 }
40 function getElementTemplateType(){
41 return $this->_elementTemplateType;
42 }
43 function toHtml(){
5ae70385 44 if ($this->_options['canUseHtmlEditor'] && !$this->_flagFrozen){
80f962df 45 ob_start();
7850588a 46 use_html_editor($this->getName(), '', $this->getAttribute('id'));
80f962df 47 $script=ob_get_clean();
48 } else {
49 $script='';
50 }
da6f8763 51 if ($this->_flagFrozen) {
52 return $this->getFrozenHtml();
53 } else {
54 return $this->_getTabs() .
5ae70385 55 print_textarea($this->_options['canUseHtmlEditor'],
56 $this->_options['rows'],
57 $this->_options['cols'],
58 $this->_options['width'],
59 $this->_options['height'],
da6f8763 60 $this->getName(),
61 preg_replace("/(\r\n|\n|\r)/", '&#010;',$this->getValue()),
62 $this->_options['course'],
7850588a 63 true,
64 $this->getAttribute('id')).$script;
da6f8763 65 }
66 } //end func toHtml
67
68}
69?>