$mform->addElement('text','fullname', get_string("fullname"),'maxlength="254" size="50"');
$mform->addElement('text','shortname', get_string("shortname"),'maxlength="15" size="10"');
$mform->addElement('text','idnumber', get_string("idnumbercourse"),'maxlength="100" size="10"');
- $mform->addElement('htmleditor','summary', get_string("summary"), 'width="500" height="200" rows="10", cols="40"');
+ $mform->addElement('htmleditor','summary', get_string("summary"), array('rows'=>'10', 'cols'=>'65'));
$courseformats = get_list_of_plugins("course/format");
$formcourseformats = array();
var $_type;
var $_elementTemplateType='default';
var $_canUseHtmlEditor;
- var $_options=array('course'=>0);
- function moodleform_htmleditor($elementName=null, $elementLabel=null, $attributes=null){
+ var $_options=array('canUseHtmlEditor'=>'detect','rows'=>10, 'cols'=>65, 'width'=>0,'height'=>0, 'course'=>0);
+ function moodleform_htmleditor($elementName=null, $elementLabel=null, $options=array(), $attributes=null){
parent::moodleform_textarea($elementName, $elementLabel, $attributes);
- $this->_canUseHtmlEditor=can_use_html_editor();
- if ($this->_canUseHtmlEditor){
+ // set the options, do not bother setting bogus ones
+ if (is_array($options)) {
+ foreach ($options as $name => $value) {
+ if (isset($this->_options[$name])) {
+ if (is_array($value) && is_array($this->_options[$name])) {
+ $this->_options[$name] = @array_merge($this->_options[$name], $value);
+ } else {
+ $this->_options[$name] = $value;
+ }
+ }
+ }
+ }
+ if ($this->_options['canUseHtmlEditor']=='detect'){
+ $this->_options['canUseHtmlEditor']=can_use_html_editor();
+ }
+ if ($this->_options['canUseHtmlEditor']){
$this->_type='htmleditor';
//$this->_elementTemplateType='wide';
}else{
return $this->_elementTemplateType;
}
function toHtml(){
- if ($this->_canUseHtmlEditor){
+ if ($this->_options['canUseHtmlEditor'] && !$this->_flagFrozen){
ob_start();
use_html_editor($this->getName());
$script=ob_get_clean();
return $this->getFrozenHtml();
} else {
return $this->_getTabs() .
- print_textarea($this->_canUseHtmlEditor,
- $this->getAttribute('rows'),
- $this->getAttribute('cols'),
- $this->getAttribute('width'),
- $this->getAttribute('height'),
+ print_textarea($this->_options['canUseHtmlEditor'],
+ $this->_options['rows'],
+ $this->_options['cols'],
+ $this->_options['width'],
+ $this->_options['height'],
$this->getName(),
preg_replace("/(\r\n|\n|\r)/", '
',$this->getValue()),
$this->_options['course'],