MDL-39888 mnet: Removal of an old sql statement invloving the mdl_log table.
[moodle.git] / lib / form / htmleditor.php
blobadddc3fcf3e4826d29e06f1636830d464d1f160c
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * htmleditor type form element
21 * Contains HTML class for htmleditor type element
23 * @package core_form
24 * @copyright 2006 Jamie Pratt <me@jamiep.org>
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 global $CFG;
29 require_once("$CFG->libdir/form/textarea.php");
31 /**
32 * htmleditor type form element
34 * HTML class for htmleditor type element
36 * @package core_form
37 * @category form
38 * @copyright 2006 Jamie Pratt <me@jamiep.org>
39 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
41 class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{
42 /** @var string defines the type of editor */
43 var $_type;
45 /** @var array default options for html editor, which can be overridden */
46 var $_options=array('rows'=>10, 'cols'=>45, 'width'=>0,'height'=>0);
48 /**
49 * Constructor
51 * @param string $elementName (optional) name of the html editor
52 * @param string $elementLabel (optional) editor label
53 * @param array $options set of options to create html editor
54 * @param array $attributes (optional) Either a typical HTML attribute string
55 * or an associative array
57 function MoodleQuickForm_htmleditor($elementName=null, $elementLabel=null, $options=array(), $attributes=null){
58 parent::MoodleQuickForm_textarea($elementName, $elementLabel, $attributes);
59 // set the options, do not bother setting bogus ones
60 if (is_array($options)) {
61 foreach ($options as $name => $value) {
62 if (array_key_exists($name, $this->_options)) {
63 if (is_array($value) && is_array($this->_options[$name])) {
64 $this->_options[$name] = @array_merge($this->_options[$name], $value);
65 } else {
66 $this->_options[$name] = $value;
71 $this->_type='htmleditor';
73 editors_head_setup();
76 /**
77 * Returns the input field in HTML
79 * @return string
81 function toHtml(){
82 if ($this->_flagFrozen) {
83 return $this->getFrozenHtml();
84 } else {
85 return $this->_getTabs() .
86 print_textarea(true,
87 $this->_options['rows'],
88 $this->_options['cols'],
89 $this->_options['width'],
90 $this->_options['height'],
91 $this->getName(),
92 preg_replace("/(\r\n|\n|\r)/", '&#010;',$this->getValue()),
93 0, // unused anymore
94 true,
95 $this->getAttribute('id'));
99 /**
100 * What to display when element is frozen.
102 * @return string
104 function getFrozenHtml()
106 $html = format_text($this->getValue());
107 return $html . $this->_getPersistantData();