]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19756 Renamed moodle_select to html_select for better API consistency
authornicolasconnault <nicolasconnault>
Mon, 10 Aug 2009 08:38:45 +0000 (08:38 +0000)
committernicolasconnault <nicolasconnault>
Mon, 10 Aug 2009 08:38:45 +0000 (08:38 +0000)
62 files changed:
admin/environment.php
admin/filters.php
admin/lang.php
admin/roles/assign.php
admin/roles/override.php
auth/shibboleth/login.php
backup/restore_form.html
blocks/rss_client/managefeeds.php
calendar/event_edit.html
calendar/event_new.html
calendar/view.php
course/category.php
course/format/topics/format.php
course/format/weeks/format.php
course/index.php
course/lib.php
course/report/log/lib.php
course/report/participation/index.php
course/report/stats/lib.php
course/search.php
enrol/authorize/config_form.php
enrol/authorize/locallib.php
enrol/mnet/config.html
grade/edit/tree/index.php
grade/edit/tree/lib.php
grade/lib.php
group/overview.php
index.php
lib/blocklib.php
lib/deprecatedlib.php
lib/grouplib.php
lib/javascript-static.js
lib/outputcomponents.php
lib/outputrenderers.php
lib/questionlib.php
lib/simpletest/testoutputlib.php
lib/weblib.php
login/index.php
login/signup.php
mod/choice/lib.php
mod/data/field.php
mod/data/field/date/field.class.php
mod/feedback/analysis_course.php
mod/forum/discuss.php
mod/forum/lib.php
mod/forum/search.php
mod/glossary/lib.php
mod/lesson/locallib.php
mod/lesson/report.php
mod/quiz/report/grading/report.php
mod/scorm/datamodels/aicclib.php
mod/scorm/datamodels/scorm_12lib.php
mod/scorm/datamodels/scorm_13lib.php
mod/scorm/locallib.php
mod/scorm/report.php
mod/wiki/admin.php
mod/wiki/lib.php
mod/wiki/view.php
my/index.php
question/editlib.php
user/index.php
user/profile/index.php

index 93c8bf043bd60f698a4c301d63af4e0f63d6fe28..d1b84f1854ec28fe068c9443572087ef90fb7410 100644 (file)
 
 /// 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>';
index 440d3d73ad0dea40b7724fc9907f6ac4d4f049f6..d71b2f47365745fbbc2e5f7a6e96013c6f54ab86 100644 (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');
index a0ec39f37c007713b1110348348b9ded027ba353..15e7cea96245538b73eb553cdce086353b91621b 100644 (file)
         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);
         //$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);
         //$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);
index 07ba75bef8417ae816472202108a949d485b6609..c22c8f176b42f03ee7ec64b47741a0ffcc3e8fe1 100755 (executable)
 
     /// 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);
index b9f8412c80318504db0a0fb46b4f9f70cdd9aa05..977a1e2d9db1871a164fe6c3ed3126fb72b3a8f6 100755 (executable)
 
     /// 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);
index 258561c4b861e25adb9e3b1142383b09f03b4da9..92cb2aa27bb6c045b251d6726a6252599c5fa2d8 100644 (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);
index fcad656e6750a4deadb69eb1a62bde77fa9cdb80..0f82f4d4714ace984d0a969d7cb03afdc59d8199 100644 (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"));
index 5790d53afb720275bcf195ba43ad00e69f9258f3..cca4e96d4b52e83fb027dee68e3fddb23b692dc9 100644 (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);
 
index 0208cb19cbd3f5f3bfa2259ce182a070f94b28da..bc5da929d9edda8c7f0b8c1edf33879e04a7a891 100644 (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', 
index ff2ce47897f81b940ab8e9570a7f8839f222f2ce..b6c6ad9943a66e34771cb88755da87ba7fb75c23 100644 (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', 
index 6056d1ced5ffe74d4d45e9d7a1125397e74d0a87..eb826597e733ab1ea4d282139a4d725481b0fc74 100644 (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);
 }
index 60e934f16c5582a9a93508b4e9e7924c93bf86d2..5d0df0656863b29d23333c29985c4d89f0fa6e6e 100644 (file)
     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);
             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;
index 496fde2e03de9526fa76e02042baa2715d0818ee..6a8771d862cce04ff0fdd2bf30c7842d04603ed5 100644 (file)
     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>';
index 23b5a1893f53b8100b154c3f7c3ec32081ce6127..8e56aaa55fd3fbd160ea19157dd15ce219c5e6f3 100644 (file)
     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>';
index a382017cb55bbed288bdc017030a8e8f6e101e04..48fcba31605a5dae85ce4719841c446076e718dc 100644 (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);
         }
index 40280a4bb8110418ba97c24bb75929e47e2c561a..144ac281fbf7bbc3d2bd3471989417569ef17cb4 100644 (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);
index 45571572b3ccd38c37f3cea02726ff72c445c666..a73f44820eba939fc7c2341ae8130477aeea1b4b 100644 (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 {
index ad1f0b76a162b6c57c959d0b586087419870bcde..4d8ece267fff1d2ae69da95b10ca53e6874fa99f 100644 (file)
     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";
             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");
index 28fc7b53be47ee147c84f45f489dca242a9c722a..57acc8ae27f6af97df235797415cdf792bb69ed8 100644 (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);
     }
index d3b84de0a5686d9cbacde8ad02b90eac67a36324..780cc961756d487c36775932a4cd5d1821102935 100644 (file)
             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");
index b6dbab78fb01d4c863ec3205a0d7e143c12cd4c3..1cb44801d84e74377427a20867191122678bc8af 100755 (executable)
@@ -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>
index d00f9b9551a720e1a7661f267bf4c5853bed437a..a3d02816b6b418664afe351a47e7a93a05250724 100644 (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");
index f9f0b9fa3ce3e7a4cf59fa1e9a385be166fcd5dc..5c48e9d91fb7b5cd31011b3767634aa9a2d47813 100644 (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">
index 93b45029d372d674e7511069414c31f05a78440b..284b36b1c2fcd0d1d1c5e01ed6d1dcaf1c6e5db7 100644 (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;
index 551b9d7034816bbdac1defc1fb8d541ed12b6965..564a1cd177cb403ed7a831d8e9744dbc0166a93a 100755 (executable)
@@ -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;
index d2087624bfcb7eaba8ee88b0be811f2d3811fc98..49222a49cc07fd3f8da2a99d7eda46f7d4e67e72 100644 (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) {
index 4821f572da6e688044e9960cbe5815742b0fdce9..66ea5f8484c23661a025ae68ab5bd0a626333701 100644 (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);
 
index 6009984fed31e76b113eebb58f896e4522b55682..7db0b94fbaeff4ac3e88bf626b8a7f8e493a4c05 100644 (file)
--- a/index.php
+++ b/index.php
@@ -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);
index 4c1201c3feb543114605d56633d5de3a0bb4936e..06ac5dce6c5fb9993a96b476958f4b08d78525a4 100644 (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);
index 1ae249389a97fb65bf704896a5735a392da1ba8d..7505a661b088c72c245aadc3d22c106b9cb07eba 100644 (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);
index 6eca7586ac4276c8e35d9e9330aaa132e537a89d..5db4d8c8315f09e3818bed78a24f52cd64b6a553 100644 (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); 
index 44221394f75e35d7f33abf87448d526211fb6cee..c8581d6539e5ca1d3fd532d3988a2d726964c3ba 100644 (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');
index 6113b09407a416d3be0eae211ceb1eb1321bc4a8..9c81b9f1f8b6e2b737db1deb7da908a45478c649 100644 (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.
  *
@@ -264,208 +264,670 @@ class html_label extends moodle_html_component {
 }
 
 /**
- * This class represents a select option element
+ * 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.)
  *
- * @copyright 2009 Nicolas Connault
+ * 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_option extends moodle_html_component {
-    /**
-     * @var string $value The value of this option (will be sent with form)
-     */
-    public $value;
+class html_select extends moodle_html_component {
     /**
-     * @var string $text The display value of the option
+     * 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 $text;
+    public $options;
     /**
-     * @var boolean $selected Whether or not this option is selected
+     * @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 $selected = false;
+    public $name;
     /**
      * @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()
-     * @return void
+     * @var string $selectedvalue the option to select initially. Should match one
+     * of the $options array keys. Default none.
      */
-    public function 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);
-        }
-        if (empty($this->id)) {
-            $this->generate_id();
-        }
-
-        parent::prepare();
-    }
-
+    public $selectedvalue;
     /**
-     * Shortcut for making a checkbox-ready option
-     * @param string $value The value of the checkbox
-     * @param boolean $checked
-     * @param string $label
-     * @param string $alt
-     * @return html_select_option A component ready for $OUTPUT->checkbox()
+     * 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 function make_checkbox($value, $checked, $label='', $alt='') {
-        $checkbox = new html_select_option();
-        $checkbox->value = $value;
-        $checkbox->selected = $checked;
-        $checkbox->text = $label;
-        $checkbox->label->text = $label;
-        $checkbox->alt = $alt;
-        return $checkbox;
-    }
-}
-
-/**
- * This class represents a select optgroup element
- *
- * @copyright 2009 Nicolas Connault
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since     Moodle 2.0
- */
-class html_select_optgroup extends moodle_html_component {
+    public $nothinglabel = null;
     /**
-     * @var string $text The display value of the optgroup
+     * @var string The value returned by the 'nothing is selected' option. Defaults to 0.
      */
-    public $text;
+    public $nothingvalue = 0;
     /**
-     * @var array $options An array of html_select_option objects
+     * @var boolean set this to true if you want the control to appear disabled.
      */
-    public $options = array();
-
-    public function prepare() {
-        if (empty($this->text)) {
-            throw new coding_exception('html_select_optgroup requires a $text value.');
-        }
-        if (empty($this->options)) {
-            throw new coding_exception('html_select_optgroup requires at least one html_select_option object');
-        }
-        parent::prepare();
-    }
-}
-
-/**
- * This class represents an input field
- *
- * @copyright 2009 Nicolas Connault
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since     Moodle 2.0
- */
-class html_field extends moodle_html_component {
+    public $disabled = false;
     /**
-     * @var string $name The name attribute of the field
+     * @var integer if non-zero, sets the tabindex attribute on the <select> element. Default 0.
      */
-    public $name;
+    public $tabindex = 0;
     /**
-     * @var string $value The value attribute of the field
+     * @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 $value;
+    public $listbox = false;
     /**
-     * @var string $type The type attribute of the field (text, submit, checkbox etc)
+     * @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 $type;
+    public $maxautosize = 10;
     /**
-     * @var string $maxlength The maxlength attribute of the field (only applies to text type)
+     * @var boolean if true, allow multiple selection. Only used if $listbox is true, or if
+     *      the select is to be output as checkboxes.
      */
-    public $maxlength;
+    public $multiple = false;
     /**
-     * @var mixed $label The label for that component. String or html_label object
+     * 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 $label;
-
-    public function __construct() {
-        $this->label = new html_label();
-    }
+    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() {
-        if (empty($this->style)) {
-            $this->style = 'width: 4em;';
-        }
+        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->generate_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();
     }
 
     /**
-     * Shortcut for creating a text input component.
-     * @param string $name    The name of the text field
-     * @param string $value   The value of the text field
-     * @param string $alt     The info to be inserted in the alt tag
-     * @param int $maxlength Sets the maxlength attribute of the field. Not set by default
-     * @return html_field The field component
+     * 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_text($name='unnamed', $value, $alt, $maxlength=0) {
-        $field = new html_field();
-        if (empty($alt)) {
-            $alt = get_string('textfield');
-        }
-        $field->type = 'text';
-        $field->name = $name;
-        $field->value = $value;
-        $field->alt = $alt;
-        $field->maxlength = $maxlength;
-        return $field;
+    public static function make($options, $name, $selected = '') {
+        $menu = new html_select();
+        $menu->options = $options;
+        $menu->name = $name;
+        $menu->selectedvalue = $selected;
+        return $menu;
     }
-}
 
-/**
- * Holds all the information required to render a <table> by
- * {@see moodle_core_renderer::table()} or by an overridden version of that
- * method in a subclass.
- *
- * Example of usage:
- * $t = new html_table();
- * ... // set various properties of the object $t as described below
- * echo $OUTPUT->table($t);
- *
- * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since     Moodle 2.0
- */
-class html_table extends moodle_html_component {
     /**
-     * @var array of headings. The n-th array item is used as a heading of the n-th column.
-     *
-     * Example of usage:
-     * $t->head = array('Student', 'Grade');
+     * 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 $head;
+    public static function make_yes_no($name, $selected) {
+        return self::make(array(0 => get_string('no'), 1 => get_string('yes')), $name, $selected);
+    }
+
     /**
-     * @var array can be used to make a heading span multiple columns
-     *
-     * Example of usage:
-     * $t->headspan = array(2,1);
-     *
-     * In this example, {@see html_table:$data} is supposed to have three columns. For the first two columns,
-     * the same heading is used. Therefore, {@see html_table::$head} should consist of two items.
+     * 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 $headspan;
-    /**
-     * @var array of column alignments. The value is used as CSS 'text-align' property. Therefore, possible
-     * values are 'left', 'right', 'center' and 'justify'. Specify 'right' or 'left' from the perspective
-     * of a left-to-right (LTR) language. For RTL, the values are flipped automatically.
-     *
+    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
+ *
+ * @copyright 2009 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.0
+ */
+class html_select_option extends moodle_html_component {
+    /**
+     * @var string $value The value of this option (will be sent with form)
+     */
+    public $value;
+    /**
+     * @var string $text The display value of the option
+     */
+    public $text;
+    /**
+     * @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()
+     * @return void
+     */
+    public function 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);
+        }
+        if (empty($this->id)) {
+            $this->generate_id();
+        }
+
+        parent::prepare();
+    }
+
+    /**
+     * Shortcut for making a checkbox-ready option
+     * @param string $value The value of the checkbox
+     * @param boolean $checked
+     * @param string $label
+     * @param string $alt
+     * @return html_select_option A component ready for $OUTPUT->checkbox()
+     */
+    public function make_checkbox($value, $checked, $label='', $alt='') {
+        $checkbox = new html_select_option();
+        $checkbox->value = $value;
+        $checkbox->selected = $checked;
+        $checkbox->text = $label;
+        $checkbox->label->text = $label;
+        $checkbox->alt = $alt;
+        return $checkbox;
+    }
+}
+
+/**
+ * This class represents a select optgroup element
+ *
+ * @copyright 2009 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.0
+ */
+class html_select_optgroup extends moodle_html_component {
+    /**
+     * @var string $text The display value of the optgroup
+     */
+    public $text;
+    /**
+     * @var array $options An array of html_select_option objects
+     */
+    public $options = array();
+
+    public function prepare() {
+        if (empty($this->text)) {
+            throw new coding_exception('html_select_optgroup requires a $text value.');
+        }
+        if (empty($this->options)) {
+            throw new coding_exception('html_select_optgroup requires at least one html_select_option object');
+        }
+        parent::prepare();
+    }
+}
+
+/**
+ * This class represents an input field
+ *
+ * @copyright 2009 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.0
+ */
+class html_field extends moodle_html_component {
+    /**
+     * @var string $name The name attribute of the field
+     */
+    public $name;
+    /**
+     * @var string $value The value attribute of the field
+     */
+    public $value;
+    /**
+     * @var string $type The type attribute of the field (text, submit, checkbox etc)
+     */
+    public $type;
+    /**
+     * @var string $maxlength The maxlength attribute of the field (only applies to text type)
+     */
+    public $maxlength;
+    /**
+     * @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()
+     * @return void
+     */
+    public function prepare() {
+        if (empty($this->style)) {
+            $this->style = 'width: 4em;';
+        }
+        if (empty($this->id)) {
+            $this->generate_id();
+        }
+        parent::prepare();
+    }
+
+    /**
+     * Shortcut for creating a text input component.
+     * @param string $name    The name of the text field
+     * @param string $value   The value of the text field
+     * @param string $alt     The info to be inserted in the alt tag
+     * @param int $maxlength Sets the maxlength attribute of the field. Not set by default
+     * @return html_field The field component
+     */
+    public static function make_text($name='unnamed', $value, $alt, $maxlength=0) {
+        $field = new html_field();
+        if (empty($alt)) {
+            $alt = get_string('textfield');
+        }
+        $field->type = 'text';
+        $field->name = $name;
+        $field->value = $value;
+        $field->alt = $alt;
+        $field->maxlength = $maxlength;
+        return $field;
+    }
+}
+
+/**
+ * Holds all the information required to render a <table> by
+ * {@see moodle_core_renderer::table()} or by an overridden version of that
+ * method in a subclass.
+ *
+ * Example of usage:
+ * $t = new html_table();
+ * ... // set various properties of the object $t as described below
+ * echo $OUTPUT->table($t);
+ *
+ * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.0
+ */
+class html_table extends moodle_html_component {
+    /**
+     * @var array of headings. The n-th array item is used as a heading of the n-th column.
+     *
+     * Example of usage:
+     * $t->head = array('Student', 'Grade');
+     */
+    public $head;
+    /**
+     * @var array can be used to make a heading span multiple columns
+     *
+     * Example of usage:
+     * $t->headspan = array(2,1);
+     *
+     * In this example, {@see html_table:$data} is supposed to have three columns. For the first two columns,
+     * the same heading is used. Therefore, {@see html_table::$head} should consist of two items.
+     */
+    public $headspan;
+    /**
+     * @var array of column alignments. The value is used as CSS 'text-align' property. Therefore, possible
+     * values are 'left', 'right', 'center' and 'justify'. Specify 'right' or 'left' from the perspective
+     * of a left-to-right (LTR) language. For RTL, the values are flipped automatically.
+     *
      * Examples of usage:
      * $t->align = array(null, 'right');
      * or
@@ -632,866 +1094,404 @@ class html_table extends moodle_html_component {
     public function __set($name, $value) {
         if ($name == 'rowclass') {
             debugging('rowclass[] has been deprecated for html_table ' .
-                      'and should be replaced with rowclasses[]. please fix the code.');
-            $this->rowclasses = $value;
-        } else {
-            parent::__set($name, $value);
-        }
-    }
-}
-
-/**
- * Component representing a table row.
- *
- * @copyright 2009 Nicolas Connault
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since     Moodle 2.0
- */
-class html_table_row extends moodle_html_component {
-    /**
-     * @var array $cells Array of html_table_cell objects
-     */
-    public $cells = array();
-
-    /**
-     * @see lib/moodle_html_component#prepare()
-     * @return void
-     */
-    public function prepare() {
-        parent::prepare();
-    }
-}
-
-/**
- * Component representing a table cell.
- *
- * @copyright 2009 Nicolas Connault
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since     Moodle 2.0
- */
-class html_table_cell extends moodle_html_component {
-    /**
-     * @var string $text The contents of the cell
-     */
-    public $text;
-    /**
-     * @var string $abbr Abbreviated version of the contents of the cell
-     */
-    public $abbr = '';
-    /**
-     * @var int $colspan Number of columns this cell should span
-     */
-    public $colspan = '';
-    /**
-     * @var int $rowspan Number of rows this cell should span
-     */
-    public $rowspan = '';
-    /**
-     * @var string $scope Defines a way to associate header cells and data cells in a table
-     */
-    public $scope = '';
-
-    /**
-     * @see lib/moodle_html_component#prepare()
-     * @return void
-     */
-    public function prepare() {
-        parent::prepare();
-    }
-}
-
-/**
- * Component representing a XHTML link.
- *
- * @copyright 2009 Nicolas Connault
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since     Moodle 2.0
- */
-class html_link extends moodle_html_component {
-    /**
-     * URL can be simple text or a moodle_url object
-     * @var mixed $url
-     */
-    public $url;
-
-    /**
-     * @var string $text The text that will appear between the link tags
-     */
-    public $text;
-
-    /**
-     * @see lib/moodle_html_component#prepare()
-     * @return void
-     */
-    public function prepare() {
-        // We can't accept an empty text value
-        if (empty($this->text)) {
-            throw new coding_exception('A html_link must have a descriptive text value!');
-        }
-
-        parent::prepare();
-    }
-
-    /**
-     * Shortcut for creating a link component.
-     * @param mixed  $url String or moodle_url
-     * @param string $text The text of the link
-     * @return html_link The link component
-     */
-    public function make($url, $text) {
-        $link = new html_link();
-        $link->url = $url;
-        $link->text = $text;
-        return $link;
-    }
-}
-
-/**
- * Component representing a XHTML button (input of type 'button').
- * The renderer will either output it as a button with an onclick event,
- * or as a form with hidden inputs.
- *
- * @copyright 2009 Nicolas Connault
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since     Moodle 2.0
- */
-class html_button extends moodle_html_component {
-    /**
-     * @var string $text
-     */
-    public $text;
-
-    /**
-     * @var boolean $disabled Whether or not this button is disabled
-     */
-    public $disabled = false;
-
-    /**
-     * @see lib/moodle_html_component#prepare()
-     * @return void
-     */
-    public function prepare() {
-        $this->add_class('singlebutton');
-
-        if (empty($this->text)) {
-            throw new coding_exception('A html_button must have a text value!');
-        }
-
-        if ($this->disabled) {
-            $this->disabled = 'disabled';
+                      'and should be replaced with rowclasses[]. please fix the code.');
+            $this->rowclasses = $value;
+        } else {
+            parent::__set($name, $value);
         }
-
-        parent::prepare();
     }
 }
 
 /**
- * Component representing an image.
+ * Component representing a table row.
  *
  * @copyright 2009 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since     Moodle 2.0
  */
-class html_image extends moodle_html_component {
-    /**
-     * @var string $alt A descriptive text
-     */
-    public $alt = HTML_ATTR_EMPTY;
+class html_table_row extends moodle_html_component {
     /**
-     * @var string $src The path to the image being used
+     * @var array $cells Array of html_table_cell objects
      */
-    public $src;
+    public $cells = array();
 
     /**
      * @see lib/moodle_html_component#prepare()
      * @return void
      */
     public function prepare() {
-        $this->add_class('image');
         parent::prepare();
     }
 }
 
 /**
- * Component representing a textarea.
+ * Component representing a table cell.
  *
  * @copyright 2009 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since     Moodle 2.0
  */
-class html_textarea extends moodle_html_component {
+class html_table_cell extends moodle_html_component {
     /**
-     * @param string $name Name to use for the textarea element.
+     * @var string $text The contents of the cell
      */
-    public $name;
+    public $text;
     /**
-     * @param string $value Initial content to display in the textarea.
+     * @var string $abbr Abbreviated version of the contents of the cell
      */
-    public $value;
+    public $abbr = '';
     /**
-     * @param int $rows Number of rows to display  (minimum of 10 when $height is non-null)
+     * @var int $colspan Number of columns this cell should span
      */
-    public $rows;
+    public $colspan = '';
     /**
-     * @param int $cols Number of columns to display (minimum of 65 when $width is non-null)
+     * @var int $rowspan Number of rows this cell should span
      */
-    public $cols;
+    public $rowspan = '';
     /**
-     * @param bool $usehtmleditor Enables the use of the htmleditor for this field.
+     * @var string $scope Defines a way to associate header cells and data cells in a table
      */
-    public $usehtmleditor;
+    public $scope = '';
 
     /**
      * @see lib/moodle_html_component#prepare()
      * @return void
      */
     public function prepare() {
-        $this->add_class('form-textarea');
-
-        if (empty($this->id)) {
-            $this->id = "edit-$this->name";
-        }
-
-        if ($this->usehtmleditor) {
-            editors_head_setup();
-            $editor = get_preferred_texteditor(FORMAT_HTML);
-            $editor->use_editor($this->id, array('legacy'=>true));
-            $this->value = htmlspecialchars($value);
-        }
-
         parent::prepare();
     }
 }
 
 /**
- * Component representing a simple form wrapper. Its purpose is mainly to enclose
- * a submit input with the appropriate action and hidden inputs.
+ * Component representing a XHTML link.
  *
  * @copyright 2009 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since     Moodle 2.0
  */
-class html_form extends moodle_html_component {
-    /**
-     * @var string $method post or get
-     */
-    public $method = 'post';
+class html_link extends moodle_html_component {
     /**
-     * If a string is given, it will be converted to a moodle_url during prepare()
-     * @var mixed $url A moodle_url including params or a string
+     * URL can be simple text or a moodle_url object
+     * @var mixed $url
      */
     public $url;
-    /**
-     * @var array $params Optional array of parameters. Ignored if $url instanceof moodle_url
-     */
-    public $params = array();
-    /**
-     * @var boolean $showbutton If true, the submit button will always be shown even if JavaScript is available
-     */
-    public $showbutton = false;
-    /**
-     * @var string $targetwindow The name of the target page to open the linked page in.
-     */
-    public $targetwindow = 'self';
-    /**
-     * @var html_button $button A submit button
-     */
-    public $button;
 
     /**
-     * Constructor: sets up the other components in case they are needed
-     * @return void
+     * @var string $text The text that will appear between the link tags
      */
-    public function __construct() {
-        static $yes;
-        $this->button = new html_button();
-        if (!isset($yes)) {
-            $yes = get_string('yes');
-            $this->button->text = $yes;
-        }
-    }
+    public $text;
 
     /**
      * @see lib/moodle_html_component#prepare()
      * @return void
      */
     public function prepare() {
-
-        if (empty($this->url)) {
-            throw new coding_exception('A html_form must have a $url value (string or moodle_url).');
-        }
-
-        if (!($this->url instanceof moodle_url)) {
-            $this->url = new moodle_url($this->url, $this->params);
-        }
-
-        if ($this->method == 'post') {
-            $this->url->param('sesskey', sesskey());
+        // We can't accept an empty text value
+        if (empty($this->text)) {
+            throw new coding_exception('A html_link must have a descriptive text value!');
         }
 
         parent::prepare();
     }
-}
-
-/**
- * Component representing a list.
- *
- * The advantage of using this object instead of a flat array is that you can load it
- * with metadata (CSS classes, event handlers etc.) which can be used by the renderers.
- *
- * @copyright 2009 Nicolas Connault
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since     Moodle 2.0
- */
-class html_list extends moodle_html_component {
-
-    /**
-     * @var array $items An array of html_list_item or html_list objects
-     */
-    public $items = array();
-
-    /**
-     * @var string $type The type of list (ordered|unordered), definition type not yet supported
-     */
-    public $type = 'unordered';
-
-    /**
-     * @see lib/moodle_html_component#prepare()
-     * @return void
-     */
-    public function prepare() {
-        parent::prepare();
-    }
-
-    /**
-     * This function takes a nested array of data and maps it into this list's $items array
-     * as proper html_list_item and html_list objects, with appropriate metadata.
-     *
-     * @param array $tree A nested array (array keys are ignored);
-     * @param int $row Used in identifying the iteration level and in ul classes
-     * @return void
-     */
-    public function load_data($tree, $level=0) {
-
-        $this->add_class("list-$level");
-
-        foreach ($tree as $key => $element) {
-            if (is_array($element)) {
-                $newhtmllist = new html_list();
-                $newhtmllist->load_data($element, $level + 1);
-                $this->items[] = $newhtmllist;
-            } else {
-                $listitem = new html_list_item();
-                $listitem->value = $element;
-                $listitem->add_class("list-item-$level-$key");
-                $this->items[] = $listitem;
-            }
-        }
-    }
 
     /**
-     * Adds a html_list_item or html_list to this list.
-     * If the param is a string, a html_list_item will be added.
-     * @param mixed $item String, html_list or html_list_item object
-     * @return void
+     * Shortcut for creating a link component.
+     * @param mixed  $url String or moodle_url
+     * @param string $text The text of the link
+     * @return html_link The link component
      */
-    public function add_item($item) {
-        if ($item instanceof html_list_item || $item instanceof html_list) {
-            $this->items[] = $item;
-        } else {
-            $listitem = new html_list_item();
-            $listitem->value = $item;
-            $this->items[] = $item;
-        }
+    public function make($url, $text) {
+        $link = new html_link();
+        $link->url = $url;
+        $link->text = $text;
+        return $link;
     }
 }
 
 /**
- * Component representing a list item.
+ * Component representing a XHTML button (input of type 'button').
+ * The renderer will either output it as a button with an onclick event,
+ * or as a form with hidden inputs.
  *
  * @copyright 2009 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since     Moodle 2.0
  */
-class html_list_item extends moodle_html_component {
-    /**
-     * @var string $value The value of the list item
-     */
-    public $value;
-
+class html_button extends moodle_html_component {
     /**
-     * @see lib/moodle_html_component#prepare()
-     * @return void
+     * @var string $text
      */
-    public function prepare() {
-        parent::prepare();
-    }
-}
-
-/// Complex components aggregating simpler components
+    public $text;
 
-/**
- * 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.
+     * @var boolean $disabled Whether or not this button is disabled
      */
     public $disabled = false;
+
     /**
-     * @var integer if non-zero, sets the tabindex attribute on the <select> element. Default 0.
+     * @see lib/moodle_html_component#prepare()
+     * @return void
      */
-    public $tabindex = 0;
+    public function prepare() {
+        $this->add_class('singlebutton');
+
+        if (empty($this->text)) {
+            throw new coding_exception('A html_button must have a text value!');
+        }
+
+        if ($this->disabled) {
+            $this->disabled = 'disabled';
+        }
+
+        parent::prepare();
+    }
+}
+
+/**
+ * Component representing an image.
+ *
+ * @copyright 2009 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.0
+ */
+class html_image extends moodle_html_component {
     /**
-     * @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.
+     * @var string $alt A descriptive text
      */
-    public $listbox = false;
+    public $alt = HTML_ATTR_EMPTY;
     /**
-     * @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.
+     * @var string $src The path to the image being used
      */
-    public $maxautosize = 10;
+    public $src;
+
     /**
-     * @var boolean if true, allow multiple selection. Only used if $listbox is true, or if
-     *      the select is to be output as checkboxes.
+     * @see lib/moodle_html_component#prepare()
+     * @return void
      */
-    public $multiple = false;
+    public function prepare() {
+        $this->add_class('image');
+        parent::prepare();
+    }
+}
+
+/**
+ * Component representing a textarea.
+ *
+ * @copyright 2009 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.0
+ */
+class html_textarea extends moodle_html_component {
     /**
-     * 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)
+     * @param string $name Name to use for the textarea element.
      */
-    public $nested = false;
+    public $name;
     /**
-     * @var html_form $form An optional html_form component
+     * @param string $value Initial content to display in the textarea.
      */
-    public $form;
+    public $value;
     /**
-     * @var moodle_help_icon $form An optional moodle_help_icon component
+     * @param int $rows Number of rows to display  (minimum of 10 when $height is non-null)
      */
-    public $helpicon;
+    public $rows;
     /**
-     * @var boolean $rendertype How the select element should be rendered: menu or radio (checkbox is just radio + multiple)
+     * @param int $cols Number of columns to display (minimum of 65 when $width is non-null)
      */
-    public $rendertype = 'menu';
+    public $cols;
+    /**
+     * @param bool $usehtmleditor Enables the use of the htmleditor for this field.
+     */
+    public $usehtmleditor;
 
     /**
-     * @see moodle_html_component::prepare()
+     * @see lib/moodle_html_component#prepare()
      * @return void
      */
     public function prepare() {
-        global $CFG;
+        $this->add_class('form-textarea');
 
-        // 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');
+            $this->id = "edit-$this->name";
         }
 
-        if (!empty($this->label) && !($this->label instanceof html_label)) {
-            $label = new html_label();
-            $label->text = $this->label;
-            $label->for = $this->name;
-            $this->label = $label;
+        if ($this->usehtmleditor) {
+            editors_head_setup();
+            $editor = get_preferred_texteditor(FORMAT_HTML);
+            $editor->use_editor($this->id, array('legacy'=>true));
+            $this->value = htmlspecialchars($value);
         }
 
-        $this->add_class('select');
-
-        $this->initialise_options();
         parent::prepare();
     }
+}
 
+/**
+ * Component representing a simple form wrapper. Its purpose is mainly to enclose
+ * a submit input with the appropriate action and hidden inputs.
+ *
+ * @copyright 2009 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.0
+ */
+class html_form extends moodle_html_component {
     /**
-     * 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.
+     * @var string $method post or get
      */
-    public static function make($options, $name, $selected = '') {
-        $menu = new moodle_select();
-        $menu->options = $options;
-        $menu->name = $name;
-        $menu->selectedvalue = $selected;
-        return $menu;
-    }
-
+    public $method = 'post';
     /**
-     * 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.
+     * If a string is given, it will be converted to a moodle_url during prepare()
+     * @var mixed $url A moodle_url including params or a string
      */
-    public static function make_yes_no($name, $selected) {
-        return self::make(array(0 => get_string('no'), 1 => get_string('yes')), $name, $selected);
-    }
-
+    public $url;
     /**
-     * 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.
+     * @var array $params Optional array of parameters. Ignored if $url instanceof moodle_url
      */
-    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;
-    }
+    public $params = array();
+    /**
+     * @var boolean $showbutton If true, the submit button will always be shown even if JavaScript is available
+     */
+    public $showbutton = false;
+    /**
+     * @var string $targetwindow The name of the target page to open the linked page in.
+     */
+    public $targetwindow = 'self';
+    /**
+     * @var html_button $button A submit button
+     */
+    public $button;
 
     /**
-     * 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
+     * Constructor: sets up the other components in case they are needed
+     * @return void
      */
-    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);
+    public function __construct() {
+        static $yes;
+        $this->button = new html_button();
+        if (!isset($yes)) {
+            $yes = get_string('yes');
+            $this->button->text = $yes;
         }
-        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.
+     * @see lib/moodle_html_component#prepare()
+     * @return void
      */
-    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);
-        }
+    public function prepare() {
 
-        if (!empty($selected)) {
-            $selectedurl = $baseurl->out(false, array($name => $selected), false);
+        if (empty($this->url)) {
+            throw new coding_exception('A html_form must have a $url value (string or moodle_url).');
         }
 
-        if (!($baseurl instanceof moodle_url)) {
-            $baseurl = new moodle_url($baseurl);
+        if (!($this->url instanceof moodle_url)) {
+            $this->url = new moodle_url($this->url, $this->params);
         }
 
-        // Replace real value by formatted URLs
-        foreach ($options as $value => $label) {
-            $options[$baseurl->out(false, array($name => $value), false)] = $label;
-            unset($options[$value]);
+        if ($this->method == 'post') {
+            $this->url->param('sesskey', sesskey());
         }
 
-        $select = self::make($options, 'jump', $selectedurl);
+        parent::prepare();
+    }
+}
 
-        $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');
+/**
+ * Component representing a list.
+ *
+ * The advantage of using this object instead of a flat array is that you can load it
+ * with metadata (CSS classes, event handlers etc.) which can be used by the renderers.
+ *
+ * @copyright 2009 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.0
+ */
+class html_list extends moodle_html_component {
 
-        $select->id = $formid . '_jump';
+    /**
+     * @var array $items An array of html_list_item or html_list objects
+     */
+    public $items = array();
 
-        $select->add_action('change', 'submit_form_by_id', array('id' => $formid, 'selectid' => $select->id));
+    /**
+     * @var string $type The type of list (ordered|unordered), definition type not yet supported
+     */
+    public $type = 'unordered';
 
-        return $select;
+    /**
+     * @see lib/moodle_html_component#prepare()
+     * @return void
+     */
+    public function prepare() {
+        parent::prepare();
     }
 
     /**
-     * Override the URLs of the default popup_form, which only supports one base URL
-     * @param array $options value=>label pairs representing select options
+     * This function takes a nested array of data and maps it into this list's $items array
+     * as proper html_list_item and html_list objects, with appropriate metadata.
+     *
+     * @param array $tree A nested array (array keys are ignored);
+     * @param int $row Used in identifying the iteration level and in ul classes
      * @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));
+    public function load_data($tree, $level=0) {
 
-                    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));
+        $this->add_class("list-$level");
 
-                if ($optionurl->compare($PAGE->url, URL_MATCH_PARAMS)) {
-                    $this->options[$optkey]->selected = 'selected';
-                }
+        foreach ($tree as $key => $element) {
+            if (is_array($element)) {
+                $newhtmllist = new html_list();
+                $newhtmllist->load_data($element, $level + 1);
+                $this->items[] = $newhtmllist;
+            } else {
+                $listitem = new html_list_item();
+                $listitem->value = $element;
+                $listitem->add_class("list-item-$level-$key");
+                $this->items[] = $listitem;
             }
         }
     }
 
     /**
-     * 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
+     * Adds a html_list_item or html_list to this list.
+     * If the param is a string, a html_list_item will be added.
+     * @param mixed $item String, html_list or html_list_item object
      * @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;
+    public function add_item($item) {
+        if ($item instanceof html_list_item || $item instanceof html_list) {
+            $this->items[] = $item;
+        } else {
+            $listitem = new html_list_item();
+            $listitem->value = $item;
+            $this->items[] = $item;
         }
     }
+}
 
+/**
+ * Component representing a list item.
+ *
+ * @copyright 2009 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.0
+ */
+class html_list_item extends moodle_html_component {
     /**
-     * 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;
+     * @var string $value The value of the list item
      */
-    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;
-                    }
-                }
-            }
+    public $value;
 
-            if ($optgroup) {
-                $this->options[] = $optgroup;
-            }
-        }
+    /**
+     * @see lib/moodle_html_component#prepare()
+     * @return void
+     */
+    public function prepare() {
+        parent::prepare();
     }
 }
 
+/// Complex components aggregating simpler components
+
 /**
  * Component representing a paging bar.
  *
index f16adeec72f8d11df54d2ab8507288e053c74f60..6213bd9e3f6470a7a363ab831935e35dea5e3aa9 100644 (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) {
index 862bb137bca9b2e64487339e76ea32e1301d7fd8..78fcbe5a1624d551ebfcea365a834c29aac2a156 100644 (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);
index 851dd5bf3db5cbb00fedae5b726394bf2fe54264..88da5790fe2e7aa5f72a51a5e844154f88065998 100644 (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);
index 80f9789acfe7d8e76179ea44b0245a9832541ffd..15881359e6f995a859ce079b1cf28e4a5f7f2b68 100644 (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);
index ca9e834ab3f3f9b409c4fe3e78a335e8d1024b8c..50ad0985ef8450216fd1afee45e6d9c2ac2d498b 100644 (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);
index 1d2e45640100d476789aead3fdc858cae6c20123..82b2c737e23360dd71b1c5be12bdf5ea715629a2 100644 (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);
     }
index 0b633c407b46fadc4b436183f30ec48d8d584c19..105455b8cce5264383f34afbb565b4ed375ecbf8 100644 (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');
index 197d3dc6bc98adb117ac392248cb886b588211c4..6f3e84e72f9324f30e85d384b707d4313d2c6ee3 100755 (executable)
         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>';
 
index aee7a7297f471c09ce3321acbe6fbf587736d87d..4b5a85a2e71c2e7b196a34b1dd9d1b2dd311ea7d 100755 (executable)
@@ -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>';
 
index 664a42c5f150ab6d157c5d60971bc3399a5fa68c..2dc0187b44444717817a2a579957b73dbaf81135 100644 (file)
         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;
index 562929a12e5c21b03e0810fa95f0328605343dd2..8c3fb7c85332f02626c701e83e3155faf4ac53ee 100644 (file)
             }
             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');
 
index f6d94a869b55f624182dd850b92863fb5e22feb5..d8d6348c1f45dffaad71b41658480965bdbb9c9f 100644 (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') {
index 57cc06fa37c6dd53fd56eda7b2f0112c6cc2c37b..381aa5c33fc308deed573c8a17c3cea13771866c 100644 (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);
     }
index 3c2591a38832a288e772105d9908a71901692b52..84466143e990bd13a6408dd19ebce7c014d139dd 100644 (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);
 
index 64734b4834be236a710b51eee096e591a6a14421..af8b35371832f363d184fb9905dc2aaeb72b5668 100644 (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);
index d60bfd749b5f08aa92feab7e3b639676f07d699e..56b1315450b3f2e3bcae3a58c92c624a558768da 100644 (file)
                  '<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;
index 670755d8f47b15349e3a48120fd479582c932758..d7c34255c1adbe4e4886506d05fbf82f9398bbee 100644 (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){
index 728abd9bcc294f32d3a09d8c2a008d8901a9cd88..fd8e0f8f783eebfc1a65ef83c1edfd3e69e23b7a 100644 (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);
 
index 116a2b6b12ccc9c7006b5afe0d2fb381e27b882d..c07b547d6902b8fa9f6b5791d8e5862fef70a869 100644 (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);
 
index f7fa4d50a7998719a150830f41f1c91ac696ea4b..f1821a7fb94e203149aa719f7fc20406200456c8 100644 (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);
 
index e4aacf556b425dcba66ae90136de75e2b7e21dba..d4ebf3f374894ac3cd74bf443522eea01d034eb2 100755 (executable)
@@ -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;
index c1ca80dc242e439b701bb6fb99fc8f29522fea36..c259e80f4cd77ea06a1b5bd648fc86b5ed69b5fe 100755 (executable)
                     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');
index 7b9a2aa53392674cc164dd9e2393ff41d2f5b164..6aaf3c8d297802363eb464b3f5aefe26c045af34 100644 (file)
         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;
index c5a53a1d57cf9df12d29159f9b78bcae3249d450..21583497fc76139f25dcab640051715d2b664250 100644 (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);
 }
index 47cd5284d3abba8d406b5fb71499934e7ddff2ba..6eda2131ca9051dff40cc68db1997a4b08e15c13 100644 (file)
 
         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;
index 628f9b99f9a88c5f980d294e5197a01260fb71f8..21d92a3da72dc7fdb27d903e3bf6d9e3c1a5245b 100644 (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);
index f833bc72bf21a5621cc8d63003c1e03c1785c8a5..52388bca57db679735c41bf0b8dd75fcac289211 100644 (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);
index 6bed589d3290f5b3fbfe7f4064dd0676f8004ccd..03b5593f89e8137b113c70c97fdadf6f9870752f 100644 (file)
             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>';
 
         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>';
     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);
                 $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>';
         }
 
         helpbutton("participantswithselectedusers", get_string("withselectedusers"));
-        $select = new moodle_select();
+        $select = new html_select();
         $select->options = $displaylist;
         $select->name = "formaction";
         $select->label = get_string("withselectedusers");
index 2eb6283243ade9f53a68abc7634ac706ab609247..0a6f6df4f0c4b27438809f045d0a49c2f2335321 100644 (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');