From: nicolasconnault Date: Wed, 29 Jul 2009 01:08:52 +0000 (+0000) Subject: MDL-19756 Migrated time selectors from weblib to outputlib X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c68e40989241e1ec6b568cbb0717231ab587ba6d;p=moodle.git MDL-19756 Migrated time selectors from weblib to outputlib --- diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index a0a09681fa..5ca3bbd46c 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -3196,3 +3196,106 @@ function choose_from_menu_nested($options,$name,$selected='',$nothing='choose',$ } } +/** + * Prints a help button about a scale + * + * @deprecated since Moodle 2.0 + * + * @global object + * @param id $courseid + * @param object $scale + * @param boolean $return If set to true returns rather than echo's + * @return string|bool Depending on value of $return + */ +function print_scale_menu_helpbutton($courseid, $scale, $return=false) { + // debugging('print_scale_menu_helpbutton() has been deprecated. Please change your code to use $OUTPUT->help_button($scaleselectmenu).'); + global $OUTPUT; + + $helpbutton = help_button::make_scale_menu($courseid, $scale); + + $output = $OUTPUT->help_button($helpbutton); + + if ($return) { + return $output; + } else { + echo $output; + } +} + + +/** + * Prints time limit value selector + * + * @deprecated since Moodle 2.0 + * + * Uses {@link choose_from_menu()} to generate HTML + * @see choose_from_menu() + * + * @global object + * @param int $timelimit default + * @param string $unit + * @param string $name + * @param boolean $return If set to true returns rather than echo's + * @return string|bool Depending on value of $return + */ +function print_timer_selector($timelimit = 0, $unit = '', $name = 'timelimit', $return=false) { + throw new coding_exception('print_timer_selector is completely deprecated. Please use $OUTPUT->select_menu($selectmenu) instead'); +} + +/** + * Prints form items with the names $hour and $minute + * + * @deprecated since Moodle 2.0 + * + * @param string $hour fieldname + * @param string $minute fieldname + * @param int $currenttime A default timestamp in GMT + * @param int $step minute spacing + * @param boolean $return If set to true returns rather than echo's + * @return string|bool Depending on value of $return + */ +function print_time_selector($hour, $minute, $currenttime=0, $step=5, $return=false) { + // debugging('print_time_selector() has been deprecated. Please change your code to use $OUTPUT->select_menu($timeselector).'); + global $OUTPUT; + $hourselector = moodle_select_menu::make_time_selector('hours', $hour, $currenttime); + $minuteselector = moodle_select_menu::make_time_selector('minutes', $minute, $currenttime, $step); + + $output = $OUTPUT->select_menu($hourselector) . $OUTPUT->select_menu($minuteselector); + + if ($return) { + return $output; + } else { + echo $output; + } +} + +/** + * Prints form items with the names $day, $month and $year + * + * @deprecated since Moodle 2.0 + * + * @param string $day fieldname + * @param string $month fieldname + * @param string $year fieldname + * @param int $currenttime A default timestamp in GMT + * @param boolean $return If set to true returns rather than echo's + * @return string|bool Depending on value of $return + */ +function print_date_selector($day, $month, $year, $currenttime=0, $return=false) { + + // debugging('print_date_selector() has been deprecated. Please change your code to use $OUTPUT->select_menu($dateselector).'); + global $OUTPUT; + + $dayselector = moodle_select_menu::make_time_selector('days', $day, $currenttime); + $monthselector = moodle_select_menu::make_time_selector('months', $month, $currenttime); + $yearselector = moodle_select_menu::make_time_selector('years', $year, $currenttime); + + $output = $OUTPUT->select_menu($dayselector) . $OUTPUT->select_menu($monthselector) . $OUTPUT->select_menu($yearselector); + + if ($return) { + return $output; + } else { + echo $output; + } +} + diff --git a/lib/outputlib.php b/lib/outputlib.php index 6079ac7698..22387bb498 100644 --- a/lib/outputlib.php +++ b/lib/outputlib.php @@ -2439,11 +2439,11 @@ class moodle_core_renderer extends moodle_renderer_base { throw new coding_exception('The 3rd param to $OUTPUT->confirm must be either a URL (string/moodle_url) or a html_form object.'); } - if (empty($continue->button->label)) { - $continue->button->label = get_string('yes'); + if (empty($continue->button->text)) { + $continue->button->text = get_string('yes'); } - if (empty($cancel->button->label)) { - $cancel->button->label = get_string('no'); + if (empty($cancel->button->text)) { + $cancel->button->text = get_string('no'); } $output = $this->box_start('generalbox', 'notice'); @@ -2470,7 +2470,7 @@ class moodle_core_renderer extends moodle_renderer_base { $buttonattributes = array('class' => $form->button->get_classes_string(), 'type' => 'submit', - 'value' => $form->button->label, + 'value' => $form->button->text, 'disabled' => $form->button->disabled, 'id' => $form->button->id); @@ -2799,7 +2799,7 @@ class moodle_core_renderer extends moodle_renderer_base { $html = ''; if (!empty($selectmenu->label)) { - $html .= $this->output_tag('label', array('for' => $selectmenu->name), $selectmenu->label); + $html .= $this->label($selectmenu->label); } $html .= $this->output_start_tag('select', $attributes) . "\n"; @@ -2810,7 +2810,7 @@ class moodle_core_renderer extends moodle_renderer_base { if (!is_array($values)) { var_dump($values); } - foreach ($values as $value => $label) { + foreach ($values as $value => $display) { $attributes = array('value' => $value); if ((string) $value == (string) $selectmenu->selectedvalue || @@ -2820,10 +2820,10 @@ class moodle_core_renderer extends moodle_renderer_base { $html .= $this->output_start_tag('option', $attributes); - if ($label === '') { + if ($display === '') { $html .= $value; } else { - $html .= $label; + $html .= $display; } $html .= $this->output_end_tag('option'); @@ -2831,13 +2831,13 @@ class moodle_core_renderer extends moodle_renderer_base { $html .= $this->output_end_tag('optgroup'); } } else { - foreach ($selectmenu->options as $value => $label) { + foreach ($selectmenu->options as $value => $display) { $attributes = array('value' => $value); if ((string) $value == (string) $selectmenu->selectedvalue || (is_array($selectmenu->selectedvalue) && in_array($value, $selectmenu->selectedvalue))) { $attributes['selected'] = 'selected'; } - $html .= ' ' . $this->output_tag('option', $attributes, s($label)) . "\n"; + $html .= ' ' . $this->output_tag('option', $attributes, s($display)) . "\n"; } } $html .= $this->output_end_tag('select') . "\n"; @@ -2845,7 +2845,16 @@ class moodle_core_renderer extends moodle_renderer_base { return $html; } - // TODO choose_from_menu_nested + /** + * Outputs a