MDL-19756 Renamed moodle_select to html_select for better API consistency

This commit is contained in:
nicolasconnault
2009-08-10 08:38:45 +00:00
parent 8c61317a4c
commit 7b1f2c829f
62 changed files with 571 additions and 571 deletions
+1 -1
View File
@@ -121,7 +121,7 @@
/// Print form and popup menu
echo '<div style="text-align:center">'.$strmoodleversion.' ';
$select = moodle_select::make_popup_form("$CFG->wwwroot/$CFG->admin/environment.php", 'version', $versions, 'selectversion', $version);
$select = html_select::make_popup_form("$CFG->wwwroot/$CFG->admin/environment.php", 'version', $versions, 'selectversion', $version);
$select->nothinglabel = false;
echo $OUTPUT->select($select);
echo '</div>';
+2 -2
View File
@@ -248,7 +248,7 @@ function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings)
}
// Disable/off/on
$select = moodle_select::make_popup_form(action_url($filter, 'setstate'), 'newstate', $activechoices, 'active' . basename($filter), $filterinfo->active);
$select = html_select::make_popup_form(action_url($filter, 'setstate'), 'newstate', $activechoices, 'active' . basename($filter), $filterinfo->active);
$select->nothinglabel = false;
$select->form->button->text = get_string('save', 'admin');
$row[] = $OUTPUT->select($select);
@@ -271,7 +271,7 @@ function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings)
$row[] = $updown;
// Apply to strings.
$select = moodle_select::make_popup_form(action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, 'applyto' . basename($filter), $applytostrings);
$select = html_select::make_popup_form(action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, 'applyto' . basename($filter), $applytostrings);
$select->nothinglabel = false;
$select->disabled = $filterinfo->active == TEXTFILTER_DISABLED;
$select->form->button->text = get_string('save', 'admin');
+3 -3
View File
@@ -140,7 +140,7 @@
echo $OUTPUT->box_start();
$currlang = current_language();
$langs = get_list_of_languages(false, true);
$select = moodle_select::make_popup_form("$CFG->wwwroot/$CFG->admin/lang.php", 'lang', $langs, "chooselang", $currlang);
$select = html_select::make_popup_form("$CFG->wwwroot/$CFG->admin/lang.php", 'lang', $langs, "chooselang", $currlang);
$select->nothinglabel = false;
$select->set_label($strcurrentlanguage.':');
echo $OUTPUT->select($select);
@@ -494,7 +494,7 @@
//$selectionlabel .= $strfilestoredin;
$selectionlabel .= $uselocal ? "{$currentlang}_local" : $currentlang;
$selectionlabel .= '/</code>';
$select = moodle_select::make_popup_form("$CFG->wwwroot/$CFG->admin/lang.php?mode=compare", 'currentfile', $menufiles, "choosefile", $currentfile);
$select = html_select::make_popup_form("$CFG->wwwroot/$CFG->admin/lang.php?mode=compare", 'currentfile', $menufiles, "choosefile", $currentfile);
$select->nothinglabel = $strchoosefiletoedit;
$select->set_label($selectionlabel);
echo $OUTPUT->select($select);
@@ -761,7 +761,7 @@
//$selectionlabel .= $strfilestoredin;
$selectionlabel .= $uselocal ? "{$currentlang}_local" : $currentlang;
$selectionlabel .= '/help/</code>';
$select = moodle_select::make_popup_form("$CFG->wwwroot/$CFG->admin/lang.php?mode=helpfiles", 'currentfile', $menufiles, "choosefile", $currentfile);
$select = html_select::make_popup_form("$CFG->wwwroot/$CFG->admin/lang.php?mode=helpfiles", 'currentfile', $menufiles, "choosefile", $currentfile);
$select->nothinglabel = $strchoosefiletoedit;
$select->set_label($selectionlabel);
echo $OUTPUT->select($select);
+1 -1
View File
@@ -373,7 +373,7 @@
/// Print a form to swap roles, and a link back to the all roles list.
echo '<div class="backlink">';
$select = moodle_select::make_popup_form($baseurl, 'roleid', $nameswithcounts, 'switchrole', $roleid);
$select = html_select::make_popup_form($baseurl, 'roleid', $nameswithcounts, 'switchrole', $roleid);
$select->set_label(get_string('assignanotherrole', 'role'));
$select->nothinglabel = false;
echo $OUTPUT->select($select);
+1 -1
View File
@@ -231,7 +231,7 @@
/// Print a form to swap roles, and a link back to the all roles list.
echo '<div class="backlink">';
$select = moodle_select::make_popup_form($baseurl, 'roleid', $nameswithcounts, 'switchrole', $roleid);
$select = html_select::make_popup_form($baseurl, 'roleid', $nameswithcounts, 'switchrole', $roleid);
$select->set_label(get_string('overrideanotherrole', 'role'));
$select->nothinglabel = false;
echo $OUTPUT->select($select);
+1 -1
View File
@@ -28,7 +28,7 @@ httpsrequired();
} else {
$currlang = current_language();
$langs = get_list_of_languages();
$select = moodle_select::make_popup_form("$CFG->httpswwwroot/login/index.php", 'lang', $langs, 'chooselang', $currlang);
$select = html_select::make_popup_form("$CFG->httpswwwroot/login/index.php", 'lang', $langs, 'chooselang', $currlang);
$select->nothinglabel = false;
$select->set_label(get_accesshide(get_string('language')));
$langmenu = $OUTPUT->select($select);
+3 -3
View File
@@ -284,9 +284,9 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
/// (some formats like main page, social..., haven't it and rolling dates
/// from 0 produces crazy dates. MDL-10125
if ($form1->startdate) {
$dayselector = moodle_select::make_time_selector('days', "startday", $form1->startdate);
$monthselector = moodle_select::make_time_selector('months', "startmonth", $form1->startdate);
$yearselector = moodle_select::make_time_selector('years', "startyear", $form1->startdate);
$dayselector = html_select::make_time_selector('days', "startday", $form1->startdate);
$monthselector = html_select::make_time_selector('months', "startmonth", $form1->startdate);
$yearselector = html_select::make_time_selector('years', "startyear", $form1->startdate);
echo $OUTPUT->select($dayselector) . $OUTPUT->select($monthselector) . $OUTPUT->select($yearselector);
helpbutton("coursestartdate", get_string("startdate"));
+1 -1
View File
@@ -133,7 +133,7 @@ foreach($feeds as $feed) {
$deleteaction->link->title = get_string('delete');
$deleteaction->image->src = $OUTPUT->old_icon_url('t/delete');
$deleteaction->image->alt = get_string('delete');
$deleteaction->link->add_action('click', 'confirm_dialog', array('message' => get_string('deletefeedconfirm', 'block_rss_client')));
$deleteaction->link->add_confirm_action(get_string('deletefeedconfirm', 'block_rss_client'));
$feedicons = $OUTPUT->action_icon($editaction) . ' ' . $OUTPUT->action_icon($deleteaction);
+2 -2
View File
@@ -1,12 +1,12 @@
<?php
$startselectors = moodle_select::make_time_selectors(array(
$startselectors = html_select::make_time_selectors(array(
'days' => 'startday',
'months' => 'startmon',
'years' => 'startyr',
'hours' => 'starthr',
'minutes' => 'startmin'), $form->timestart);
$endselectors = moodle_select::make_time_selectors(array(
$endselectors = html_select::make_time_selectors(array(
'days' => 'endday',
'months' => 'endmon',
'years' => 'endyr',
+2 -2
View File
@@ -1,14 +1,14 @@
<?php
// The following is a hack to fix bug 1488
$course = $DB->get_record('course', array('id'=>($form->courseid ? $form->courseid : $site->id)));
$startselectors = moodle_select::make_time_selectors(array(
$startselectors = html_select::make_time_selectors(array(
'days' => 'startday',
'months' => 'startmon',
'years' => 'startyr',
'hours' => 'starthr',
'minutes' => 'startmin'), (int) $form->timestart);
$endselectors = moodle_select::make_time_selectors(array(
$endselectors = html_select::make_time_selectors(array(
'days' => 'endday',
'months' => 'endmon',
'years' => 'endyr',
+1 -1
View File
@@ -625,7 +625,7 @@ function calendar_course_filter_selector($getvars = '') {
} else {
$selected = '';
}
$select = moodle_select::make_popup_form(CALENDAR_URL.'set.php?var=setcourse&'.$getvars, 'id', $courseoptions, 'cal_courses_flt', $selected);
$select = html_select::make_popup_form(CALENDAR_URL.'set.php?var=setcourse&'.$getvars, 'id', $courseoptions, 'cal_courses_flt', $selected);
$select->nothinglabel = false;
return $OUTPUT->select($select);
}
+2 -2
View File
@@ -171,7 +171,7 @@
make_categories_list($displaylist, $notused);
echo '<div class="categorypicker">';
$select = moodle_select::make_popup_form('category.php', 'id', $displaylist, 'switchcategory', $category->id);
$select = html_select::make_popup_form('category.php', 'id', $displaylist, 'switchcategory', $category->id);
$select->set_label($strcategories.':');
$select->nothinglabel = false;
echo $OUTPUT->select($select);
@@ -410,7 +410,7 @@
make_categories_list($movetocategories, $notused, 'moodle/category:manage');
$movetocategories[$category->id] = get_string('moveselectedcoursesto');
echo '<tr><td colspan="3" align="right">';
$select = new moodle_select();
$select = new html_select();
$select->options = $movetocategories;
$select->name = 'moveto';
$select->selectedvalue = $category->id;
+1 -1
View File
@@ -253,7 +253,7 @@
if (!empty($sectionmenu)) {
echo '<div class="jumpmenu">';
$popupurl = $CFG->wwwroot.'/course/view.php?id='.$course->id;
$select = moodle_select::make_popup_form($popupurl, 'topic', $sectionmenu, 'sectionmenu');
$select = html_select::make_popup_form($popupurl, 'topic', $sectionmenu, 'sectionmenu');
$select->set_label(get_string('jumpto'));
echo $OUTPUT->select($select);
echo '</div>';
+1 -1
View File
@@ -245,7 +245,7 @@
if (!empty($sectionmenu)) {
echo '<div class="jumpmenu">';
$popupurl = $CFG->wwwroot.'/course/view.php?id='.$course->id;
$select = moodle_select::make_popup_form($popupurl, 'week', $sectionmenu, 'sectionmenu');
$select = html_select::make_popup_form($popupurl, 'week', $sectionmenu, 'sectionmenu');
$select->set_label(get_string('jumpto'));
echo $OUTPUT->select($select);
echo '</div>';
+1 -1
View File
@@ -337,7 +337,7 @@ function print_category_edit($category, $displaylist, $parentslist, $depth=-1, $
}
}
$popupurl = "index.php?move=$category->id&sesskey=".sesskey();
$select = moodle_select::make_popup_form($popupurl, 'moveto', $tempdisplaylist, "moveform$category->id", $category->parent);
$select = html_select::make_popup_form($popupurl, 'moveto', $tempdisplaylist, "moveform$category->id", $category->parent);
$select->nothinglabel = false;
echo $OUTPUT->select($select);
}
+2 -2
View File
@@ -1605,14 +1605,14 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
$popupurl = "$CFG->wwwroot/course/mod.php?id=$course->id&section=$section&sesskey=".sesskey();
if (!empty($resources)) {
$select = moodle_select::make_popup_form($popupurl, 'add', $resources, "ressection$section", null);
$select = html_select::make_popup_form($popupurl, 'add', $resources, "ressection$section", null);
$select->nothinglabel = $straddresource;
$select->set_help_icon('resource/types', $straddresource);
$output .= $OUTPUT->select($select);
}
if (!empty($activities)) {
$select = moodle_select::make_popup_form($popupurl, 'add', $activities, "section$section", null);
$select = html_select::make_popup_form($popupurl, 'add', $activities, "section$section", null);
$select->nothinglabel = $straddactivity;
$select->set_help_icon('mods', $straddactivity);
$output .= $OUTPUT->select($select);
+1 -1
View File
@@ -221,7 +221,7 @@ function print_mnet_log_selector_form($hostid, $course, $selecteduser=0, $select
echo "<input type=\"hidden\" name=\"showcourses\" value=\"$showcourses\" />\n";
if (has_capability('coursereport/log:view', $sitecontext) && $showcourses) {
$cid = empty($course->id)? '1' : $course->id;
$select = moodle_select::make($dropdown, "host_course", $hostid.'/'.$cid);
$select = html_select::make($dropdown, "host_course", $hostid.'/'.$cid);
$select->nested = true;
echo $OUTPUT->select($select);
} else {
+2 -2
View File
@@ -117,7 +117,7 @@
echo '<form class="participationselectform" action="index.php" method="get"><div>'."\n".
'<input type="hidden" name="id" value="'.$course->id.'" />'."\n";
echo '<label for="menuinstanceid">'.get_string('activitymodule').'</label>'."\n";
$select = moodle_select::make($instanceoptions, 'instanceid', $instanceid);
$select = html_select::make($instanceoptions, 'instanceid', $instanceid);
$select->nested = true;
echo $OUTPUT->select($select);
echo '<label for="menutimefrom">'.get_string('lookback').'</label>'."\n";
@@ -275,7 +275,7 @@
echo '<input type="button" onclick="checknos()" value="'.get_string('selectnos').'" />'."\n";
}
$displaylist['messageselect.php'] = get_string('messageselectadd');
$select = new moodle_select();
$select = new html_select();
$select->options = $displaylist;
$select->name = "formaction";
$select->label = get_string("withselectedusers");
+1 -1
View File
@@ -24,7 +24,7 @@
$options[STATS_MODE_RANKED] = get_string('reports');
}
$popupurl = $url."?course=$course->id&time=$time";
$select = moodle_select::make_popup_form($popupurl, 'mode', $options, 'switchmode', $mode);
$select = html_select::make_popup_form($popupurl, 'mode', $options, 'switchmode', $mode);
$select->nothinglabel = false;
return $OUTPUT->select($select);
}
+1 -1
View File
@@ -334,7 +334,7 @@
echo "<br />";
echo "<input type=\"button\" onclick=\"checkall()\" value=\"$strselectall\" />\n";
echo "<input type=\"button\" onclick=\"checknone()\" value=\"$strdeselectall\" />\n";
$select = new moodle_select();
$select = new html_select();
$select->options = $displaylist;
$select->name = "moveto";
$select->label = get_string("moveselectedcoursesto");
+2 -2
View File
@@ -110,8 +110,8 @@ if (!isset($frm->acceptechecktypes)) {
<td align="right">an_cutoff:</td>
<td><?php
$curtime = make_timestamp(2000,1,1,$frm->an_cutoff_hour,$frm->an_cutoff_min);
$hourselector = moodle_select::make_time_selector('hours', 'an_cutoff_hour', $curtime);
$minselector = moodle_select::make_time_selector('minutes', 'an_cutoff_min', $curtime);
$hourselector = html_select::make_time_selector('hours', 'an_cutoff_hour', $curtime);
$minselector = html_select::make_time_selector('minutes', 'an_cutoff_min', $curtime);
echo $OUTPUT->select($hourselector) . $OUTPUT->select($minselector);
?><br />
<?php print_string("cutofftime", "enrol_authorize") ?></td>
+3 -3
View File
@@ -50,7 +50,7 @@ function authorize_print_orders($courseid, $userid) {
if (($popupcrs = $DB->get_records_sql_menu($sql, $params))) {
$popupcrs = array($SITE->id => $SITE->fullname) + $popupcrs;
}
$popupmenu = empty($popupcrs) ? '' : $OUTPUT->select(moodle_select::make_popup_form($baseurl.'&status='.$status, 'course', $popupcrs, 'coursesmenu', $courseid));
$popupmenu = empty($popupcrs) ? '' : $OUTPUT->select(html_select::make_popup_form($baseurl.'&status='.$status, 'course', $popupcrs, 'coursesmenu', $courseid));
$popupmenu .= '<br />';
$statusmenu = array(
AN_STATUS_NONE => $strs->all,
@@ -66,7 +66,7 @@ function authorize_print_orders($courseid, $userid) {
AN_STATUS_TEST => $authstrs->tested
);
$popupmenu .= $OUTPUT->select(moodle_select::make_popup_form($baseurl.'&course='.$courseid, 'status', $statusmenu, 'statusmenu', $status));
$popupmenu .= $OUTPUT->select(html_select::make_popup_form($baseurl.'&course='.$courseid, 'status', $statusmenu, 'statusmenu', $status));
if ($canmanagepayments) {
$popupmenu .= '<br />';
$checkbox = html_select_option::make_checkbox(1, $userid == $USER->id, get_string('mypaymentsonly', 'enrol_authorize'));
@@ -92,7 +92,7 @@ function authorize_print_orders($courseid, $userid) {
if ($perpage > 100) { $perpage = 100; }
$perpagemenus = array(5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100);
$perpagemenu = $OUTPUT->select(moodle_select::make_popup_form($baseurl.'&status='.$status.'&course='.$courseid, 'perpage',$perpagemenus,'perpagemenu',$perpage));
$perpagemenu = $OUTPUT->select(html_select::make_popup_form($baseurl.'&status='.$status.'&course='.$courseid, 'perpage',$perpagemenus,'perpagemenu',$perpage));
$table->define_columns(array('id', 'userid', 'timecreated', 'status', 'action'));
$table->define_headers(array($authstrs->orderid, $authstrs->shopper, $strs->time, $strs->status, $perpagemenu));
$table->define_baseurl($baseurl."&amp;status=$status&amp;course=$courseid&amp;perpage=$perpage");
+1 -1
View File
@@ -8,7 +8,7 @@ $servercount = 0;
if (is_array($mnethosts)) {
$servercount = count(array_keys($mnethosts));
}
$select = moodle_select::make_yes_no('enrol_mnet_allow_allcourses', $frm->enrol_mnet_allow_allcourses);
$select = html_select::make_yes_no('enrol_mnet_allow_allcourses', $frm->enrol_mnet_allow_allcourses);
?>
<table cellspacing="0" cellpadding="5" border="0" class="boxaligncenter">
+1 -1
View File
@@ -309,7 +309,7 @@ if (!$moving && count($categories) > 1) {
echo '<br /><br />';
echo '<input type="hidden" name="bulkmove" value="0" id="bulkmoveinput" />';
echo get_string('moveselectedto', 'grades') . ' ';
$select = new moodle_select();
$select = new html_select();
$select->options = $categories;
$select->name = 'moveafter';
$select->disabled = true;
+1 -1
View File
@@ -564,7 +564,7 @@ class grade_edit_tree_column_aggregation extends grade_edit_tree_column_category
}
}
$select = new moodle_select();
$select = new html_select();
$select->options = $options;
$select->name = 'aggregation_'.$category->id;
$select->selectedvalue = $category->aggregation;
+2 -2
View File
@@ -320,7 +320,7 @@ function print_graded_users_selector($course, $actionpage, $userid=0, $groupid=0
if ($includeall) {
$menu[0] .= " (" . (count($menu) - 1) . ")";
}
$select = moodle_select::make_popup_form($CFG->wwwroot.'/grade/' . $actionpage, 'userid', $menu, 'choosegradeuser', $userid);
$select = html_select::make_popup_form($CFG->wwwroot.'/grade/' . $actionpage, 'userid', $menu, 'choosegradeuser', $userid);
$select->set_label($label);
return $OUTPUT->select($select);
}
@@ -359,7 +359,7 @@ function print_grade_plugin_selector($plugin_info, $return=false) {
// finally print/return the popup form
if ($count > 1) {
$select = moodle_select::make_popup_form('', '', $menu, 'choosepluginreport', '');
$select = html_select::make_popup_form('', '', $menu, 'choosepluginreport', '');
$select->override_option_values($menu);
if ($return) {
+2 -2
View File
@@ -130,7 +130,7 @@ if (!empty($CFG->enablegroupings)) {
$options[$grouping->id] = strip_tags(format_string($grouping->name));
}
$popupurl = $rooturl.'&group='.$groupid;
$select = moodle_select::make_popup_form($popupurl, 'grouping', $options, 'selectgrouping', $groupingid);
$select = html_select::make_popup_form($popupurl, 'grouping', $options, 'selectgrouping', $groupingid);
$select->set_label($strgrouping);
echo $OUTPUT->select($select);
}
@@ -141,7 +141,7 @@ foreach ($groups as $group) {
$options[$group->id] = strip_tags(format_string($group->name));
}
$popupurl = $rooturl.'&grouping='.$groupingid;
$select = moodle_select::make_popup_form($popupurl, 'group', $options, 'selectgroup', $groupid);
$select = html_select::make_popup_form($popupurl, 'group', $options, 'selectgroup', $groupid);
$select->set_label($strgroup);
echo $OUTPUT->select($select);
+1 -1
View File
@@ -75,7 +75,7 @@
$currlang = current_language();
$langs = get_list_of_languages();
$select = moodle_select::make_popup_form($CFG->wwwroot .'/index.php', 'lang', $langs, 'chooselang', $currlang);
$select = html_select::make_popup_form($CFG->wwwroot .'/index.php', 'lang', $langs, 'chooselang', $currlang);
$select->nothinglabel = false;
$select->set_label(get_accesshide(get_string('language')));
$langmenu = $OUTPUT->select($select);
+1 -1
View File
@@ -1362,7 +1362,7 @@ function block_add_block_ui($page, $output) {
asort($menu, SORT_LOCALE_STRING);
$actionurl = $page->url->out_action();
$select = moodle_select::make_popup_form($actionurl, 'bui_addblock', $menu, 'add_block');
$select = html_select::make_popup_form($actionurl, 'bui_addblock', $menu, 'add_block');
$select->nothinglabel = get_string('adddots');
$bc->content = $OUTPUT->select($select);
+10 -10
View File
@@ -3025,7 +3025,7 @@ function choose_from_menu ($options, $name, $selected='', $nothing='choose', $sc
if ($script) {
debugging('The $script parameter has been deprecated. You must use component_actions instead', DEBUG_DEVELOPER);
}
$select = moodle_select::make($options, $name, $selected);
$select = html_select::make($options, $name, $selected);
$select->nothinglabel = $nothing;
$select->nothingvalue = $nothingvalue;
$select->disabled = $disabled;
@@ -3073,7 +3073,7 @@ function choose_from_menu_yesno($name, $selected, $script = '', $return = false,
debugging('The $script parameter has been deprecated. You must use component_actions instead', DEBUG_DEVELOPER);
}
$select = moodle_select::make_yes_no($name, $selected);
$select = html_select::make_yes_no($name, $selected);
$select->disabled = $disabled;
$select->tabindex = $tabindex;
$output = $OUTPUT->select($select);
@@ -3119,7 +3119,7 @@ function choose_from_menu_nested($options,$name,$selected='',$nothing='choose',$
if ($script) {
debugging('The $script parameter has been deprecated. You must use component_actions instead', DEBUG_DEVELOPER);
}
$select = moodle_select::make($options, $name, $selected);
$select = html_select::make($options, $name, $selected);
$select->tabindex = $tabindex;
$select->disabled = $disabled;
$select->nothingvalue = $nothingvalue;
@@ -3197,8 +3197,8 @@ function print_timer_selector($timelimit = 0, $unit = '', $name = 'timelimit', $
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($timeselector).');
global $OUTPUT;
$hourselector = moodle_select::make_time_selector('hours', $hour, $currenttime);
$minuteselector = moodle_select::make_time_selector('minutes', $minute, $currenttime, $step);
$hourselector = html_select::make_time_selector('hours', $hour, $currenttime);
$minuteselector = html_select::make_time_selector('minutes', $minute, $currenttime, $step);
$output = $OUTPUT->select($hourselector) . $OUTPUT->select($minuteselector);
@@ -3226,9 +3226,9 @@ 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($dateselector).');
global $OUTPUT;
$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);
$dayselector = html_select::make_time_selector('days', $day, $currenttime);
$monthselector = html_select::make_time_selector('months', $month, $currenttime);
$yearselector = html_select::make_time_selector('years', $year, $currenttime);
$output = $OUTPUT->select($dayselector) . $OUTPUT->select($monthselector) . $OUTPUT->select($yearselector);
@@ -3284,7 +3284,7 @@ function popup_form($baseurl, $options, $formid, $selected='', $nothing='choose'
}
$baseurl = new moodle_url($baseurl);
$select = moodle_select::make_popup_form($baseurl, $name, $options, $formid, $selected);
$select = html_select::make_popup_form($baseurl, $name, $options, $formid, $selected);
$select->disabled = $disabled;
if (!empty($submitvalue)) {
@@ -3356,7 +3356,7 @@ 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 = html_select::make($options, $name, $checked);
$select->rendertype = 'radio';
$output = $OUTPUT->select($select);
+2 -2
View File
@@ -480,7 +480,7 @@ function groups_print_course_menu($course, $urlroot, $return=false) {
$groupname = reset($groupsmenu);
$output = $grouplabel.': '.$groupname;
} else {
$select = moodle_select::make_popup_form($urlroot, 'group', $groupsmenu, 'selectgroup', $activegroup);
$select = html_select::make_popup_form($urlroot, 'group', $groupsmenu, 'selectgroup', $activegroup);
$select->nothinglabel = false;
$select->set_label($grouplabel);
$output = $OUTPUT->select($select);
@@ -588,7 +588,7 @@ function groups_print_activity_menu($cm, $urlroot, $return=false, $hideallpartic
$groupname = reset($groupsmenu);
$output = $grouplabel.': '.$groupname;
} else {
$select = moodle_select::make_popup_form($urlroot, 'group', $groupsmenu, 'selectgroup', $activegroup);
$select = html_select::make_popup_form($urlroot, 'group', $groupsmenu, 'selectgroup', $activegroup);
$select->nothinglabel = false;
$select->set_label($grouplabel);
$output = $OUTPUT->select($select);
+2 -2
View File
@@ -210,9 +210,9 @@ function lockoptionsallsetup(formid) {
* 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 component with this function:
* Example usage of the html_select component with this function:
* <pre>
* $select = new moodle_select();
* $select = new html_select();
* $select->options = array('delete' => get_string('delete'));
* $select->name = 'action';
* $select->button->label = get_string('withselected', 'quiz');
+463 -463
View File
@@ -27,7 +27,7 @@
*/
/**
* Base class for classes representing HTML elements, like moodle_select.
* Base class for classes representing HTML elements, like html_select.
*
* Handles the id and class attributes.
*
@@ -263,6 +263,468 @@ class html_label extends moodle_html_component {
}
}
/**
* This class hold all the information required to describe a <select> menu that
* 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
* needs a bit more setting up than for a simple menu. See the shortcut methods for
* developer-friendly usage.
*
* All the fields that are not set by the constructor have sensible defaults, so
* you only need to set the properties where you want non-default behaviour.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
*/
class html_select extends moodle_html_component {
/**
* The html_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 $options;
/**
* @var string $name the name of this form control. That is, the name of the GET/POST
* variable that will be set if this select is submitted as part of a form.
*/
public $name;
/**
* @var mixed $label The label for that component. String or html_label object
*/
public $label;
/**
* @var string $selectedvalue the option to select initially. Should match one
* of the $options array keys. Default none.
*/
public $selectedvalue;
/**
* 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;
/**
* @var string The value returned by the 'nothing is selected' option. Defaults to 0.
*/
public $nothingvalue = 0;
/**
* @var boolean set this to true if you want the control to appear disabled.
*/
public $disabled = false;
/**
* @var integer if non-zero, sets the tabindex attribute on the <select> element. Default 0.
*/
public $tabindex = 0;
/**
* @var mixed Defaults to false, which means display the select as a dropdown menu.
* If true, display this select as a list box whose size is chosen automatically.
* If an integer, display as list box of that size.
*/
public $listbox = false;
/**
* @var integer if you are using $listbox === true to get an automatically
* sized list box, the size of the list box will be the number of options,
* or this number, whichever is smaller.
*/
public $maxautosize = 10;
/**
* @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;
/**
* Another way to use nested menu is to prefix optgroup labels with -- and end the optgroup with --
* Leave this setting to false if you are using the latter method.
* @var boolean $nested if true, uses $options' keys as option headings (optgroup)
*/
public $nested = false;
/**
* @var html_form $form An optional html_form component
*/
public $form;
/**
* @var moodle_help_icon $form An optional moodle_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()
* @return void
*/
public function prepare() {
global $CFG;
// name may contain [], which would make an invalid id. e.g. numeric question type editing form, assignment quickgrading
if (empty($this->id)) {
$this->id = 'menu' . str_replace(array('[', ']'), '', $this->name);
}
if (empty($this->classes)) {
$this->set_classes(array('menu' . str_replace(array('[', ']'), '', $this->name)));
}
if (is_null($this->nothinglabel)) {
$this->nothinglabel = get_string('choosedots');
}
if (!empty($this->label) && !($this->label instanceof html_label)) {
$label = new html_label();
$label->text = $this->label;
$label->for = $this->name;
$this->label = $label;
}
$this->add_class('select');
$this->initialise_options();
parent::prepare();
}
/**
* This is a shortcut for making a simple select menu. It lets you specify
* the options, name and selected option in one line of code.
* @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 html_select A html_select object with the three common fields initialised.
*/
public static function make($options, $name, $selected = '') {
$menu = new html_select();
$menu->options = $options;
$menu->name = $name;
$menu->selectedvalue = $selected;
return $menu;
}
/**
* 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 html_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);
}
/**
* This is a shortcut for making an hour selector menu.
* @param string $type The type of selector (years, months, days, hours, minutes)
* @param string $name fieldname
* @param int $currenttime A default timestamp in GMT
* @param int $step minute spacing
* @return html_select A menu initialised with hour options.
*/
public static function make_time_selector($type, $name, $currenttime=0, $step=5) {
if (!$currenttime) {
$currenttime = time();
}
$currentdate = usergetdate($currenttime);
$userdatetype = $type;
switch ($type) {
case 'years':
for ($i=1970; $i<=2020; $i++) {
$timeunits[$i] = $i;
}
$userdatetype = 'year';
break;
case 'months':
for ($i=1; $i<=12; $i++) {
$timeunits[$i] = userdate(gmmktime(12,0,0,$i,15,2000), "%B");
}
$userdatetype = 'month';
break;
case 'days':
for ($i=1; $i<=31; $i++) {
$timeunits[$i] = $i;
}
$userdatetype = 'mday';
break;
case 'hours':
for ($i=0; $i<=23; $i++) {
$timeunits[$i] = sprintf("%02d",$i);
}
break;
case 'minutes':
if ($step != 1) {
$currentdate['minutes'] = ceil($currentdate['minutes']/$step)*$step;
}
for ($i=0; $i<=59; $i+=$step) {
$timeunits[$i] = sprintf("%02d",$i);
}
break;
default:
throw new coding_exception("Time type $type is not supported by html_select::make_time_selector().");
}
$timerselector = self::make($timeunits, $name, $currentdate[$userdatetype]);
$timerselector->label = new html_label();
$timerselector->label->text = get_string(substr($type, -1), 'form');
$timerselector->label->for = "menu$timerselector->name";
$timerselector->label->add_class('accesshide');
$timerselector->nothinglabel = '';
return $timerselector;
}
/**
* Given an associative array of type => fieldname and an optional timestamp,
* returns an array of html_select components representing date/time selectors.
* @param array $selectors Arrays of type => fieldname. Selectors will be returned in the order of the types given
* @param int $currenttime A UNIX timestamp
* @param int $step minute spacing
* @return array Instantiated date/time selectors
*/
public function make_time_selectors($selectors, $currenttime=0, $step=5) {
$selects = array();
foreach ($selectors as $type => $name) {
$selects[] = html_select::make_time_selector($type, $name, $currenttime, $step);
}
return $selects;
}
/**
* This is a shortcut for making a select popup form.
* @param mixed $baseurl The target URL, string or moodle_url
* @param string $name The variable which this select's options are changing in the URL
* @param array $options A list of value-label pairs for the popup list
* @param string $formid id for the control. Must be unique on the page. Used in the HTML.
* @param string $selected The option that is initially selected
* @return html_select A menu initialised as a popup form.
*/
public function make_popup_form($baseurl, $name, $options, $formid, $selected=null) {
global $CFG;
$selectedurl = null;
if (!($baseurl instanceof moodle_url)) {
$baseurl = new moodle_url($baseurl);
}
if (!empty($selected)) {
$selectedurl = $baseurl->out(false, array($name => $selected), false);
}
if (!($baseurl instanceof moodle_url)) {
$baseurl = new moodle_url($baseurl);
}
// Replace real value by formatted URLs
foreach ($options as $value => $label) {
$options[$baseurl->out(false, array($name => $value), false)] = $label;
unset($options[$value]);
}
$select = self::make($options, 'jump', $selectedurl);
$select->form = new html_form();
$select->form->id = $formid;
$select->form->method = 'get';
$select->form->add_class('popupform');
$select->form->url = new moodle_url($CFG->wwwroot . '/course/jumpto.php', array('sesskey' => sesskey()));
$select->form->button->text = get_string('go');
$select->id = $formid . '_jump';
$select->add_action('change', 'submit_form_by_id', array('id' => $formid, 'selectid' => $select->id));
return $select;
}
/**
* Override the URLs of the default popup_form, which only supports one base URL
* @param array $options value=>label pairs representing select options
* @return void
*/
public function override_option_values($options) {
global $PAGE;
$this->initialise_options();
reset($options);
foreach ($this->options as $optkey => $optgroup) {
if ($optgroup instanceof html_select_optgroup) {
foreach ($optgroup->options as $key => $option) {
next($options);
$this->options[$optkey]->options[$key]->value = key($options);
$optionurl = new moodle_url(key($options));
if ($optionurl->compare($PAGE->url, URL_MATCH_PARAMS)) {
$this->options[$optkey]->options[$key]->selected = 'selected';
}
}
next($options);
} else if ($optgroup instanceof html_select_option) {
next($options);
$this->options[$optkey]->value = key($options);
$optionurl = new moodle_url(key($options));
if ($optionurl->compare($PAGE->url, URL_MATCH_PARAMS)) {
$this->options[$optkey]->selected = 'selected';
}
}
}
}
/**
* Adds a help icon next to the select menu.
*
* This can be used in two ways:
*
* <pre>
* $select->set_help_icon($page, $text, $linktext);
* // OR
* $helpicon = new moodle_help_icon();
* $helpicon->page = $page;
* $helpicon->text = $text;
* $helpicon->linktext = $linktext;
* $select->set_help_icon($helpicon);
* </pre>
*
* Use the second form when you need to add additional HTML attributes
* to the label and/or JS actions.
*
* @param mixed $page Either the keyword that defines a help page or a moodle_help_icon object
* @param text $text The text of the help icon
* @param boolean $linktext Whether or not to show text next to the icon
* @return void
*/
public function set_help_icon($page, $text, $linktext=false) {
if ($page instanceof moodle_help_icon) {
$this->helpicon = $page;
} else if (!empty($page)) {
$this->helpicon = new moodle_help_icon();
$this->helpicon->page = $page;
$this->helpicon->text = $text;
$this->helpicon->linktext = $linktext;
}
}
/**
* Parses the $options array and instantiates html_select_option objects in
* the place of the original value => label pairs. This is useful for when you
* need to setup extra html attributes and actions on individual options before
* the component is sent to the renderer
* @return void;
*/
public function initialise_options() {
// If options are already instantiated objects, stop here
$firstoption = reset($this->options);
if ($firstoption instanceof html_select_option || $firstoption instanceof html_select_optgroup) {
return;
}
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 && $this->rendertype != 'menu') {
throw new coding_exception('html_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;
foreach ($values as $value => $display) {
$option = new html_select_option();
$option->value = s($value);
$option->text = $display;
if ($display === '') {
$option->text = $value;
}
if ((string) $value == (string) $this->selectedvalue ||
(is_array($this->selectedvalue) && in_array($value, $this->selectedvalue))) {
$option->selected = 'selected';
}
$optgroup->options[] = $option;
}
$this->options[] = $optgroup;
}
} else {
$inoptgroup = false;
$optgroup = false;
foreach ($options as $value => $display) {
if ($display == '--') { /// we are ending previous optgroup
// $this->options[] = $optgroup;
$inoptgroup = false;
continue;
} else if (substr($display,0,2) == '--') { /// we are starting a new optgroup
if (!empty($optgroup->options)) {
$this->options[] = $optgroup;
}
$optgroup = new html_select_optgroup();
$optgroup->text = substr($display,2); // stripping the --
$inoptgroup = true; /// everything following will be in an optgroup
continue;
} else {
// Add $nothing option if there are not optgroups
if ($this->nothinglabel && empty($this->options[0]) && !$inoptgroup) {
$nothingoption = new html_select_option();
$nothingoption->value = 0;
if (!empty($this->nothingvalue)) {
$nothingoption->value = $this->nothingvalue;
}
$nothingoption->text = $this->nothinglabel;
$this->options = array($nothingoption) + $this->options;
}
$option = new html_select_option();
$option->text = $display;
if ($display === '') {
$option->text = $value;
}
if ((string) $value == (string) $this->selectedvalue ||
(is_array($this->selectedvalue) && in_array($value, $this->selectedvalue))) {
$option->selected = 'selected';
}
$option->value = s($value);
if ($inoptgroup) {
$optgroup->options[] = $option;
} else {
$this->options[] = $option;
}
}
}
if ($optgroup) {
$this->options[] = $optgroup;
}
}
}
}
/**
* This class represents a select option element
*
@@ -1030,468 +1492,6 @@ class html_list_item extends moodle_html_component {
/// Complex components aggregating simpler components
/**
* This class hold all the information required to describe a <select> menu that
* 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
* needs a bit more setting up than for a simple menu. See the shortcut methods for
* developer-friendly usage.
*
* All the fields that are not set by the constructor have sensible defaults, so
* you only need to set the properties where you want non-default behaviour.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
*/
class moodle_select extends moodle_html_component {
/**
* 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 $options;
/**
* @var string $name the name of this form control. That is, the name of the GET/POST
* variable that will be set if this select is submitted as part of a form.
*/
public $name;
/**
* @var mixed $label The label for that component. String or html_label object
*/
public $label;
/**
* @var string $selectedvalue the option to select initially. Should match one
* of the $options array keys. Default none.
*/
public $selectedvalue;
/**
* 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;
/**
* @var string The value returned by the 'nothing is selected' option. Defaults to 0.
*/
public $nothingvalue = 0;
/**
* @var boolean set this to true if you want the control to appear disabled.
*/
public $disabled = false;
/**
* @var integer if non-zero, sets the tabindex attribute on the <select> element. Default 0.
*/
public $tabindex = 0;
/**
* @var mixed Defaults to false, which means display the select as a dropdown menu.
* If true, display this select as a list box whose size is chosen automatically.
* If an integer, display as list box of that size.
*/
public $listbox = false;
/**
* @var integer if you are using $listbox === true to get an automatically
* sized list box, the size of the list box will be the number of options,
* or this number, whichever is smaller.
*/
public $maxautosize = 10;
/**
* @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;
/**
* Another way to use nested menu is to prefix optgroup labels with -- and end the optgroup with --
* Leave this setting to false if you are using the latter method.
* @var boolean $nested if true, uses $options' keys as option headings (optgroup)
*/
public $nested = false;
/**
* @var html_form $form An optional html_form component
*/
public $form;
/**
* @var moodle_help_icon $form An optional moodle_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()
* @return void
*/
public function prepare() {
global $CFG;
// name may contain [], which would make an invalid id. e.g. numeric question type editing form, assignment quickgrading
if (empty($this->id)) {
$this->id = 'menu' . str_replace(array('[', ']'), '', $this->name);
}
if (empty($this->classes)) {
$this->set_classes(array('menu' . str_replace(array('[', ']'), '', $this->name)));
}
if (is_null($this->nothinglabel)) {
$this->nothinglabel = get_string('choosedots');
}
if (!empty($this->label) && !($this->label instanceof html_label)) {
$label = new html_label();
$label->text = $this->label;
$label->for = $this->name;
$this->label = $label;
}
$this->add_class('select');
$this->initialise_options();
parent::prepare();
}
/**
* This is a shortcut for making a simple select menu. It lets you specify
* the options, name and selected option in one line of code.
* @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 A moodle_select object with the three common fields initialised.
*/
public static function make($options, $name, $selected = '') {
$menu = new moodle_select();
$menu->options = $options;
$menu->name = $name;
$menu->selectedvalue = $selected;
return $menu;
}
/**
* 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 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);
}
/**
* This is a shortcut for making an hour selector menu.
* @param string $type The type of selector (years, months, days, hours, minutes)
* @param string $name fieldname
* @param int $currenttime A default timestamp in GMT
* @param int $step minute spacing
* @return moodle_select A menu initialised with hour options.
*/
public static function make_time_selector($type, $name, $currenttime=0, $step=5) {
if (!$currenttime) {
$currenttime = time();
}
$currentdate = usergetdate($currenttime);
$userdatetype = $type;
switch ($type) {
case 'years':
for ($i=1970; $i<=2020; $i++) {
$timeunits[$i] = $i;
}
$userdatetype = 'year';
break;
case 'months':
for ($i=1; $i<=12; $i++) {
$timeunits[$i] = userdate(gmmktime(12,0,0,$i,15,2000), "%B");
}
$userdatetype = 'month';
break;
case 'days':
for ($i=1; $i<=31; $i++) {
$timeunits[$i] = $i;
}
$userdatetype = 'mday';
break;
case 'hours':
for ($i=0; $i<=23; $i++) {
$timeunits[$i] = sprintf("%02d",$i);
}
break;
case 'minutes':
if ($step != 1) {
$currentdate['minutes'] = ceil($currentdate['minutes']/$step)*$step;
}
for ($i=0; $i<=59; $i+=$step) {
$timeunits[$i] = sprintf("%02d",$i);
}
break;
default:
throw new coding_exception("Time type $type is not supported by moodle_select::make_time_selector().");
}
$timerselector = self::make($timeunits, $name, $currentdate[$userdatetype]);
$timerselector->label = new html_label();
$timerselector->label->text = get_string(substr($type, -1), 'form');
$timerselector->label->for = "menu$timerselector->name";
$timerselector->label->add_class('accesshide');
$timerselector->nothinglabel = '';
return $timerselector;
}
/**
* Given an associative array of type => fieldname and an optional timestamp,
* returns an array of moodle_select components representing date/time selectors.
* @param array $selectors Arrays of type => fieldname. Selectors will be returned in the order of the types given
* @param int $currenttime A UNIX timestamp
* @param int $step minute spacing
* @return array Instantiated date/time selectors
*/
public function make_time_selectors($selectors, $currenttime=0, $step=5) {
$selects = array();
foreach ($selectors as $type => $name) {
$selects[] = moodle_select::make_time_selector($type, $name, $currenttime, $step);
}
return $selects;
}
/**
* This is a shortcut for making a select popup form.
* @param mixed $baseurl The target URL, string or moodle_url
* @param string $name The variable which this select's options are changing in the URL
* @param array $options A list of value-label pairs for the popup list
* @param string $formid id for the control. Must be unique on the page. Used in the HTML.
* @param string $selected The option that is initially selected
* @return moodle_select A menu initialised as a popup form.
*/
public function make_popup_form($baseurl, $name, $options, $formid, $selected=null) {
global $CFG;
$selectedurl = null;
if (!($baseurl instanceof moodle_url)) {
$baseurl = new moodle_url($baseurl);
}
if (!empty($selected)) {
$selectedurl = $baseurl->out(false, array($name => $selected), false);
}
if (!($baseurl instanceof moodle_url)) {
$baseurl = new moodle_url($baseurl);
}
// Replace real value by formatted URLs
foreach ($options as $value => $label) {
$options[$baseurl->out(false, array($name => $value), false)] = $label;
unset($options[$value]);
}
$select = self::make($options, 'jump', $selectedurl);
$select->form = new html_form();
$select->form->id = $formid;
$select->form->method = 'get';
$select->form->add_class('popupform');
$select->form->url = new moodle_url($CFG->wwwroot . '/course/jumpto.php', array('sesskey' => sesskey()));
$select->form->button->text = get_string('go');
$select->id = $formid . '_jump';
$select->add_action('change', 'submit_form_by_id', array('id' => $formid, 'selectid' => $select->id));
return $select;
}
/**
* Override the URLs of the default popup_form, which only supports one base URL
* @param array $options value=>label pairs representing select options
* @return void
*/
public function override_option_values($options) {
global $PAGE;
$this->initialise_options();
reset($options);
foreach ($this->options as $optkey => $optgroup) {
if ($optgroup instanceof html_select_optgroup) {
foreach ($optgroup->options as $key => $option) {
next($options);
$this->options[$optkey]->options[$key]->value = key($options);
$optionurl = new moodle_url(key($options));
if ($optionurl->compare($PAGE->url, URL_MATCH_PARAMS)) {
$this->options[$optkey]->options[$key]->selected = 'selected';
}
}
next($options);
} else if ($optgroup instanceof html_select_option) {
next($options);
$this->options[$optkey]->value = key($options);
$optionurl = new moodle_url(key($options));
if ($optionurl->compare($PAGE->url, URL_MATCH_PARAMS)) {
$this->options[$optkey]->selected = 'selected';
}
}
}
}
/**
* Adds a help icon next to the select menu.
*
* This can be used in two ways:
*
* <pre>
* $select->set_help_icon($page, $text, $linktext);
* // OR
* $helpicon = new moodle_help_icon();
* $helpicon->page = $page;
* $helpicon->text = $text;
* $helpicon->linktext = $linktext;
* $select->set_help_icon($helpicon);
* </pre>
*
* Use the second form when you need to add additional HTML attributes
* to the label and/or JS actions.
*
* @param mixed $page Either the keyword that defines a help page or a moodle_help_icon object
* @param text $text The text of the help icon
* @param boolean $linktext Whether or not to show text next to the icon
* @return void
*/
public function set_help_icon($page, $text, $linktext=false) {
if ($page instanceof moodle_help_icon) {
$this->helpicon = $page;
} else if (!empty($page)) {
$this->helpicon = new moodle_help_icon();
$this->helpicon->page = $page;
$this->helpicon->text = $text;
$this->helpicon->linktext = $linktext;
}
}
/**
* Parses the $options array and instantiates html_select_option objects in
* the place of the original value => label pairs. This is useful for when you
* need to setup extra html attributes and actions on individual options before
* the component is sent to the renderer
* @return void;
*/
public function initialise_options() {
// If options are already instantiated objects, stop here
$firstoption = reset($this->options);
if ($firstoption instanceof html_select_option || $firstoption instanceof html_select_optgroup) {
return;
}
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 && $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;
foreach ($values as $value => $display) {
$option = new html_select_option();
$option->value = s($value);
$option->text = $display;
if ($display === '') {
$option->text = $value;
}
if ((string) $value == (string) $this->selectedvalue ||
(is_array($this->selectedvalue) && in_array($value, $this->selectedvalue))) {
$option->selected = 'selected';
}
$optgroup->options[] = $option;
}
$this->options[] = $optgroup;
}
} else {
$inoptgroup = false;
$optgroup = false;
foreach ($options as $value => $display) {
if ($display == '--') { /// we are ending previous optgroup
// $this->options[] = $optgroup;
$inoptgroup = false;
continue;
} else if (substr($display,0,2) == '--') { /// we are starting a new optgroup
if (!empty($optgroup->options)) {
$this->options[] = $optgroup;
}
$optgroup = new html_select_optgroup();
$optgroup->text = substr($display,2); // stripping the --
$inoptgroup = true; /// everything following will be in an optgroup
continue;
} else {
// Add $nothing option if there are not optgroups
if ($this->nothinglabel && empty($this->options[0]) && !$inoptgroup) {
$nothingoption = new html_select_option();
$nothingoption->value = 0;
if (!empty($this->nothingvalue)) {
$nothingoption->value = $this->nothingvalue;
}
$nothingoption->text = $this->nothinglabel;
$this->options = array($nothingoption) + $this->options;
}
$option = new html_select_option();
$option->text = $display;
if ($display === '') {
$option->text = $value;
}
if ((string) $value == (string) $this->selectedvalue ||
(is_array($this->selectedvalue) && in_array($value, $this->selectedvalue))) {
$option->selected = 'selected';
}
$option->value = s($value);
if ($inoptgroup) {
$optgroup->options[] = $option;
} else {
$this->options[] = $option;
}
}
}
if ($optgroup) {
$this->options[] = $optgroup;
}
}
}
}
/**
* Component representing a paging bar.
*
+10 -10
View File
@@ -1565,26 +1565,26 @@ class moodle_core_renderer extends moodle_renderer_base {
* descriptive labels and help icons. By default it just outputs a select
* menu.
*
* 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 descriptive label, use html_select::set_label($text, $for) or
* html_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 moodle_help_icon object
* To add a help icon, use html_select::set_help($page, $text, $linktext) or
* html_select::set_help($helpicon) passing a moodle_help_icon object
*
* If you moodle_select::$rendertype to "radio", it will render radio buttons
* If you html_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->form as a
* To surround the menu with a form, simply set html_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 argument
* You can either call this function with a single html_select argument
* or, with a list of parameters, in which case those parameters are sent to
* the moodle_select constructor.
* the html_select constructor.
*
* @param moodle_select $select a moodle_select that describes
* @param html_select $select a html_select that describes
* the select menu you want output.
* @return string the HTML for the <select>
*/
@@ -1745,7 +1745,7 @@ class moodle_core_renderer extends moodle_renderer_base {
* Output an <option> or <optgroup> element. If an optgroup element is detected,
* this will recursively output its options as well.
*
* @param mixed $option a html_select_option or moodle_select_optgroup
* @param mixed $option a html_select_option or html_select_optgroup
* @return string the HTML for the <option> or <optgroup>
*/
public function select_option($option) {
+1 -1
View File
@@ -2355,7 +2355,7 @@ function question_category_select_menu($contexts, $top = false, $currentcat = 0,
} else {
$nothing = 'choosedots';
}
$select = moodle_select::make($categoriesarray, 'category', $selected);
$select = html_select::make($categoriesarray, 'category', $selected);
$select->nothingvalue = $nothing;
$select->nested = true;
echo $OUTPUT->select($select);
+4 -4
View File
@@ -884,7 +884,7 @@ class moodle_core_renderer_test extends UnitTestCase {
}
public function test_select_simple() {
$select = moodle_select::make(array(10 => 'ten', 'c2' => 'two'), 'mymenu');
$select = html_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);
@@ -1160,9 +1160,9 @@ class moodle_core_renderer_test extends UnitTestCase {
$html = $this->renderer->htmllist($htmllist);
}
public function test_moodle_select() {
public function test_html_select() {
$options = array('var1' => 'value1', 'var2' => 'value2', 'var3' => 'value3');
$select = moodle_select::make($options, 'mymenu', 'var2');
$select = html_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);
@@ -1173,7 +1173,7 @@ class moodle_core_renderer_test extends UnitTestCase {
$this->assert(new ContainsTagWithContents('option', 'value3'), $html);
$options = array('group1' => '--group1', 'var1' => 'value1', 'var2' => 'value2', 'group2' => '--', 'group2' => '--group2', 'var3' => 'value3', 'var4' => 'value4');
$select = moodle_select::make($options, 'mymenu', 'var2');
$select = html_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);
+1 -1
View File
@@ -2666,7 +2666,7 @@ function switchroles_form($courseid) {
// unset default user role - it would not work
unset($roles[$CFG->guestroleid]);
$popupurl = $CFG->wwwroot.'/course/view.php?id='.$courseid.'&sesskey='.sesskey();
$select = moodle_select::make_popup_form($popupurl, 'switchrole', $roles, 'switchrole', '');
$select = html_select::make_popup_form($popupurl, 'switchrole', $roles, 'switchrole', '');
$select->nothinglabel = get_string('switchroleto');
$select->set_help_icon('switchrole', get_string('switchroleto'));
return $OUTPUT->select($select);
+1 -1
View File
@@ -46,7 +46,7 @@
} else {
$currlang = current_language();
$langs = get_list_of_languages();
$select = moodle_select::make_popup_form("$CFG->httpswwwroot/login/index.php", 'lang', $langs, 'chooselang', $currlang);
$select = html_select::make_popup_form("$CFG->httpswwwroot/login/index.php", 'lang', $langs, 'chooselang', $currlang);
$select->nothinglabel = false;
$select->set_label(get_accesshide(get_string('language')));
$langmenu = $OUTPUT->select($select);
+1 -1
View File
@@ -51,7 +51,7 @@
} else {
$currlang = current_language();
$langs = get_list_of_languages();
$select = moodle_select::make_popup_form("$CFG->wwwroot/login/signup.php", 'lang', $langs, 'chooselang', $currlang);
$select = html_select::make_popup_form("$CFG->wwwroot/login/signup.php", 'lang', $langs, 'chooselang', $currlang);
$select->nothinglabel = false;
$langmenu = $OUTPUT->select($select);
}
+1 -1
View File
@@ -544,7 +544,7 @@ function choice_show_results($choice, $course, $cm, $allresponses, $forcepublish
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 '&nbsp;&nbsp;';
$select = new moodle_select();
$select = new html_select();
$select->options = array('delete' => get_string('delete'));
$select->name = 'action';
$select->button->label = get_string('withselected', 'quiz');
+1 -1
View File
@@ -280,7 +280,7 @@
echo '<div class="fieldadd">';
echo '<label for="fieldform_jump">'.get_string('newfield','data').'</label>';
$popupurl = $CFG->wwwroot.'/mod/data/field.php?d='.$data->id.'&mode=new&sesskey='. sesskey();
echo $OUTPUT->select(moodle_select::make_popup_form($popupurl, 'newtype', $menufield, "fieldform"));
echo $OUTPUT->select(html_select::make_popup_form($popupurl, 'newtype', $menufield, "fieldform"));
helpbutton('fields', get_string('addafield','data'), 'data');
echo '</div>';
+3 -3
View File
@@ -44,9 +44,9 @@ class data_field_date extends data_field_base {
}
$str = '<div title="'.s($this->field->description).'">';
$dayselector = moodle_select::make_time_selector('days', 'field_'.$this->field->id.'_day', $content);
$monthselector = moodle_select::make_time_selector('months', 'field_'.$this->field->id.'_month', $content);
$yearselector = moodle_select::make_time_selector('years', 'field_'.$this->field->id.'_year', $content);
$dayselector = html_select::make_time_selector('days', 'field_'.$this->field->id.'_day', $content);
$monthselector = html_select::make_time_selector('months', 'field_'.$this->field->id.'_month', $content);
$yearselector = html_select::make_time_selector('years', 'field_'.$this->field->id.'_year', $content);
$str .= $OUTPUT->select($dayselector) . $OUTPUT->select($monthselector) . $OUTPUT->select($yearselector);
$str .= '</div>';
+1 -1
View File
@@ -146,7 +146,7 @@
if ($courses = $DB->get_records_sql_menu($sql, $params)) {
echo ' ' . get_string('filter_by_course', 'feedback') . ': ';
$select = new moodle_select();
$select = new html_select();
$select->options = $courses;
$select->name = 'coursefilter';
$select->selectedvalue = $coursefilter;
+1 -1
View File
@@ -212,7 +212,7 @@
}
if (!empty($forummenu)) {
echo "<div style=\"float:right;\">";
$select = moodle_select::make_popup_form('', '', $forummenu, 'forummenu');
$select = html_select::make_popup_form('', '', $forummenu, 'forummenu');
$select->nothinglabel = get_string("movethisdiscussionto", "forum");
$select->form->button->text = get_string('move');
+1 -1
View File
@@ -4135,7 +4135,7 @@ function forum_print_rating_menu($postid, $userid, $scale, $myrating=NULL) {
*/
function forum_print_mode_form($id, $mode, $forumtype='') {
global $OUTPUT;
$select = moodle_select::make_popup_form("view.php?f=$id", 'mode', forum_get_layout_modes(), "mode", $mode);
$select = html_select::make_popup_form("view.php?f=$id", 'mode', forum_get_layout_modes(), "mode", $mode);
$select->nothinglabel = false;
if ($forumtype == 'single') {
+2 -2
View File
@@ -292,7 +292,7 @@ function forum_print_big_search_form($course) {
}
echo '<input name="timefromrestrict" type="checkbox" value="1" alt="'.get_string('searchdatefrom', 'forum').'" onclick="return lockoptions(\'searchform\', \'timefromrestrict\', timefromitems)" '. $datefromchecked . ' /> ';
$selectors = moodle_select::make_time_selectors(array('days' => 'fromday','months' => 'frommonth', 'years' => 'fromyear', 'hours' => 'fromhour', 'minutes' => 'fromminute'), $datefrom);
$selectors = html_select::make_time_selectors(array('days' => 'fromday','months' => 'frommonth', 'years' => 'fromyear', 'hours' => 'fromhour', 'minutes' => 'fromminute'), $datefrom);
foreach ($selectors as $select) {
echo $OUTPUT->select($select);
}
@@ -316,7 +316,7 @@ function forum_print_big_search_form($course) {
}
echo '<input name="timetorestrict" type="checkbox" value="1" alt="'.get_string('searchdateto', 'forum').'" onclick="return lockoptions(\'searchform\', \'timetorestrict\', timetoitems)" ' .$datetochecked. ' /> ';
$selectors = moodle_select::make_time_selectors(array('days' => 'today','months' => 'tomonth', 'years' => 'toyear', 'hours' => 'tohour', 'minutes' => 'tominute'), $dateto);
$selectors = html_select::make_time_selectors(array('days' => 'today','months' => 'tomonth', 'years' => 'toyear', 'hours' => 'tohour', 'minutes' => 'tominute'), $dateto);
foreach ($selectors as $select) {
echo $OUTPUT->select($select);
}
+1 -1
View File
@@ -1523,7 +1523,7 @@ function glossary_print_categories_menu($cm, $glossary, $hook, $category) {
echo '</b></td>';
echo '<td align="center" style="width:20%">';
$select = moodle_select::make_popup_form("$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&mode=cat", 'hook', $menu, "catmenu", $selected);
$select = html_select::make_popup_form("$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&mode=cat", 'hook', $menu, "catmenu", $selected);
$select->nothinglabel = false;
echo $OUTPUT->select($select);
+1 -1
View File
@@ -481,7 +481,7 @@ function lesson_print_page_actions($cmid, $page, $printmove, $printaddpage = fal
$options['addpage'] = get_string('question', 'lesson');
// Base url
$common = "$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&pageid=$page->id";
$select = moodle_select::make_popup_form($common, 'action', $options, "addpage_$page->id");
$select = html_select::make_popup_form($common, 'action', $options, "addpage_$page->id");
$select->nothinglabel = get_string('addpage', 'lesson').'...';
$actions[] = $OUTPUT->select($select);
+1 -1
View File
@@ -275,7 +275,7 @@
'<a href="javascript: checkall();">'.get_string('selectall').'</a> / '.
'<a href="javascript: checknone();">'.get_string('deselectall').'</a> ';
$select = new moodle_select();
$select = new html_select();
$select->options = array('delete' => get_string('deleteselected'));
$select->name = 'attemptaction';
$select->selectedvalue = 0;
+1 -1
View File
@@ -185,7 +185,7 @@ class quiz_grading_report extends quiz_default_report {
if (count($gradeableqs)!=1){
$qurl = fullclone($this->viewurl);
$qurl->remove_params('questionid', 'attemptid', 'gradeall', 'gradeungraded', 'gradenextungraded');
$menu = $OUTPUT->select(moodle_select::make_popup_form($qurl->out(), 'questionid', $qmenu, 'questionid', $questionid));
$menu = $OUTPUT->select(html_select::make_popup_form($qurl->out(), 'questionid', $qmenu, 'questionid', $questionid));
echo '<div class="mdl-align">'.$menu.'</div>';
}
if (!$questionid){
+1 -1
View File
@@ -540,7 +540,7 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
}
$url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr;
$select = moodle_select::make_popup_form($url, 'scoid', $tocmenus, "tocmenu", $sco->id);
$select = html_select::make_popup_form($url, 'scoid', $tocmenus, "tocmenu", $sco->id);
$select->nothinglabel = false;
$result->tocmenu = $OUTPUT->select($select);
+1 -1
View File
@@ -324,7 +324,7 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
}
$url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr;
$select = moodle_select::make_popup_form($url, 'scoid', $tocmenus, "tocmenu", $sco->id);
$select = html_select::make_popup_form($url, 'scoid', $tocmenus, "tocmenu", $sco->id);
$select->nothinglabel = false;
$result->tocmenu = $OUTPUT->select($select);
+1 -1
View File
@@ -215,7 +215,7 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
}
$url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr;
$select = moodle_select::make_popup_form($url, 'scoid', $tocmenus, "tocmenu", $sco->id);
$select = html_select::make_popup_form($url, 'scoid', $tocmenus, "tocmenu", $sco->id);
$select->nothinglabel = false;
$result->tocmenu = $OUTPUT->select($select);
+1 -1
View File
@@ -740,7 +740,7 @@ function scorm_view_display ($user, $scorm, $action, $cm, $boxwidth='') {
<?php print_string('organizations','scorm') ?>
<form id='changeorg' method='post' action='<?php echo $action ?>'>
<?php
$select = new moodle_select();
$select = new html_select();
$select->options = $orgs;
$select->name = 'organization';
$select->selectedvalue = $organization;
+1 -1
View File
@@ -198,7 +198,7 @@
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 '&nbsp;&nbsp;';
$select = new moodle_select();
$select = new html_select();
$select->options = array('delete' => get_string('delete'));
$select->name = 'action';
$select->button->label = get_string('withselected', 'quiz');
+1 -1
View File
@@ -285,7 +285,7 @@
while(list($key,$val)=each($wiki_list)) {
$wiki_admin_list[$key."&amp;action=$action"]=$val;
}
$select = new moodle_select();
$select = new html_select();
$select->options = $wiki_admin_list;
$select->name = 'wikiselect';
$select->selectedvalue = $selected;
+3 -3
View File
@@ -1476,7 +1476,7 @@ function wiki_print_wikilinks_block($cmid, $binary=false, $return=false) {
$name = $matches[1];
}
$select = moodle_select::make_popup_form(EWIKI_SCRIPT, $name, $links, 'wikilinks');
$select = html_select::make_popup_form(EWIKI_SCRIPT, $name, $links, 'wikilinks');
$select->nothinglabel = get_string("choosewikilinks", "wiki");
echo $OUTPUT->select($select);
}
@@ -1516,7 +1516,7 @@ function wiki_print_page_actions($cmid, $specialpages, $page, $action, $binary=f
$name = $matches[1];
}
$select = moodle_select::make_popup_form(EWIKI_SCRIPT, $name, $page, 'wikiactions');
$select = html_select::make_popup_form(EWIKI_SCRIPT, $name, $page, 'wikiactions');
$select->nothinglabel = get_string("action", "wiki");
echo $OUTPUT->select($select);
}
@@ -1561,7 +1561,7 @@ function wiki_print_administration_actions($wiki, $cmid, $userid, $groupid, $pag
if($noeditor) {
$action["checklinks"]=get_string("checklinks", "wiki");
}
$select = moodle_select::make_popup_form($ewscript, 'action', $action, 'wikiadministration');
$select = html_select::make_popup_form($ewscript, 'action', $action, 'wikiadministration');
$select->nothinglabel = get_string("chooseadministration", "wiki");
echo $OUTPUT->select($select);
}
+1 -1
View File
@@ -300,7 +300,7 @@
echo '<td class="sideblockheading">'
.get_string('otherwikis', 'wiki').':&nbsp;&nbsp;';
$select = new moodle_select();
$select = new html_select();
$select->options = $wiki_list;
$select->name = 'wikiselect';
$select->selectedvalue = $selected;
+1 -1
View File
@@ -50,7 +50,7 @@
} else {
$currlang = current_language();
$langs = get_list_of_languages();
$select = moodle_select::make_popup_form($CFG->wwwroot .'/my/index.php', 'lang', $langs, 'chooselang', $currlang);
$select = html_select::make_popup_form($CFG->wwwroot .'/my/index.php', 'lang', $langs, 'chooselang', $currlang);
$select->nothinglabel = false;
$select->set_label(get_accesshide(get_string('language')));
$langmenu = $OUTPUT->select($select);
+1 -1
View File
@@ -1165,7 +1165,7 @@ class question_bank_view {
/// Get all the existing categories now
echo '<div class="choosecategory">';
$catmenu = question_category_options($contexts, false, 0, true);
$select = moodle_select::make_popup_form('edit.php?'.$pageurl->get_query_string(), 'category', $catmenu, 'catmenu', $current);
$select = html_select::make_popup_form('edit.php?'.$pageurl->get_query_string(), 'category', $catmenu, 'catmenu', $current);
$select->nothinglabel = false;
$select->set_label(get_string('selectacategory', 'question'));
echo $OUTPUT->select($select);
+5 -5
View File
@@ -223,7 +223,7 @@
unset($courselist[SITEID]);
$courselist = array(SITEID => format_string($SITE->shortname)) + $courselist;
}
$select = moodle_select::make_popup_form($popupurl, 'id', $courselist, 'courseform', $course->id);
$select = html_select::make_popup_form($popupurl, 'id', $courselist, 'courseform', $course->id);
$select->set_label(get_string('mycourses'));
echo $OUTPUT->select($select);
echo '</td>';
@@ -285,7 +285,7 @@
if (count($timeoptions) > 1) {
echo '<td class="left">';
$select = moodle_select::make_popup_form($baseurl, 'accesssince', $timeoptions, 'timeoptions', $accesssince);
$select = html_select::make_popup_form($baseurl, 'accesssince', $timeoptions, 'timeoptions', $accesssince);
$select->set_label(get_string('usersnoaccesssince'));
echo $OUTPUT->select($select);
echo '</td>';
@@ -315,7 +315,7 @@
if ($allowenroldetails) {
$formatmenu['2']= get_string('enroldetails');
}
$select = moodle_select::make_popup_form($baseurl, 'mode', $formatmenu, 'formatmenu', $mode);
$select = html_select::make_popup_form($baseurl, 'mode', $formatmenu, 'formatmenu', $mode);
$select->nothinglabel = false;
$select->set_label(get_string('userlist'));
echo $OUTPUT->select($select);
@@ -589,7 +589,7 @@
$rolenames = array('0' => get_string('userswithrole', 'role')) + $rolenames;
}
}
$select = moodle_select::make_popup_form($rolenamesurl, 'roleid', $rolenames, 'rolesform', $roleid);
$select = html_select::make_popup_form($rolenamesurl, 'roleid', $rolenames, 'rolesform', $roleid);
$select->nothinglabel = false;
echo $OUTPUT->select($select);
echo '</div>';
@@ -970,7 +970,7 @@
}
helpbutton("participantswithselectedusers", get_string("withselectedusers"));
$select = new moodle_select();
$select = new html_select();
$select->options = $displaylist;
$select->name = "formaction";
$select->label = get_string("withselectedusers");
+1 -1
View File
@@ -140,7 +140,7 @@ echo '<div class="profileeditor">';
/// Create a new field link
$options = profile_list_datatypes();
$popupurl = $CFG->wwwroot.'/user/profile/index.php?id=0&action=editfield';
echo $OUTPUT->select(moodle_select::make_popup_form($popupurl, 'datatype', $options, 'newfieldform', $strcreatefield));
echo $OUTPUT->select(html_select::make_popup_form($popupurl, 'datatype', $options, 'newfieldform', $strcreatefield));
/// Create a new category link
$options = array('action'=>'editcategory');