diff --git a/course/edit2.php b/course/edit2.php index ec6ac863aef..8cfa2160e7f 100644 --- a/course/edit2.php +++ b/course/edit2.php @@ -292,7 +292,7 @@ print_heading($streditcoursesettings); $mform->display(); - + print_footer($course); ?> diff --git a/course/edit_form.php b/course/edit_form.php index 12eb8337a1e..9c596355f1e 100644 --- a/course/edit_form.php +++ b/course/edit_form.php @@ -213,7 +213,7 @@ }else { $mform->addElement('hidden', 'restrictmodules', $default->restrictmodules); } - $mform->add_help_buttons(array('category'=>array("coursecategory", get_string("category")), + $mform->addHelpButtons(array('category'=>array("coursecategory", get_string("category")), 'fullname'=>array("coursefullname", get_string("fullname")), 'shortname'=>array("courseshortname", get_string("shortname")), 'idnumber'=>array("courseidnumber", get_string("idnumbercourse")), diff --git a/lang/en_utf8/form.php b/lang/en_utf8/form.php index ecaebdfa706..7b1754790b2 100644 --- a/lang/en_utf8/form.php +++ b/lang/en_utf8/form.php @@ -2,4 +2,5 @@ $string['denotesreq']='$a denotes required field.'; $string['requiredelement']='Required field.'; $string['nonexistentformelements']='Trying to add help buttons to nonexistent form elements : $a'; +$string['nomethodforaddinghelpbutton']='There is no method for adding a help button to form element $a->name (class $a->classname)'; ?> \ No newline at end of file diff --git a/lib/form/htmleditor.php b/lib/form/htmleditor.php index 5882cf43163..7630f5b76bd 100644 --- a/lib/form/htmleditor.php +++ b/lib/form/htmleditor.php @@ -9,26 +9,31 @@ require_once("$CFG->libdir/form/textarea.php"); * @access public */ class moodleform_htmleditor extends moodleform_textarea{ - var $_type = 'htmleditor'; + var $_type; var $_elementTemplateType='default'; var $_canUseHtmlEditor; var $_options=array('course'=>0); function moodleform_htmleditor($elementName=null, $elementLabel=null, $attributes=null){ + parent::moodleform_textarea($elementName, $elementLabel, $attributes); $this->_canUseHtmlEditor=can_use_html_editor(); if ($this->_canUseHtmlEditor){ - $this->_elementTemplateType='wide'; + $this->_type='htmleditor'; + //$this->_elementTemplateType='wide'; }else{ - $this->_elementTemplateType='default'; + $this->_type='textarea'; } - parent::moodleform_textarea($elementName, $elementLabel, $attributes); } function getElementTemplateType(){ return $this->_elementTemplateType; } function toHtml(){ - ob_start(); - use_html_editor($this->getName()); - $script=ob_get_clean(); + if ($this->_canUseHtmlEditor){ + ob_start(); + use_html_editor($this->getName()); + $script=ob_get_clean(); + } else { + $script=''; + } if ($this->_flagFrozen) { return $this->getFrozenHtml(); } else { diff --git a/lib/formslib.php b/lib/formslib.php index c9b70164471..cd020988cf1 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -91,7 +91,7 @@ class moodleform extends HTML_QuickForm_DHTMLRulesTableless{ if (!empty($oldclass)){ $this->updateAttributes(array('class'=>$oldclass.' mform')); }else { - $this->updateAttributes(array('class'=>'mform')); + $this->updateAttributes(array('class'=>'mform')); } $this->_helpImageURL="$CFG->wwwroot/lib/form/req.gif"; $this->_reqHTML = @@ -110,14 +110,19 @@ class moodleform extends HTML_QuickForm_DHTMLRulesTableless{ * * @access public */ - function add_help_buttons($buttons, $suppresscheck=false){ + function addHelpButtons($buttons, $suppresscheck=false){ foreach ($this->_elements as $no => $element){ if (array_key_exists($element->getName(), $buttons)){ - //dynamically create a property so we don't have to modify element - //class : - $this->_elements[$no]->setHelpButton($buttons[$element->getName()]); + if (method_exists($element, 'setHelpButton')){ + $this->_elements[$no]->setHelpButton($buttons[$element->getName()]); + }else{ + $a=new object(); + $a->name=$element->getName(); + $a->classname=get_class($element); + print_error('nomethodforaddinghelpbutton', 'form', '', $a); + } unset($buttons[$element->getName()]); } @@ -178,8 +183,8 @@ class moodleform_renderer extends HTML_QuickForm_Renderer_Tableless{ var $_elementTemplates; var $_htmleditors=array(); function moodleform_renderer(){ - $this->_elementTemplates=array('default'=>"\n\t\t