Skip to content

Commit

Permalink
MDL-34853 code style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Aug 22, 2012
1 parent ef2737a commit 444af7c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
19 changes: 12 additions & 7 deletions lib/adminlib.php
Expand Up @@ -2828,11 +2828,16 @@ protected static function get_duration_text($seconds) {
} }
$data = self::parse_seconds($seconds); $data = self::parse_seconds($seconds);
switch ($data['u']) { switch ($data['u']) {
case (60*60*24*7) : return get_string('numweeks', '', $data['v']); case (60*60*24*7):
case (60*60*24) : return get_string('numdays', '', $data['v']); return get_string('numweeks', '', $data['v']);
case (60*60) : return get_string('numhours', '', $data['v']); case (60*60*24):
case (60) : return get_string('numminutes', '', $data['v']); return get_string('numdays', '', $data['v']);
default: return get_string('numseconds', '', $data['v']*$data['u']); case (60*60):
return get_string('numhours', '', $data['v']);
case (60):
return get_string('numminutes', '', $data['v']);
default:
return get_string('numseconds', '', $data['v']*$data['u']);
} }
} }


Expand All @@ -2843,7 +2848,7 @@ protected static function get_duration_text($seconds) {
* @return array * @return array
*/ */
protected static function parse_seconds($seconds) { protected static function parse_seconds($seconds) {
foreach (self::get_units() as $unit=>$unused) { foreach (self::get_units() as $unit => $unused) {
if ($seconds % $unit === 0) { if ($seconds % $unit === 0) {
return array('v'=>(int)($seconds/$unit), 'u'=>$unit); return array('v'=>(int)($seconds/$unit), 'u'=>$unit);
} }
Expand Down Expand Up @@ -2908,7 +2913,7 @@ public function output_html($data, $query='') {
$return = '<div class="form-duration defaultsnext">'; $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="'.$this->get_id().'v" name="'.$this->get_full_name().'[v]" value="'.s($data['v']).'" />';
$return .= '<select id="'.$this->get_id().'u" name="'.$this->get_full_name().'[u]">'; $return .= '<select id="'.$this->get_id().'u" name="'.$this->get_full_name().'[u]">';
foreach ($units as $val=>$text) { foreach ($units as $val => $text) {
$selected = ''; $selected = '';
if ($data['v'] == 0) { if ($data['v'] == 0) {
if ($val == $this->defaultunit) { if ($val == $this->defaultunit) {
Expand Down
4 changes: 2 additions & 2 deletions lib/form/duration.php
Expand Up @@ -58,8 +58,8 @@ class MoodleQuickForm_duration extends MoodleQuickForm_group {
* @param string $elementName Element's name * @param string $elementName Element's name
* @param mixed $elementLabel Label(s) for an element * @param mixed $elementLabel Label(s) for an element
* @param array $options Options to control the element's display. Recognised values are * @param array $options Options to control the element's display. Recognised values are
'optional' => true/false - whether to display an 'enabled' checkbox next to the element. * 'optional' => true/false - whether to display an 'enabled' checkbox next to the element.
'defaultunit' => 1|60|3600|86400|604800 - the default unit to display when the time is blank. * 'defaultunit' => 1|60|3600|86400|604800 - the default unit to display when the time is blank.
* If not specified, minutes is used. * If not specified, minutes is used.
* @param mixed $attributes Either a typical HTML attribute string or an associative array * @param mixed $attributes Either a typical HTML attribute string or an associative array
*/ */
Expand Down

0 comments on commit 444af7c

Please sign in to comment.