MDL-48482 core_admin: Added additional label for durations

This commit is contained in:
Brian Barnes 2014-12-04 13:42:35 +13:00
parent 2d84748c26
commit 60b57b6189
2 changed files with 13 additions and 5 deletions

View File

@ -439,6 +439,7 @@ $string['doclang'] = 'Language for docs';
$string['docroot'] = 'Moodle Docs document root';
$string['doctonewwindow'] = 'Open in new window';
$string['download'] = 'Download';
$string['durationunits'] = 'duration units';
$string['edithelpdocs'] = 'Edit help documents';
$string['editlang'] = '<b>Edit</b>';
$string['editorbackgroundcolor'] = 'Background colour';

View File

@ -3389,8 +3389,13 @@ class admin_setting_configduration extends admin_setting {
$units = self::get_units();
$inputid = $this->get_id() . 'v';
$return = '<div class="form-duration defaultsnext">';
$return .= '<input type="text" size="5" id="'.$this->get_id().'v" name="'.$this->get_full_name().'[v]" value="'.s($data['v']).'" />';
$return .= '<input type="text" size="5" id="' . $inputid . '" name="' . $this->get_full_name() .
'[v]" value="' . s($data['v']) . '" />';
$return .= '<label for="' . $this->get_id() . 'u" class="accesshide">' .
get_string('durationunits', 'admin') . '</label>';
$return .= '<select id="'.$this->get_id().'u" name="'.$this->get_full_name().'[u]">';
foreach ($units as $val => $text) {
$selected = '';
@ -3404,7 +3409,7 @@ class admin_setting_configduration extends admin_setting {
$return .= '<option value="'.$val.'"'.$selected.'>'.$text.'</option>';
}
$return .= '</select></div>';
return format_admin_setting($this, $this->visiblename, $return, $this->description, false, '', $defaultinfo, $query);
return format_admin_setting($this, $this->visiblename, $return, $this->description, $inputid, '', $defaultinfo, $query);
}
}
@ -6907,7 +6912,7 @@ function admin_output_new_settings_by_page($node) {
* @param string $title label element
* @param string $form form fragment, html code - not highlighted automatically
* @param string $description
* @param bool $label link label to id, true by default
* @param mixed $label link label to id, true by default or string being the label to connect it to
* @param string $warning warning text
* @param sting $defaultinfo defaults info, null means nothing, '' is converted to "Empty" string, defaults to null
* @param string $query search query to be highlighted
@ -6920,10 +6925,12 @@ function format_admin_setting($setting, $title='', $form='', $description='', $l
$fullname = $setting->get_full_name();
// sometimes the id is not id_s_name, but id_s_name_m or something, and this does not validate
if ($label) {
if ($label === true) {
$labelfor = 'for = "'.$setting->get_id().'"';
} else {
} else if ($label === false) {
$labelfor = '';
} else {
$labelfor = 'for="' . $label . '"';
}
$form .= $setting->output_setting_flags();