Skip to content

Commit

Permalink
MDL-48482 core_admin: Added additional label for durations
Browse files Browse the repository at this point in the history
  • Loading branch information
marsh0lion committed Dec 16, 2014
1 parent 2d84748 commit 60b57b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions lang/en/admin.php
Expand Up @@ -439,6 +439,7 @@
$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';
Expand Down
17 changes: 12 additions & 5 deletions lib/adminlib.php
Expand Up @@ -3389,8 +3389,13 @@ public function output_html($data, $query='') {

$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 = '';
Expand All @@ -3404,7 +3409,7 @@ public function output_html($data, $query='') {
$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);
}
}

Expand Down Expand Up @@ -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
Expand All @@ -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();

Expand Down

0 comments on commit 60b57b6

Please sign in to comment.