make_categories_list($movetocategories, $notused, 'moodle/category:manage');
$movetocategories[$category->id] = get_string('moveselectedcoursesto');
echo '<tr><td colspan="3" align="right">';
- $selectmenu = new moodle_select_menu();
- $selectmenu->options = $movetocategories;
- $selectmenu->name = 'moveto';
- $selectmenu->selectedvalue = $category->id;
- $selectmenu->add_action('change', 'submit_form_by_id', array('id' => 'movecourses'));
- echo $OUTPUT->select_menu($selectmenu);
+ $select = new moodle_select();
+ $select->options = $movetocategories;
+ $select->name = 'moveto';
+ $select->selectedvalue = $category->id;
+ $select->add_action('change', 'submit_form_by_id', array('id' => 'movecourses'));
+ echo $OUTPUT->select($select);
echo '<input type="hidden" name="id" value="'.$category->id.'" />';
echo '</td></tr>';
}
echo '<input type="button" onclick="checknos()" value="'.get_string('selectnos').'" />'."\n";
}
$displaylist['messageselect.php'] = get_string('messageselectadd');
- $selectmenu = new moodle_select_menu();
- $selectmenu->options = $displaylist;
- $selectmenu->name = "formaction";
- $selectmenu->label = get_string("withselectedusers");
- $selectmenu->add_action('change', 'conditionalsubmit', array('formid' => 'studentsform'));
- echo $OUTPUT->select_menu($selectmenu);
+ $select = new moodle_select();
+ $select->options = $displaylist;
+ $select->name = "formaction";
+ $select->label = get_string("withselectedusers");
+ $select->add_action('change', 'conditionalsubmit', array('formid' => 'studentsform'));
+ echo $OUTPUT->select($select);
helpbutton("participantswithselectedusers", get_string("withselectedusers"));
echo '<input type="submit" value="' . get_string('ok') . '" />'."\n";
echo '</div>'."\n";
echo "<br />";
echo "<input type=\"button\" onclick=\"checkall()\" value=\"$strselectall\" />\n";
echo "<input type=\"button\" onclick=\"checknone()\" value=\"$strdeselectall\" />\n";
- $selectmenu = new moodle_select_menu();
- $selectmenu->options = $displaylist;
- $selectmenu->name = "moveto";
- $selectmenu->label = get_string("moveselectedcoursesto");
- $selectmenu->add_action('change', 'submit_form_by_id', array('id' => 'movecourses'));
- echo $OUTPUT->select_menu($selectmenu);
+ $select = new moodle_select();
+ $select->options = $displaylist;
+ $select->name = "moveto";
+ $select->label = get_string("moveselectedcoursesto");
+ $select->add_action('change', 'submit_form_by_id', array('id' => 'movecourses'));
+ echo $OUTPUT->select($select);
echo "</td>\n</tr>\n";
echo "</table>\n</form>";
if (!$context = get_context_instance(CONTEXT_COURSE, $course->id)) {
print_error('invalidcontext');
}
- redirect('index.php?contextid='.$context->id.'&itemid=0&filearea=course_content');
+ redirect(new moodle_url('index.php', array('contextid' => $context->id, 'itemid'=> 0, 'filearea' => 'course_content')));
}
if (!$context = get_context_instance_by_id($contextid)) {
if ($file_info and $file_info->is_directory() and $file_info->is_writable() and $newdirname !== '' and data_submitted() and confirm_sesskey()) {
if ($newdir_info = $file_info->create_directory($newdirname, $USER->id)) {
$params = $newdir_info->get_params_rawencoded();
- $params = implode('&', $params);
- redirect("index.php?$params");
+ redirect(new moodle_url('index.php', $params));
} else {
$error = "Could not create new dir"; // TODO: localise
}
try {
if ($newfile = $file_info->create_file_from_pathname($newfilename, $_FILES['newfile']['tmp_name'], $USER->id)) {
$params = $file_info->get_params_rawencoded();
- $params = implode('&', $params);
- redirect("index.php?$params");
+ redirect(new moodle_url('index.php', $params));
} else {
$error = "Could not create upload file"; // TODO: localise
$error = "Could not delete file!"; // TODO: localise
}
$params = $parent_info->get_params_rawencoded();
- $params = implode('&', $params);
- redirect("index.php?$params", $error);
+ redirect(new moodle_url('index.php', $params));
}
}
echo '<br /><br />';
echo '<input type="hidden" name="bulkmove" value="0" id="bulkmoveinput" />';
echo get_string('moveselectedto', 'grades') . ' ';
- $selectmenu = new moodle_select_menu();
- $selectmenu->options = $categories;
- $selectmenu->name = 'moveafter';
- $selectmenu->disabled = true;
- $selectmenu->id = 'menumoveafter';
- $selectmenu->add_action('change', 'submit_bulk_move');
- echo $OUTPUT->select_menu($selectmenu);
+ $select = new moodle_select();
+ $select->options = $categories;
+ $select->name = 'moveafter';
+ $select->disabled = true;
+ $select->id = 'menumoveafter';
+ $select->add_action('change', 'submit_bulk_move');
+ echo $OUTPUT->select($select);
echo '<div id="noscriptgradetreeform" style="display: inline;">
<input type="submit" value="'.get_string('go').'" />
</div>';
}
}
- $selectmenu = new moodle_select_menu();
- $selectmenu->options = $options;
- $selectmenu->name = 'aggregation_'.$category->id;
- $selectmenu->selectedvalue = $category->aggregation;
- $selectmenu->add_action('change', 'update_category_aggregation', array('courseid' => $params['id'], 'category' => $category->id, 'sesskey' => sesskey()));
- $aggregation = $OUTPUT->select_menu($selectmenu);
+ $select = new moodle_select();
+ $select->options = $options;
+ $select->name = 'aggregation_'.$category->id;
+ $select->selectedvalue = $category->aggregation;
+ $select->add_action('change', 'update_category_aggregation', array('courseid' => $params['id'], 'category' => $category->id, 'sesskey' => sesskey()));
+ $aggregation = $OUTPUT->select($select);
if ($this->forced) {
$aggregation = $options[$category->aggregation];
}
$output = $OUTPUT->button($form);
-
+
$icon = new action_icon();
if ($return) {
$id='', $listbox=false, $multiple=false, $class='') {
global $OUTPUT;
- // debugging('choose_from_menu() has been deprecated. Please change your code to use $OUTPUT->select_menu($selectmenu).');
+ // debugging('choose_from_menu() has been deprecated. Please change your code to use $OUTPUT->select($select).');
if ($script) {
debugging('The $script parameter has been deprecated. You must use component_actions instead', DEBUG_DEVELOPER);
}
- $selectmenu = new moodle_select_menu();
- $selectmenu->options = $options;
- $selectmenu->name = $name;
- $selectmenu->selectedvalue = $selected;
- $selectmenu->nothinglabel = $nothing;
- $selectmenu->nothingvalue = $nothingvalue;
- $selectmenu->disabled = $disabled;
- $selectmenu->tabindex = $tabindex;
- $selectmenu->id = $id;
- $selectmenu->listbox = $listbox;
- $selectmenu->multiple = $multiple;
- $selectmenu->add_classes($class);
+ $select = new moodle_select();
+ $select->options = $options;
+ $select->name = $name;
+ $select->selectedvalue = $selected;
+ $select->nothinglabel = $nothing;
+ $select->nothingvalue = $nothingvalue;
+ $select->disabled = $disabled;
+ $select->tabindex = $tabindex;
+ $select->id = $id;
+ $select->listbox = $listbox;
+ $select->multiple = $multiple;
+ $select->add_classes($class);
if ($nothing == 'choose') {
- $selectmenu->nothinglabel = '';
+ $select->nothinglabel = '';
}
- $output = $OUTPUT->select_menu($selectmenu);
+ $output = $OUTPUT->select($select);
if ($return) {
return $output;
*/
function choose_from_menu_yesno($name, $selected, $script = '',
$return = false, $disabled = false, $tabindex = 0) {
- // debugging('choose_from_menu_yesno() has been deprecated. Please change your code to use $OUTPUT->select_menu($selectmenu).');
+ // debugging('choose_from_menu_yesno() has been deprecated. Please change your code to use $OUTPUT->select($select).');
global $OUTPUT;
if ($script) {
debugging('The $script parameter has been deprecated. You must use component_actions instead', DEBUG_DEVELOPER);
}
- $selectmenu = moodle_select_menu::make_yes_no($name, $selected);
- $selectmenu->disabled = $disabled;
- $selectmenu->tabindex = $tabindex;
- $output = $OUTPUT->select_menu($select_menu);
+ $select = moodle_select::make_yes_no($name, $selected);
+ $select->disabled = $disabled;
+ $select->tabindex = $tabindex;
+ $output = $OUTPUT->select($select);
if ($return) {
return $output;
function choose_from_menu_nested($options,$name,$selected='',$nothing='choose',$script = '',
$nothingvalue=0,$return=false,$disabled=false,$tabindex=0) {
- // debugging('choose_from_menu_nested() has been deprecated. Please change your code to use $OUTPUT->select_menu($selectmenu).');
+ // debugging('choose_from_menu_nested() has been deprecated. Please change your code to use $OUTPUT->select($select).');
global $OUTPUT;
if ($script) {
debugging('The $script parameter has been deprecated. You must use component_actions instead', DEBUG_DEVELOPER);
}
- $selectmenu = moodle_select_menu::make($options, $name, $selected);
- $selectmenu->tabindex = $tabindex;
- $selectmenu->disabled = $disabled;
- $selectmenu->nothingvalue = $nothingvalue;
- $selectmenu->nested = true;
+ $select = moodle_select::make($options, $name, $selected);
+ $select->tabindex = $tabindex;
+ $select->disabled = $disabled;
+ $select->nothingvalue = $nothingvalue;
+ $select->nested = true;
if ($nothing == 'choose') {
- $selectmenu->nothinglabel = '';
+ $select->nothinglabel = '';
}
- $output = $OUTPUT->select_menu($selectmenu);
+ $output = $OUTPUT->select($select);
if ($return) {
return $output;
* @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).');
+ // debugging('print_scale_menu_helpbutton() has been deprecated. Please change your code to use $OUTPUT->help_button($scaleselect).');
global $OUTPUT;
$helpbutton = help_button::make_scale_menu($courseid, $scale);
* @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');
+ throw new coding_exception('print_timer_selector is completely deprecated. Please use $OUTPUT->select($select) instead');
}
/**
* @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).');
+ // debugging('print_time_selector() has been deprecated. Please change your code to use $OUTPUT->select($timeselector).');
global $OUTPUT;
- $hourselector = moodle_select_menu::make_time_selector('hours', $hour, $currenttime);
- $minuteselector = moodle_select_menu::make_time_selector('minutes', $minute, $currenttime, $step);
+ $hourselector = moodle_select::make_time_selector('hours', $hour, $currenttime);
+ $minuteselector = moodle_select::make_time_selector('minutes', $minute, $currenttime, $step);
- $output = $OUTPUT->select_menu($hourselector) . $OUTPUT->select_menu($minuteselector);
+ $output = $OUTPUT->select($hourselector) . $OUTPUT->select($minuteselector);
if ($return) {
return $output;
*/
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).');
+ // debugging('print_date_selector() has been deprecated. Please change your code to use $OUTPUT->select($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);
+ $dayselector = moodle_select::make_time_selector('days', $day, $currenttime);
+ $monthselector = moodle_select::make_time_selector('months', $month, $currenttime);
+ $yearselector = moodle_select::make_time_selector('years', $year, $currenttime);
- $output = $OUTPUT->select_menu($dayselector) . $OUTPUT->select_menu($monthselector) . $OUTPUT->select_menu($yearselector);
+ $output = $OUTPUT->select($dayselector) . $OUTPUT->select($monthselector) . $OUTPUT->select($yearselector);
if ($return) {
return $output;
$targetwindow='self', $selectlabel='', $optionsextra=NULL, $submitvalue='', $disabled=false, $showbutton=false) {
global $OUTPUT;
- // debugging('popup_form() has been deprecated. Please change your code to use $OUTPUT->select_menu($dateselector).');
+ // debugging('popup_form() has been deprecated. Please change your code to use $OUTPUT->select($dateselector).');
if (!empty($optionsextra)) {
debugging('the optionsextra param has been deprecated in popup_form, it will be ignored.', DEBUG_DEVELOPER);
if (empty($options)) {
return '';
}
- $selectmenu = moodle_select_menu::make_popup_form($baseurl, $options, $formid, $submitvalue, $selected);
- $selectmenu->disabled = $disabled;
-
+ $select = moodle_select::make_popup_form($baseurl, $options, $formid, $submitvalue, $selected);
+ $select->disabled = $disabled;
+
// Extract the last param of the baseurl for the name of the select
if (preg_match('/([a-z_]*)=$/', $baseurl, $matches)) {
- $selectmenu->name = $matches[1];
- $selectmenu->form->url->remove_params(array($matches[1]));
+ $select->name = $matches[1];
+ $select->form->url->remove_params(array($matches[1]));
}
if ($nothing == 'choose') {
- $selectmenu->nothinglabel = '';
+ $select->nothinglabel = '';
} else {
- $selectmenu->nothinglabel = $nothing;
+ $select->nothinglabel = $nothing;
}
- $selectmenu->set_label($selectlabel, $selectmenu->id);
- $selectmenu->set_help_icon($help, $helptext);
+ $select->set_label($selectlabel, $select->id);
+ $select->set_help_icon($help, $helptext);
- $output = $OUTPUT->select_menu($selectmenu);
+ $output = $OUTPUT->select($select);
if ($return) {
return $output;
*/
function close_window_button($name='closewindow', $return=false, $reloadopener = false) {
global $OUTPUT;
-
+
// debugging('close_window_button() has been deprecated. Please change your code to use $OUTPUT->close_window_button().');
$output = $OUTPUT->close_window_button(get_string($name));
-
+
if ($return) {
return $output;
} else {
echo $output;
}
}
+
+/**
+ * Given an array of values, creates a group of radio buttons to be part of a form
+ *
+ * @deprecated since Moodle 2.0
+ *
+ * @staticvar int $idcounter
+ * @param array $options An array of value-label pairs for the radio group (values as keys)
+ * @param string $name Name of the radiogroup (unique in the form)
+ * @param string $checked The value that is already checked
+ * @param bool $return Whether this function should return a string or output
+ * it (defaults to false)
+ * @return string|void If $return=true returns string, else echo's and returns void
+ */
+function choose_from_radio ($options, $name, $checked='', $return=false) {
+
+ // debugging('choose_from_radio() has been deprecated. Please change your code to use $OUTPUT->select($select).');
+ global $OUTPUT;
+
+ $select = moodle_select::make($options, $name, $checked);
+ $select->rendertype = 'radio';
+
+ $output = $OUTPUT->select($select);
+
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
+}
+
+/**
+ * Display an standard html checkbox with an optional label
+ *
+ * @deprecated since Moodle 2.0
+ *
+ * @staticvar int $idcounter
+ * @param string $name The name of the checkbox
+ * @param string $value The valus that the checkbox will pass when checked
+ * @param bool $checked The flag to tell the checkbox initial state
+ * @param string $label The label to be showed near the checkbox
+ * @param string $alt The info to be inserted in the alt tag
+ * @param string $script If not '', then this is added to the checkbox element
+ * as an onchange handler.
+ * @param bool $return Whether this function should return a string or output
+ * it (defaults to false)
+ * @return string|void If $return=true returns string, else echo's and returns void
+ */
+function print_checkbox ($name, $value, $checked = true, $label = '', $alt = '', $script='',$return=false) {
+
+ // debugging('print_checkbox() has been deprecated. Please change your code to use $OUTPUT->checkbox($checkbox).');
+ global $OUTPUT;
+
+ if (!empty($script)) {
+ debugging('The use of the $script param in print_checkbox has not been migrated into $OUTPUT->checkbox. Please use $checkbox->add_action().', DEBUG_DEVELOPER);
+ }
+
+ $checkbox = new html_select_option();
+ $checkbox->value = $value;
+ $checkbox->selected = $checked;
+ $checkbox->text = $label;
+ $checkbox->label->text = $label;
+ $checkbox->alt = $alt;
+
+ $output = $OUTPUT->checkbox($checkbox, $name);
+
+ if (empty($return)) {
+ echo $output;
+ } else {
+ return $output;
+ }
+
+}
* submits the form designated by args.id. If args.selectid is also
* given, it only submits the form if the selected <option> is not
* the first one (usually the "Choose..." option)
- * Example usage of the moodle_select_menu component with this function:
+ * Example usage of the moodle_select component with this function:
* <pre>
- * $selectmenu = new moodle_select_menu();
- * $selectmenu->options = array('delete' => get_string('delete'));
- * $selectmenu->name = 'action';
- * $selectmenu->button->label = get_string('withselected', 'quiz');
- * $selectmenu->id = 'menuaction';
- * $selectmenu->add_action('change', 'submit_form_by_id', array('id' => 'attemptsform', 'selectid' => 'menuaction'));
- * echo $OUTPUT->select_menu($selectmenu);
+ * $select = new moodle_select();
+ * $select->options = array('delete' => get_string('delete'));
+ * $select->name = 'action';
+ * $select->button->label = get_string('withselected', 'quiz');
+ * $select->id = 'menuaction';
+ * $select->add_action('change', 'submit_form_by_id', array('id' => 'attemptsform', 'selectid' => 'menuaction'));
+ * echo $OUTPUT->select($select);
* </pre>
*/
function submit_form_by_id(e, args) {
* @return string HTML fragment
*/
protected function output_attribute($name, $value) {
+ if (is_array($value)) {
+ debugging("Passed an array for the HTML attribute $name", DEBUG_DEVELOPER);
+ }
+
$value = trim($value);
if ($value == HTML_ATTR_EMPTY) {
return ' ' . $name . '=""';
return $output . $this->output_end_tag($tag);
}
-
+
/**
* Prints a simple button to close a window
*
return $this->container($this->button($closeform), 'closewindow');
}
- public function close_window($delay = 0, $reloadopener = false) {
- // TODO
- }
-
/**
- * Output a <select> menu.
+ * Outputs a <select> menu or a list of radio/checkbox inputs.
*
* This method is extremely versatile, and can be used to output yes/no menus,
* form-enclosed menus with automatic redirects when an option is selected,
* descriptive labels and help icons. By default it just outputs a select
* menu.
*
- * To add a descriptive label, use moodle_select_menu::set_label($text, $for) or
- * moodle_select_menu::set_label($label) passing a html_label object
+ * To add a descriptive label, use moodle_select::set_label($text, $for) or
+ * moodle_select::set_label($label) passing a html_label object
+ *
+ * To add a help icon, use moodle_select::set_help($page, $text, $linktext) or
+ * moodle_select::set_help($helpicon) passing a help_icon object
*
- * To add a help icon, use moodle_select_menu::set_help($page, $text, $linktext) or
- * moodle_select_menu::set_help($helpicon) passing a help_icon object
+ * If you moodle_select::$rendertype to "radio", it will render radio buttons
+ * instead of a <select> menu, unless $multiple is true, in which case it
+ * will render checkboxes.
*
- * To surround the menu with a form, simply set moodle_select_menu->form as a
- * valid html_form object.
+ * To surround the menu with a form, simply set moodle_select->form as a
+ * valid html_form object. Note that this function will NOT automatically
+ * add a form for non-JS browsers. If you do not set one up, it assumes
+ * that you are providing your own form in some other way.
*
- * You can either call this function with a single moodle_select_menu argument
+ * You can either call this function with a single moodle_select argument
* or, with a list of parameters, in which case those parameters are sent to
- * the moodle_select_menu constructor.
+ * the moodle_select constructor.
*
- * @param moodle_select_menu $selectmenu a moodle_select_menu that describes
+ * @param moodle_select $select a moodle_select that describes
* the select menu you want output.
* @return string the HTML for the <select>
*/
- public function select_menu($selectmenu) {
- $selectmenu = clone($selectmenu);
- $selectmenu->prepare();
+ public function select($select) {
+ $select = clone($select);
+ $select->prepare();
- $this->prepare_event_handlers($selectmenu);
+ $this->prepare_event_handlers($select);
- if (empty($selectmenu->id)) {
- $selectmenu->id = 'menu' . str_replace(array('[', ']'), '', $selectmenu->name);
+ if (empty($select->id)) {
+ $select->id = 'menu' . str_replace(array('[', ']'), '', $select->name);
}
$attributes = array(
- 'name' => $selectmenu->name,
- 'id' => $selectmenu->id,
- 'class' => $selectmenu->get_classes_string()
+ 'name' => $select->name,
+ 'id' => $select->id,
+ 'class' => $select->get_classes_string()
);
- if ($selectmenu->disabled) {
+ if ($select->disabled) {
$attributes['disabled'] = 'disabled';
}
- if ($selectmenu->tabindex) {
+ if ($select->tabindex) {
$attributes['tabindex'] = $tabindex;
}
- if ($selectmenu->listbox) {
- if (is_integer($selectmenu->listbox)) {
- $size = $selectmenu->listbox;
+ if ($select->rendertype == 'menu' && $select->listbox) {
+ if (is_integer($select->listbox)) {
+ $size = $select->listbox;
} else {
- $size = min($selectmenu->maxautosize, count($selectmenu->options));
+ $size = min($select->maxautosize, count($select->options));
}
$attributes['size'] = $size;
- if ($selectmenu->multiple) {
+ if ($select->multiple) {
$attributes['multiple'] = 'multiple';
}
}
$html = '';
- if (!empty($selectmenu->label)) {
- $html .= $this->label($selectmenu->label);
+ if (!empty($select->label)) {
+ $html .= $this->label($select->label);
}
- if (!empty($selectmenu->helpicon) && $selectmenu->helpicon instanceof help_icon) {
- $html .= $this->help_icon($selectmenu->helpicon);
+ if (!empty($select->helpicon) && $select->helpicon instanceof help_icon) {
+ $html .= $this->help_icon($select->helpicon);
}
- $html .= $this->output_start_tag('select', $attributes) . "\n";
+ if ($select->rendertype == 'menu') {
+ $html .= $this->output_start_tag('select', $attributes) . "\n";
- foreach ($selectmenu->options as $option) {
- // $OUTPUT->select_option detects if $option is an option or an optgroup
- $html .= $this->select_option($option);
- }
+ foreach ($select->options as $option) {
+ // $OUTPUT->select_option detects if $option is an option or an optgroup
+ $html .= $this->select_option($option);
+ }
- $html .= $this->output_end_tag('select') . "\n";
+ $html .= $this->output_end_tag('select') . "\n";
+ } else if ($select->rendertype == 'radio') {
+ $currentradio = 0;
+ foreach ($select->options as $option) {
+ $html .= $this->radio($option, $select->name);
+ $currentradio++;
+ }
+ } else if ($select->rendertype == 'checkbox') {
+ $currentcheckbox = 0;
+ foreach ($select->options as $option) {
+ $html .= $this->checkbox($option, $select->name);
+ $currentcheckbox++;
+ }
+
+ }
- if (!empty($selectmenu->form) && $selectmenu->form instanceof html_form) {
- $html = $this->form($selectmenu->form, $html);
+ if (!empty($select->form) && $select->form instanceof html_form) {
+ $html = $this->form($select->form, $html);
}
return $html;
}
+ /**
+ * Outputs a <input type="radio" /> element. Optgroups are ignored, so do not
+ * pass a html_select_optgroup as a param to this function.
+ *
+ * @param html_select_option $option a html_select_option
+ * @return string the HTML for the <input type="radio">
+ */
+ public function radio($option, $name='unnamed') {
+ if ($option instanceof html_select_optgroup) {
+ throw new coding_exception('$OUTPUT->radio($option) does not support a html_select_optgroup object as param.');
+ } else if (!($option instanceof html_select_option)) {
+ throw new coding_exception('$OUTPUT->radio($option) only accepts a html_select_option object as param.');
+ }
+
+ $option->prepare();
+ $option->generate_id();
+ $option->label->for = $option->id;
+ $this->prepare_event_handlers($option);
+
+ $output = $this->output_start_tag('span', array('class' => "radiogroup $select->name rb$currentradio")) . "\n";
+ $output .= $this->label($option->label);
+
+ if ($option->selected == 'selected') {
+ $option->selected = 'checked';
+ }
+
+ $output .= $this->output_empty_tag('input', array(
+ 'type' => 'radio',
+ 'value' => $option->value,
+ 'name' => $name,
+ 'alt' => $option->alt,
+ 'id' => $option->id,
+ 'class' => $option->get_classes_string(),
+ 'checked' => $option->selected));
+
+ $output .= $this->output_end_tag('span');
+
+ return $output;
+ }
+
+ /**
+ * Outputs a <input type="checkbox" /> element. Optgroups are ignored, so do not
+ * pass a html_select_optgroup as a param to this function.
+ *
+ * @param html_select_option $option a html_select_option
+ * @return string the HTML for the <input type="checkbox">
+ */
+ public function checkbox($option, $name='unnamed') {
+ if ($option instanceof html_select_optgroup) {
+ throw new coding_exception('$OUTPUT->checkbox($option) does not support a html_select_optgroup object as param.');
+ } else if (!($option instanceof html_select_option)) {
+ throw new coding_exception('$OUTPUT->checkbox($option) only accepts a html_select_option object as param.');
+ }
+
+ $option->prepare();
+ $option->generate_id();
+ $option->label->for = $option->id;
+ $this->prepare_event_handlers($option);
+
+ $output = $this->output_start_tag('span', array('class' => "checkbox $name")) . "\n";
+
+ if ($option->selected == 'selected') {
+ $option->selected = 'checked';
+ }
+
+ $output .= $this->output_empty_tag('input', array(
+ 'type' => 'checkbox',
+ 'value' => $option->value,
+ 'name' => $name,
+ 'id' => $option->id,
+ 'alt' => $option->alt,
+ 'class' => $option->get_classes_string(),
+ 'checked' => $option->selected));
+ $output .= $this->label($option->label);
+
+ $output .= $this->output_end_tag('span');
+
+ return $output;
+ }
+
/**
* Output an <option> or <optgroup> element. If an optgroup element is detected,
* this will recursively output its options as well.
*
- * @param mixed $option a moodle_select_option or moodle_select_optgroup
+ * @param mixed $option a html_select_option or moodle_select_optgroup
* @return string the HTML for the <option> or <optgroup>
*/
public function select_option($option) {
/// COMPONENTS
/**
- * Base class for classes representing HTML elements, like moodle_select_menu.
+ * Base class for classes representing HTML elements, like moodle_select.
*
* Handles the id and class attributes.
*
* @var string value to use for the id attribute of this HTML tag.
*/
public $id = '';
+ /**
+ * @var string $alt value to use for the alt attribute of this HTML tag.
+ */
+ public $alt = '';
/**
* @var array class names to add to this HTML element.
*/
/**
* Internal method for generating a unique ID for the purpose of event handlers.
*/
- protected function generate_id() {
+ public function generate_id() {
// Generate an id that is not already used.
do {
$newid = get_class($this) . '-' . substr(sha1(microtime() * rand(0, 500)), 0, 6);
public function get_actions() {
return $this->actions;
}
+
+ /**
+ * Adds a descriptive label to the component.
+ *
+ * This can be used in two ways:
+ *
+ * <pre>
+ * $component->set_label($elementid, $elementlabel);
+ * // OR
+ * $label = new html_label();
+ * $label->for = $elementid;
+ * $label->text = $elementlabel;
+ * $component->set_label($label);
+ * </pre>
+ *
+ * Use the second form when you need to add additional HTML attributes
+ * to the label and/or JS actions.
+ *
+ * @param mixed $text Either the text of the label or a html_label object
+ * @param text $for The value of the "for" attribute (the associated element's id)
+ * @return void
+ */
+ public function set_label($text, $for=null) {
+ if ($text instanceof html_label) {
+ $this->label = $text;
+ } else if (!empty($text)) {
+ $this->label = new html_label();
+ $this->label->for = $for;
+ $this->label->text = $text;
+ }
+ }
}
/**
* This class hold all the information required to describe a <select> menu that
- * will be printed by {@link moodle_core_renderer::select_menu()}. (Or by an overridden
+ * will be printed by {@link moodle_core_renderer::select()}. (Or by an overridden
* version of that method in a subclass.)
*
* This component can also hold enough metadata to be used as a popup form. It just
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
*/
-class moodle_select_menu extends moodle_html_component {
+class moodle_select extends moodle_html_component {
/**
- * The moodle_select_menu object parses an array of options into component objects
+ * The moodle_select object parses an array of options into component objects
* @see nested attribute
* @var mixed $options the choices to show in the menu. An array $value => $display, of html_select_option or of html_select_optgroup objects.
*/
*/
public $selectedvalue;
/**
- * @var string The label for the 'nothing is selected' option.
* Defaults to get_string('choosedots').
* Set this to '' if you do not want a 'nothing is selected' option.
+ * This is ignored if the rendertype is 'radio' or 'checkbox'
+ * @var string The label for the 'nothing is selected' option.
*/
public $nothinglabel = null;
/**
*/
public $maxautosize = 10;
/**
- * @var boolean if true, allow multiple selection. Only used if $listbox is true.
+ * @var boolean if true, allow multiple selection. Only used if $listbox is true, or if
+ * the select is to be output as checkboxes.
*/
public $multiple = false;
/**
* @var help_icon $form An optional help_icon component
*/
public $helpicon;
+ /**
+ * @var boolean $rendertype How the select element should be rendered: menu or radio (checkbox is just radio + multiple)
+ */
+ public $rendertype = 'menu';
/**
* @see moodle_html_component::prepare()
$this->nothinglabel = get_string('choosedots');
}
- // If nested is on, remove the default Choose option
- if ($this->nested) {
+ if ($this->rendertype == 'radio' && $this->multiple) {
+ $this->rendertype = 'checkbox';
+ }
+
+ // If nested is on, or if radio/checkbox rendertype is set, remove the default Choose option
+ if ($this->nested || $this->rendertype == 'radio' || $this->rendertype == 'checkbox') {
$this->nothinglabel = '';
}
}
$options = $this->options;
+
$this->options = array();
- if ($this->nested) {
+ if ($this->nested && $this->rendertype != 'menu') {
+ throw new coding_exception('moodle_select cannot render nested options as radio buttons or checkboxes.');
+ } else if ($this->nested) {
foreach ($options as $section => $values) {
$optgroup = new html_select_optgroup();
$optgroup->text = $section;
* @param array $options used to initialise {@link $options}.
* @param string $name used to initialise {@link $name}.
* @param string $selected used to initialise {@link $selected}.
- * @return moodle_select_menu A moodle_select_menu object with the three common fields initialised.
+ * @return moodle_select A moodle_select object with the three common fields initialised.
*/
public static function make($options, $name, $selected = '') {
- $menu = new moodle_select_menu();
+ $menu = new moodle_select();
$menu->options = $options;
$menu->name = $name;
$menu->selectedvalue = $selected;
* This is a shortcut for making a yes/no select menu.
* @param string $name used to initialise {@link $name}.
* @param string $selected used to initialise {@link $selected}.
- * @return moodle_select_menu A menu initialised with yes/no options.
+ * @return moodle_select A menu initialised with yes/no options.
*/
public static function make_yes_no($name, $selected) {
return self::make(array(0 => get_string('no'), 1 => get_string('yes')), $name, $selected);
* @param string $name fieldname
* @param int $currenttime A default timestamp in GMT
* @param int $step minute spacing
- * @return moodle_select_menu A menu initialised with hour options.
+ * @return moodle_select A menu initialised with hour options.
*/
public static function make_time_selector($type, $name, $currenttime=0, $step=5) {
}
break;
default:
- throw new coding_exception("Time type $type is not supported by moodle_select_menu::make_time_selector().");
+ throw new coding_exception("Time type $type is not supported by moodle_select::make_time_selector().");
}
$timerselector = self::make($timeunits, $name, $currentdate[$userdatetype]);
* @param string $formid id for the control. Must be unique on the page. Used in the HTML.
* @param string $submitvalue Optional label for the 'Go' button. Defaults to get_string('go').
* @param string $selected The option that is initially selected
- * @return moodle_select_menu A menu initialised as a popup form.
+ * @return moodle_select A menu initialised as a popup form.
*/
public function make_popup_form($baseurl, $options, $formid, $submitvalue='', $selected=null) {
- $selectmenu = self::make($options, 'jump', $selected);
- $selectmenu->form = new html_form();
- $selectmenu->form->id = $formid;
- $selectmenu->form->method = 'get';
- $selectmenu->form->add_class('popupform');
- $selectmenu->form->url = new moodle_url($baseurl);
- $selectmenu->form->button->text = get_string('go');
+ $select = self::make($options, 'jump', $selected);
+ $select->form = new html_form();
+ $select->form->id = $formid;
+ $select->form->method = 'get';
+ $select->form->add_class('popupform');
+ $select->form->url = new moodle_url($baseurl);
+ $select->form->button->text = get_string('go');
if (!empty($submitvalue)) {
- $selectmenu->form->button->text = $submitvalue;
+ $select->form->button->text = $submitvalue;
}
- $selectmenu->id = $formid . '_jump';
- $selectmenu->baseurl = $baseurl;
+ $select->id = $formid . '_jump';
+ $select->baseurl = $baseurl;
- $selectmenu->add_action('change', 'submit_form_by_id', array('id' => $formid, 'selectid' => $selectmenu->id));
+ $select->add_action('change', 'submit_form_by_id', array('id' => $formid, 'selectid' => $select->id));
- return $selectmenu;
- }
-
- /**
- * Adds a descriptive label to the select menu.
- *
- * This can be used in two ways:
- *
- * <pre>
- * $selectmenu->set_label($elementid, $elementlabel);
- * // OR
- * $label = new html_label();
- * $label->for = $elementid;
- * $label->text = $elementlabel;
- * $selectmenu->set_label($label);
- * </pre>
- *
- * Use the second form when you need to add additional HTML attributes
- * to the label and/or JS actions.
- *
- * @param mixed $text Either the text of the label or a html_label object
- * @param text $for The value of the "for" attribute (the associated element's id)
- * @return void
- */
- public function set_label($text, $for=null) {
- if ($text instanceof html_label) {
- $this->label = $text;
- } else if (!empty($text)) {
- $this->label = new html_label();
- $this->label->for = $for;
- $this->label->text = $text;
- }
+ return $select;
}
/**
* This can be used in two ways:
*
* <pre>
- * $selectmenu->set_help_icon($page, $text, $linktext);
+ * $select->set_help_icon($page, $text, $linktext);
* // OR
* $helpicon = new help_icon();
* $helpicon->page = $page;
* $helpicon->text = $text;
* $helpicon->linktext = $linktext;
- * $selectmenu->set_help_icon($helpicon);
+ * $select->set_help_icon($helpicon);
* </pre>
*
* Use the second form when you need to add additional HTML attributes
* @var boolean $selected Whether or not this option is selected
*/
public $selected = false;
+ /**
+ * @var mixed $label The label for that component. String or html_label object
+ */
+ public $label;
+
+ public function __construct() {
+ $this->label = new html_label();
+ }
/**
* @see moodle_html_component::prepare()
if (empty($this->text)) {
throw new coding_exception('html_select_option requires a $text value.');
}
+
+ if (empty($this->label->text)) {
+ $this->set_label($this->text);
+ } else if (!($this->label instanceof html_label)) {
+ $this->set_label($this->label);
+ }
+
parent::prepare();
}
}
$this->renderer = new moodle_core_renderer(new moodle_page);
}
- public function test_select_menu_simple() {
- $selectmenu = moodle_select_menu::make(array(10 => 'ten', 'c2' => 'two'), 'mymenu');
- $html = $this->renderer->select_menu($selectmenu);
+ public function test_select_simple() {
+ $select = moodle_select::make(array(10 => 'ten', 'c2' => 'two'), 'mymenu');
+ $html = $this->renderer->select($select);
$this->assert(new ContainsTagWithAttributes('select', array('class' => 'menumymenu select', 'name' => 'mymenu', 'id' => 'menumymenu')), $html);
$this->assert(new ContainsTagWithContents('option', 'ten'), $html);
$this->assert(new ContainsTagWithAttribute('option', 'value', '10'), $html);
$html = $this->renderer->htmllist($htmllist);
}
- public function test_moodle_select_menu() {
+ public function test_moodle_select() {
$options = array('var1' => 'value1', 'var2' => 'value2', 'var3' => 'value3');
- $selectmenu = moodle_select_menu::make($options, 'mymenu', 'var2');
- $html = $this->renderer->select_menu($selectmenu);
+ $select = moodle_select::make($options, 'mymenu', 'var2');
+ $html = $this->renderer->select($select);
$this->assert(new ContainsTagWithAttributes('select', array('name' => 'mymenu')), $html);
$this->assert(new ContainsTagWithAttributes('option', array('value' => 'var1'), array('selected' => 'selected')), $html);
$this->assert(new ContainsTagWithAttributes('option', array('value' => 'var2', 'selected' => 'selected')), $html);
$this->assert(new ContainsTagWithContents('option', 'value3'), $html);
$options = array('group1' => '--group1', 'var1' => 'value1', 'var2' => 'value2', 'group2' => '--', 'group2' => '--group2', 'var3' => 'value3', 'var4' => 'value4');
- $selectmenu = moodle_select_menu::make($options, 'mymenu', 'var2');
- $html = $this->renderer->select_menu($selectmenu);
+ $select = moodle_select::make($options, 'mymenu', 'var2');
+ $html = $this->renderer->select($select);
$this->assert(new ContainsTagWithAttributes('select', array('name' => 'mymenu')), $html);
$this->assert(new ContainsTagWithAttributes('optgroup', array('label' => 'group1')), $html);
$this->assert(new ContainsTagWithAttributes('optgroup', array('label' => 'group2')), $html);
*
* It can be used in moodle pages where config.php has been included without any further includes.
*
- * It is useful for manipulating urls with long lists of params.
- * One situation where it will be useful is a page which links to itself to perfrom various actions
+ * It is useful for manipulating urls with long lists of params.
+ * One situation where it will be useful is a page which links to itself to perfrom various actions
* and / or to process form data. A moodle_url object :
- * can be created for a page to refer to itself with all the proper get params being passed from page call to
- * page call and methods can be used to output a url including all the params, optionally adding and overriding
+ * can be created for a page to refer to itself with all the proper get params being passed from page call to
+ * page call and methods can be used to output a url including all the params, optionally adding and overriding
* params and can also be used to
* - output the url without any get params
- * - and output the params as hidden fields to be output within a form
+ * - and output the params as hidden fields to be output within a form
*
* One important usage note is that data passed to methods out, out_action, get_query_string and
- * hidden_params_out affect what is returned by the function and do not change the data stored in the object.
- * This is to help with typical usage of these objects where one object is used to output urls
- * in many places in a page.
+ * hidden_params_out affect what is returned by the function and do not change the data stored in the object.
+ * This is to help with typical usage of these objects where one object is used to output urls
+ * in many places in a page.
*
* @link http://docs.moodle.org/en/Development:lib/weblib.php_moodle_url See short write up here
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
protected $path = '';
protected $fragment = '';
/**
- * @var array
+ * @var array
* @access protected
*/
protected $params = array(); // Associative array of query string params
/**
- * Pass no arguments to create a url that refers to this page.
+ * Pass no arguments to create a url that refers to this page.
* Use empty string to create empty url.
*
* @global string
}
/**
- * Add an array of params to the params for this page.
+ * Add an array of params to the params for this page.
*
* The added params override existing ones if they have the same name.
*
}
/**
- * Remove all params if no arguments passed.
- * Remove selected params if arguments are passed.
+ * Remove all params if no arguments passed.
+ * Remove selected params if arguments are passed.
*
* Can be called as either remove_params('param1', 'param2')
* or remove_params(array('param1', 'param2')).
}
/**
- * Add a param to the params for this page.
+ * Add a param to the params for this page.
*
* The added param overrides existing one if theyhave the same name.
*
// Handle relative URLs
if (substr($output, 0, 4) != 'http' && substr($output, 0, 1) != '/') {
if (preg_match('/(.*)\/([A-Za-z0-9-_]*\.php)$/', $PAGE->url->out(true), $matches)) {
-
+
return $matches[1] . "/$output";
} else {
throw new coding_exception('Your page uses bizarre relative URLs which Moodle cannot handle. Please use absolute URLs.');
}
-/**
- * Given an array of values, creates a group of radio buttons to be part of a form
- *
- * @staticvar int $idcounter
- * @param array $options An array of value-label pairs for the radio group (values as keys)
- * @param string $name Name of the radiogroup (unique in the form)
- * @param string $checked The value that is already checked
- * @param bool $return Whether this function should return a string or output
- * it (defaults to false)
- * @return string|void If $return=true returns string, else echo's and returns void
- */
-function choose_from_radio ($options, $name, $checked='', $return=false) {
-
- static $idcounter = 0;
-
- if (!$name) {
- $name = 'unnamed';
- }
-
- $output = '<span class="radiogroup '.$name."\">\n";
-
- if (!empty($options)) {
- $currentradio = 0;
- foreach ($options as $value => $label) {
- $htmlid = 'auto-rb'.sprintf('%04d', ++$idcounter);
- $output .= ' <span class="radioelement '.$name.' rb'.$currentradio."\">";
- $output .= '<input name="'.$name.'" id="'.$htmlid.'" type="radio" value="'.$value.'"';
- if ($value == $checked) {
- $output .= ' checked="checked"';
- }
- if ($label === '') {
- $output .= ' /> <label for="'.$htmlid.'">'. $value .'</label></span>' . "\n";
- } else {
- $output .= ' /> <label for="'.$htmlid.'">'. $label .'</label></span>' . "\n";
- }
- $currentradio = ($currentradio + 1) % 2;
- }
- }
-
- $output .= '</span>' . "\n";
-
- if ($return) {
- return $output;
- } else {
- echo $output;
- }
-}
-
-/**
- * Display an standard html checkbox with an optional label
- *
- * @staticvar int $idcounter
- * @param string $name The name of the checkbox
- * @param string $value The valus that the checkbox will pass when checked
- * @param bool $checked The flag to tell the checkbox initial state
- * @param string $label The label to be showed near the checkbox
- * @param string $alt The info to be inserted in the alt tag
- * @param string $script If not '', then this is added to the checkbox element
- * as an onchange handler.
- * @param bool $return Whether this function should return a string or output
- * it (defaults to false)
- * @return string|void If $return=true returns string, else echo's and returns void
- */
-function print_checkbox ($name, $value, $checked = true, $label = '', $alt = '', $script='',$return=false) {
-
- static $idcounter = 0;
-
- if (!$name) {
- $name = 'unnamed';
- }
-
- if ($alt) {
- $alt = strip_tags($alt);
- } else {
- $alt = 'checkbox';
- }
-
- if ($checked) {
- $strchecked = ' checked="checked"';
- } else {
- $strchecked = '';
- }
-
- $htmlid = 'auto-cb'.sprintf('%04d', ++$idcounter);
- $output = '<span class="checkbox '.$name."\">";
- $output .= '<input name="'.$name.'" id="'.$htmlid.'" type="checkbox" value="'.$value.'" alt="'.$alt.'"'.$strchecked.' '.((!empty($script)) ? ' onclick="'.$script.'" ' : '').' />';
- if(!empty($label)) {
- $output .= ' <label for="'.$htmlid.'">'.$label.'</label>';
- }
- $output .= '</span>'."\n";
-
- if (empty($return)) {
- echo $output;
- } else {
- return $output;
- }
-
-}
-
/**
* Display an standard html text field with an optional label
*
* @param string $alt The info to be inserted in the alt tag
* @param int $size Sets the size attribute of the field. Defaults to 50
* @param int $maxlength Sets the maxlength attribute of the field. Not set by default
- * @param bool $return Whether this function should return a string or output
+ * @param bool $return Whether this function should return a string or output
* it (defaults to false)
* @return string|void If $return=true returns string, else echo's and returns void
*/
}
}
return $text.$cmt;
-
+
}
/**
* Converts the text format from the value to the 'internal'
- * name or vice versa.
+ * name or vice versa.
*
* $key can either be the value or the name and you get the other back.
*
remove_dir($purifdir, true);
}
-/**
+/**
* Given a simple string, this function returns the string
* processed by enabled string filters if $CFG->filterall is enabled
*
/**
* Given a string, replaces all <a>.*</a> by .* and returns the string.
- *
+ *
* @param string $string
* @return string
*/
/**
* Replaces non-standard HTML entities
- *
+ *
* @param string $string
* @return string
*/
function fix_non_standard_entities($string) {
$text = preg_replace('/(&#[0-9]+)(;?)/', '$1;', $string);
- $text = preg_replace('/(&#x[0-9a-fA-F]+)(;?)/', '$1;', $text);
+ $text = preg_replace('/(&#x[0-9a-fA-F]+)(;?)/', '$1;', $text);
return $text;
}
*/
function trusttext_pre_edit($object, $field, $context) {
$trustfield = $field.'trust';
- $formatfield = $field.'format';
-
+ $formatfield = $field.'format';
+
if (!$object->$trustfield or !trusttext_trusted($context)) {
$object->$field = clean_text($object->$field, $object->$formatfield);
}
* @return bool true if user trusted
*/
function trusttext_trusted($context) {
- return (trusttext_active() and has_capability('moodle/site:trustcontent', $context));
+ return (trusttext_active() and has_capability('moodle/site:trustcontent', $context));
}
/**
function trusttext_active() {
global $CFG;
- return !empty($CFG->enabletrusttext);
+ return !empty($CFG->enabletrusttext);
}
/**
/**
* Print (or return) a collapisble region, that has a caption that can
* be clicked to expand or collapse the region.
- *
+ *
* If JavaScript is off, then the region will always be exanded.
*
* @param string $contents the contents of the box.
* @uses SITEID
* @param object $user A {@link $USER} object representing a user
* @param object $course A {@link $COURSE} object representing a course
- * @param bool $messageselect
+ * @param bool $messageselect
* @param bool $return If set to true then the HTML is returned rather than echo'd
* @return string|void Depending on the setting of $return
*/
/**
* Display a recent activity note
- *
+ *
* @uses CONTEXT_SYSTEM
* @staticvar string $strftimerecent
* @param object A time object
*
* @global object
* @param int $courseid The course ID
- * @param string $name
- * @param string $current
+ * @param string $name
+ * @param string $current
* @param boolean $includenograde Include those with no grades
* @param boolean $return If set to true returns rather than echo's
* @return string|bool Depending on value of $return
* <strong>Good practice:</strong> You should call this method before starting page
* output by using any of the OUTPUT methods.
*
- * @param mixed $url either a string URL, or a moodle_url to redirect to
+ * @param moodle_url $url A moodle_url to redirect to. Strings are not to be trusted!
* @param string $message The message to display to the user
* @param int $delay The delay before redirecting
* @return void
if ($url instanceof moodle_url) {
$url = $url->out(false, array(), false);
+ } else {
+ debugging("String URLs are not safe in redirect(), please use a moodle_url object.", DEBUG_DEVELOPER);
}
if (!empty($CFG->usesid) && !isset($_COOKIE[session_name()])) {
/**
* Prints a maintenance message from $CFG->maintenance_message or default if empty
- * @return void
+ * @return void
*/
function print_maintenance_message() {
global $CFG, $SITE, $PAGE;
*/
var $linkedwhenselected;
- /**
+ /**
* A constructor just because I like constructors
- *
+ *
* @param string $id
* @param string $link
* @param string $text
* @param string $selected The tabrow to select (by id)
* @param array $inactive An array of tabrow id's to make inactive
* @param array $activated An array of tabrow id's to make active
- * @return array The nested array
+ * @return array The nested array
*/
function convert_tabrows_to_tree($tabrows, $selected, $inactive, $activated) {
}
/**
* Create a new progress bar, this function will output html.
- *
+ *
* @return void Echo's output
*/
function create(){
echo '<a href="javascript:select_all_in(\'DIV\',null,\'tablecontainer\');">'.get_string('selectall', 'quiz').'</a> / ';
echo '<a href="javascript:deselect_all_in(\'DIV\',null,\'tablecontainer\');">'.get_string('selectnone', 'quiz').'</a> ';
echo ' ';
- $selectmenu = new moodle_select_menu();
- $selectmenu->options = array('delete' => get_string('delete'));
- $selectmenu->name = 'action';
- $selectmenu->button->label = get_string('withselected', 'quiz');
- $selectmenu->id = 'menuaction';
- $selectmenu->add_action('change', 'submit_form_by_id', array('id' => 'attemptsform', 'selectid' => 'menuaction'));
- echo $OUTPUT->select_menu($selectmenu);
+ $select = new moodle_select();
+ $select->options = array('delete' => get_string('delete'));
+ $select->name = 'action';
+ $select->button->label = get_string('withselected', 'quiz');
+ $select->id = 'menuaction';
+ $select->add_action('change', 'submit_form_by_id', array('id' => 'attemptsform', 'selectid' => 'menuaction'));
+ echo $OUTPUT->select($select);
echo '<noscript id="noscriptmenuaction" style="display: inline;">';
echo '<div>';
echo '<input type="submit" value="'.get_string('go').'" /></div></noscript>';
if ($courses = $DB->get_records_sql_menu($sql, $params)) {
echo ' ' . get_string('filter_by_course', 'feedback') . ': ';
- $selectmenu = new moodle_select_menu();
- $selectmenu->options = $courses;
- $selectmenu->name = 'coursefilter';
- $selectmenu->selectedvalue = $coursefilter;
- $selectmenu->add_action('change', 'submit_form_by_id', array('id' => 'analysis-form'));
- echo $OUTPUT->select_menu($selectmenu);
+ $select = new moodle_select();
+ $select->options = $courses;
+ $select->name = 'coursefilter';
+ $select->selectedvalue = $coursefilter;
+ $select->add_action('change', 'submit_form_by_id', array('id' => 'analysis-form'));
+ echo $OUTPUT->select($select);
}
echo '<hr />';
$itemnr = 0;
'<a href="javascript: checkall();">'.get_string('selectall').'</a> / '.
'<a href="javascript: checknone();">'.get_string('deselectall').'</a> ';
- $selectmenu = new moodle_select_menu();
- $selectmenu->options = array('delete' => get_string('deleteselected'));
- $selectmenu->name = 'attemptaction';
- $selectmenu->selectedvalue = 0;
- $selectmenu->add_action('change', 'submit_form_by_id', array('id' => 'theform'));
- echo $OUTPUT->select_menu($selectmenu);
+ $select = new moodle_select();
+ $select->options = array('delete' => get_string('deleteselected'));
+ $select->name = 'attemptaction';
+ $select->selectedvalue = 0;
+ $select->add_action('change', 'submit_form_by_id', array('id' => 'theform'));
+ echo $OUTPUT->select($select);
echo '</td></tr></table></form>';
}
<?php print_string('organizations','scorm') ?>
<form id='changeorg' method='post' action='<?php echo $action ?>'>
<?php
- $selectmenu = new moodle_select_menu();
- $selectmenu->options = $orgs;
- $selectmenu->name = 'organization';
- $selectmenu->selectedvalue = $organization;
- $selectmenu->add_action('change', 'submit_form_by_id', array('id' => 'changeorg'));
- echo $OUTPUT->select_menu($selectmenu);
+ $select = new moodle_select();
+ $select->options = $orgs;
+ $select->name = 'organization';
+ $select->selectedvalue = $organization;
+ $select->add_action('change', 'submit_form_by_id', array('id' => 'changeorg'));
+ echo $OUTPUT->select($select);
?>
</form>
</div>
echo '<a href="javascript:select_all_in(\'DIV\',null,\'scormtablecontainer\');">'.get_string('selectall', 'quiz').'</a> / ';
echo '<a href="javascript:deselect_all_in(\'DIV\',null,\'scormtablecontainer\');">'.get_string('selectnone', 'quiz').'</a> ';
echo ' ';
- $selectmenu = new moodle_select_menu();
- $selectmenu->options = array('delete' => get_string('delete'));
- $selectmenu->name = 'action';
- $selectmenu->button->label = get_string('withselected', 'quiz');
- $selectmenu->id = 'menuaction';
- $selectmenu->add_action('change', 'submit_form_by_id', array('id' => 'attemptsform', 'selectid' => 'menuaction'));
- echo $OUTPUT->select_menu($selectmenu);
+ $select = new moodle_select();
+ $select->options = array('delete' => get_string('delete'));
+ $select->name = 'action';
+ $select->button->label = get_string('withselected', 'quiz');
+ $select->id = 'menuaction';
+ $select->add_action('change', 'submit_form_by_id', array('id' => 'attemptsform', 'selectid' => 'menuaction'));
+ echo $OUTPUT->select($select);
echo '<noscript id="noscriptmenuaction" style="display: inline;">';
echo '<div>';
echo '<input type="submit" value="'.get_string('go').'" /></div></noscript>';
while(list($key,$val)=each($wiki_list)) {
$wiki_admin_list[$key."&action=$action"]=$val;
}
- $selectmenu = new moodle_select_menu();
- $selectmenu->options = $wiki_admin_list;
- $selectmenu->name = 'wikiselect';
- $selectmenu->selectedvalue = $selected;
- $selectmenu->add_action('change', 'go_to_wiki');
- echo $OUTPUT->select_menu($selectmenu);
+ $select = new moodle_select();
+ $select->options = $wiki_admin_list;
+ $select->name = 'wikiselect';
+ $select->selectedvalue = $selected;
+ $select->add_action('change', 'go_to_wiki');
+ echo $OUTPUT->select($select);
echo '</td>';
echo '</tr></table>';
echo '</fieldset></form>';
echo '<td class="sideblockheading">'
.get_string('otherwikis', 'wiki').': ';
- $selectmenu = new moodle_select_menu();
- $selectmenu->options = $wiki_list;
- $selectmenu->name = 'wikiselect';
- $selectmenu->selectedvalue = $selected;
- $selectmenu->add_action('change', 'go_to_wiki');
- echo $OUTPUT->select_menu($selectmenu);
+ $select = new moodle_select();
+ $select->options = $wiki_list;
+ $select->name = 'wikiselect';
+ $select->selectedvalue = $selected;
+ $select->add_action('change', 'go_to_wiki');
+ echo $OUTPUT->select($select);
echo '</td>';
echo '</tr></table>';
echo '</form>';
}
helpbutton("participantswithselectedusers", get_string("withselectedusers"));
- $selectmenu = new moodle_select_menu();
- $selectmenu->options = $displaylist;
- $selectmenu->name = "formaction";
- $selectmenu->label = get_string("withselectedusers");
- $selectmenu->add_action('change', 'conditionalsubmit', array('formid' => 'participantsform'));
- echo $OUTPUT->select_menu($selectmenu);
+ $select = new moodle_select();
+ $select->options = $displaylist;
+ $select->name = "formaction";
+ $select->label = get_string("withselectedusers");
+ $select->add_action('change', 'conditionalsubmit', array('formid' => 'participantsform'));
+ echo $OUTPUT->select($select);
echo '<input type="hidden" name="id" value="'.$course->id.'" />';
echo '<div id="noscriptparticipantsform" style="display: inline;">';
echo '<input type="submit" value="'.get_string('ok').'" /></div>';