/** * Called when visiting a header element * * @param HTML_QuickForm_header $header An HTML_QuickForm_header element being visited * @global moodle_page $PAGE */ function renderHeader(&$header) { global $PAGE; $header->_generateId(); $name = $header->getName(); $id = empty($name) ? '' : ' id="' . $header->getAttribute('id') . '"'; if (is_null($header->_text)) { $header_html = ''; } elseif (!empty($name) && isset($this->_templates[$name])) { $header_html = str_replace('{header}', $header->toHtml(), $this->_templates[$name]); } else { $header_html = str_replace('{header}', $header->toHtml(), $this->_headerTemplate); } if ($this->_fieldsetsOpen > 0) { $this->_html .= $this->_closeFieldsetTemplate; $this->_fieldsetsOpen--; } // Define collapsible classes for fieldsets. $arialive = ''; $fieldsetclasses = array('clearfix'); if (isset($this->_collapsibleElements[$header->getName()])) { $fieldsetclasses[] = 'collapsible'; if ($this->_collapsibleElements[$header->getName()]) { $fieldsetclasses[] = 'collapsed'; } } if (isset($this->_advancedElements[$name])) { $fieldsetclasses[] = 'containsadvancedelements'; } $openFieldsetTemplate = str_replace('{id}', $id, $this->_openFieldsetTemplate); $openFieldsetTemplate = str_replace('{classes}', join(' ', $fieldsetclasses), $openFieldsetTemplate); $this->_html .= $openFieldsetTemplate . $header_html; $this->_fieldsetsOpen++; }
/** * Called when visiting a header element * * @param HTML_QuickForm_header $header An HTML_QuickForm_header element being visited * @global moodle_page $PAGE */ function renderHeader(&$header) { global $PAGE; $name = $header->getName(); $id = empty($name) ? '' : ' id="' . $name . '"'; $id = preg_replace(array('/\\]/', '/\\[/'), array('', '_'), $id); if (is_null($header->_text)) { $header_html = ''; } elseif (!empty($name) && isset($this->_templates[$name])) { $header_html = str_replace('{header}', $header->toHtml(), $this->_templates[$name]); } else { $header_html = str_replace('{header}', $header->toHtml(), $this->_headerTemplate); } if (isset($this->_advancedElements[$name])) { $header_html = str_replace('{advancedimg}', $this->_advancedHTML, $header_html); $elementName = 'mform_showadvanced'; if ($this->_showAdvanced == 0) { $buttonlabel = get_string('showadvanced', 'form'); } else { $buttonlabel = get_string('hideadvanced', 'form'); } $button = '<input name="' . $elementName . '" class="showadvancedbtn" value="' . $buttonlabel . '" type="submit" />'; $PAGE->requires->js_init_call('M.form.initShowAdvanced', array(), false, moodleform::get_js_module()); $header_html = str_replace('{button}', $button, $header_html); } else { $header_html = str_replace('{advancedimg}', '', $header_html); $header_html = str_replace('{button}', '', $header_html); } if ($this->_fieldsetsOpen > 0) { $this->_html .= $this->_closeFieldsetTemplate; $this->_fieldsetsOpen--; } $openFieldsetTemplate = str_replace('{id}', $id, $this->_openFieldsetTemplate); if ($this->_showAdvanced) { $advclass = ' class="advanced"'; } else { $advclass = ' class="advanced hide"'; } if (isset($this->_advancedElements[$name])) { $openFieldsetTemplate = str_replace('{advancedclass}', $advclass, $openFieldsetTemplate); } else { $openFieldsetTemplate = str_replace('{advancedclass}', '', $openFieldsetTemplate); } $this->_html .= $openFieldsetTemplate . $header_html; $this->_fieldsetsOpen++; }