Skip to content

Commit

Permalink
MDL-20204 a lot more steps away from html_select
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Feb 10, 2010
1 parent 94a9b9e commit f8dab96
Show file tree
Hide file tree
Showing 23 changed files with 100 additions and 106 deletions.
5 changes: 2 additions & 3 deletions course/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,9 @@
make_categories_list($displaylist, $notused);

echo '<div class="categorypicker">';
$select = html_select::make_popup_form('category.php', 'id', $displaylist, 'switchcategory', $category->id);
$select = new single_select(new moodle_url('category.php'), 'id', $displaylist, $category->id, null, 'switchcategory');
$select->set_label($strcategories.':');
$select->nothinglabel = false;
echo $OUTPUT->select($select);
echo $OUTPUT->render($select);
echo '</div>';

/// Print current category description
Expand Down
7 changes: 3 additions & 4 deletions course/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,9 @@ function print_category_edit($category, $displaylist, $parentslist, $depth=-1, $
unset($tempdisplaylist[$key]);
}
}
$popupurl = "index.php?move=$category->id&sesskey=".sesskey();
$select = html_select::make_popup_form($popupurl, 'moveto', $tempdisplaylist, "moveform$category->id", $category->parent);
$select->nothinglabel = false;
echo $OUTPUT->select($select);
$popupurl = new moodle_url("index.php?move=$category->id&sesskey=".sesskey());
$select = new single_select($popupurl, 'moveto', $tempdisplaylist, $category->parent, null, "moveform$category->id");
echo $OUTPUT->render($select);
}
echo '</td>';
echo '</tr>';
Expand Down
6 changes: 3 additions & 3 deletions course/report/stats/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ function report_stats_mode_menu($course, $mode, $time, $url) {
$options[STATS_MODE_RANKED] = get_string('reports');
}
$popupurl = $url."?course=$course->id&time=$time";
$select = html_select::make_popup_form($popupurl, 'mode', $options, 'switchmode', $mode);
$select->nothinglabel = false;
return $OUTPUT->select($select);
$select = new single_select(new moodle_url($popupurl), 'mode', $options, $mode, null);
$select->formid = 'switchmode';
echo $OUTPUT->render($select);
}


Expand Down
6 changes: 3 additions & 3 deletions enrol/authorize/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(html_select::make_popup_form($baseurl.'&status='.$status, 'course', $popupcrs, 'coursesmenu', $courseid));
$popupmenu = empty($popupcrs) ? '' : $OUTPUT->single_select(new moodle_url($baseurl.'&status='.$status), 'course', $popupcrs, $courseid, null, 'coursesmenu');
$popupmenu .= '<br />';
$statusmenu = array(
AN_STATUS_NONE => $strs->all,
Expand All @@ -66,7 +66,7 @@ function authorize_print_orders($courseid, $userid) {
AN_STATUS_TEST => $authstrs->tested
);

$popupmenu .= $OUTPUT->select(html_select::make_popup_form($baseurl.'&course='.$courseid, 'status', $statusmenu, 'statusmenu', $status));
$popupmenu .= $OUTPUT->single_select(new moodle_url($baseurl.'&course='.$courseid), 'status', $statusmenu, $status, null, 'statusmenu');
if ($canmanagepayments) {
$popupmenu .= '<br />';
$id = html_writer::random_id('ea');
Expand Down Expand Up @@ -94,7 +94,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(html_select::make_popup_form($baseurl.'&status='.$status.'&course='.$courseid, 'perpage',$perpagemenus,'perpagemenu',$perpage));
$perpagemenu = $OUTPUT->single_select(new moodle_url($baseurl.'&status='.$status.'&course='.$courseid), 'perpage', $perpagemenus, $perpage, array(''=>'choosedots'), 'perpagemenu');
$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");
Expand Down
7 changes: 4 additions & 3 deletions grade/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,10 @@ function print_graded_users_selector($course, $actionpage, $userid=0, $groupid=0
if ($includeall) {
$menu[0] .= " (" . (count($menu) - 1) . ")";
}
$select = html_select::make_popup_form($CFG->wwwroot.'/grade/' . $actionpage, 'userid', $menu, 'choosegradeuser', $userid);
$select->set_label($label);
return $OUTPUT->select($select);
$select = new single_select(new moodle_url('/grade/'.$actionpage), 'userid', $menu, $userid);
$select->label = $label;
$select->formid = 'choosegradeuser';
return $OUTPUT->render($select);
}

/**
Expand Down
18 changes: 10 additions & 8 deletions group/overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,23 @@
foreach ($groupings as $grouping) {
$options[$grouping->id] = strip_tags(format_string($grouping->name));
}
$popupurl = $rooturl.'&group='.$groupid;
$select = html_select::make_popup_form($popupurl, 'grouping', $options, 'selectgrouping', $groupingid);
$select->set_label($strgrouping);
echo $OUTPUT->select($select);
$popupurl = new moodle_url($rooturl.'&group='.$groupid);
$select = new single_select($popupurl, 'grouping', $options, $groupingid);
$select->label = $strgrouping;
$select->formid = 'selectgrouping';
echo $OUTPUT->render($select);
}

$options = array();
$options[0] = get_string('all');
foreach ($groups as $group) {
$options[$group->id] = strip_tags(format_string($group->name));
}
$popupurl = $rooturl.'&grouping='.$groupingid;
$select = html_select::make_popup_form($popupurl, 'group', $options, 'selectgroup', $groupid);
$select->set_label($strgroup);
echo $OUTPUT->select($select);
$popupurl = new moodle_url($rooturl.'&grouping='.$groupingid);
$select = new single_select($popupurl, 'group', $options, $groupid);
$select->label = $strgroup;
$select->formid = 'selectgroup';
echo $OUTPUT->render($select);

/// Print table
$printed = false;
Expand Down
6 changes: 2 additions & 4 deletions lib/blocklib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1445,10 +1445,8 @@ function block_add_block_ui($page, $output) {
asort($menu, SORT_LOCALE_STRING);

$actionurl = new moodle_url($page->url, array('sesskey'=>sesskey()));
$select = html_select::make_popup_form($actionurl, 'bui_addblock', $menu, 'add_block');
$select->nothinglabel = get_string('adddots');

$bc->content = $OUTPUT->select($select);
$select = new single_select($actionurl, 'bui_addblock', $menu, null, array(''=>get_string('adddots')), 'add_block');
$bc->content = $OUTPUT->render($select);
return $bc;
}

Expand Down
14 changes: 6 additions & 8 deletions lib/grouplib.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,9 @@ function groups_print_course_menu($course, $urlroot, $return=false) {
$groupname = reset($groupsmenu);
$output = $grouplabel.': '.$groupname;
} else {
$select = html_select::make_popup_form($urlroot, 'group', $groupsmenu, 'selectgroup', $activegroup);
$select->nothinglabel = false;
$select->set_label($grouplabel);
$output = $OUTPUT->select($select);
$select = new single_select(new moodle_url($urlroot), 'group', $groupsmenu, $activegroup, null, 'selectgroup');
$select->label = $grouplabel;
$output = $OUTPUT->render($select);
}

$output = '<div class="groupselector">'.$output.'</div>';
Expand Down Expand Up @@ -594,10 +593,9 @@ function groups_print_activity_menu($cm, $urlroot, $return=false, $hideallpartic
$groupname = reset($groupsmenu);
$output = $grouplabel.': '.$groupname;
} else {
$select = html_select::make_popup_form($urlroot, 'group', $groupsmenu, 'selectgroup', $activegroup);
$select->nothinglabel = false;
$select->set_label($grouplabel);
$output = $OUTPUT->select($select);
$select = new single_select($urlroot, 'group', $groupsmenu, $activegroup, null, 'selectgroup');
$select->label = $grouplabel;
$output = $OUTPUT->render($select);
}

$output = '<div class="groupselector">'.$output.'</div>';
Expand Down
25 changes: 24 additions & 1 deletion lib/outputcomponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,15 @@ class single_select implements renderable {
* @param array $options list of options
* @param string $selected selected element
* @param array $nothing
* @param string $formid
*/
public function __construct(moodle_url $url, $name, array $options, $selected='', $nothing=array(''=>'choosedots')) {
public function __construct(moodle_url $url, $name, array $options, $selected='', $nothing=array(''=>'choosedots'), $formid=null) {
$this->url = $url;
$this->name = $name;
$this->options = $options;
$this->selected = $selected;
$this->nothing = $nothing;
$this->formid = $formid;
}

/**
Expand All @@ -373,6 +375,27 @@ public function add_confirm_action($confirmmessage) {
public function add_action(component_action $action) {
$this->actions[] = $action;
}

/**
* Constructor: sets up the other components in case they are needed
* @param string $page The keyword that defines a help page
* @param string $title A descriptive text for accesibility only
* @param string $component
* @param bool $linktext add extra text to icon
* @return void
*/
public function set_help_icon($helppage, $title, $component = 'moodle') {
$this->helpicon = new help_icon($helppage, $title, $component);
}

/**
* Set's select lable
* @param string $label
* @return void
*/
public function set_label($label) {
$this->label = $label;
}
}


Expand Down
5 changes: 3 additions & 2 deletions lib/outputrenderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -1088,13 +1088,14 @@ protected function render_single_button(single_button $button) {
* @param array $options list of options
* @param string $selected selected element
* @param array $nothing
* @param string $formid
* @return string HTML fragment
*/
public function single_select($url, $name, array $options, $selected='', $nothing=array(''=>'choosedots')) {
public function single_select($url, $name, array $options, $selected='', $nothing=array(''=>'choosedots'), $formid=null) {
if (!($url instanceof moodle_url)) {
$url = new moodle_url($url);
}
$select = new single_select($url, $url, $name, $options, $selected, $nothing);
$select = new single_select($url, $name, $options, $selected, $nothing, $formid);

return $this->render($select);
}
Expand Down
7 changes: 3 additions & 4 deletions lib/weblib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2283,11 +2283,10 @@ 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 = html_select::make_popup_form($popupurl, 'switchrole', $roles, 'switchrole', '');
$select->nothinglabel = get_string('switchroleto');
$popupurl = new moodle_url('/course/view.php', array('id'=>$courseid, 'sesskey'=>sesskey()));
$select = new single_select($popupurl, 'switchrole', $roles, null, array(''=>get_string('switchroleto')), 'switchrole');
$select->set_help_icon('switchrole', get_string('switchroleto'));
return $OUTPUT->select($select);
return $OUTPUT->render($select);
}

return '';
Expand Down
2 changes: 1 addition & 1 deletion mod/data/field.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@
echo '<div class="fieldadd">';
echo '<label for="fieldform_jump">'.get_string('newfield','data').'</label>';
$popupurl = $CFG->wwwroot.'/mod/data/field.php?d='.$data->id.'&mode=new&sesskey='. sesskey();
echo $OUTPUT->select(html_select::make_popup_form($popupurl, 'newtype', $menufield, "fieldform"));
echo $OUTPUT->single_select(new moodle_url($popupurl), 'newtype', $menufield, null, array(''=>'choosedots'), "fieldform");
echo $OUTPUT->help_icon('fields', get_string('addafield','data'), 'data');
echo '</div>';

Expand Down
10 changes: 3 additions & 7 deletions mod/forum/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4186,16 +4186,12 @@ function forum_print_rating_menu($postid, $userid, $scale, $myrating=NULL) {
*/
function forum_print_mode_form($id, $mode, $forumtype='') {
global $OUTPUT;
$select = html_select::make_popup_form("view.php?f=$id", 'mode', forum_get_layout_modes(), "mode", $mode);
$select->nothinglabel = false;
$select = new single_select(new moodle_url("/mod/forum/view.php", array('f'=>$id)), 'mode', forum_get_layout_modes(), $mode, null, "mode");

if ($forumtype == 'single') {
echo '<div class="forummode">';
echo $OUTPUT->select($select);
echo '</div>';
} else {
echo $OUTPUT->select($select);
$select->class = "forummode";
}
echo $OUTPUT->render($select);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions mod/glossary/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,7 @@ function glossary_print_categories_menu($cm, $glossary, $hook, $category) {
echo '<td align="center" style="width:60%">';
echo '<b>';

$menu = array();
$menu[GLOSSARY_SHOW_ALL_CATEGORIES] = get_string("allcategories","glossary");
$menu[GLOSSARY_SHOW_NOT_CATEGORISED] = get_string("notcategorised","glossary");

Expand Down Expand Up @@ -1537,9 +1538,8 @@ function glossary_print_categories_menu($cm, $glossary, $hook, $category) {
echo '</b></td>';
echo '<td align="center" style="width:20%">';

$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);
$select = new single_select(new moodle_url("/mod/glossary/view.php", array('id'=>$cm->id, 'mode'=>'cat')), 'hook', $menu, $selected, null, "catmenu");
echo $OUTPUT->render($select);

echo '</td>';
echo '</tr>';
Expand Down
5 changes: 2 additions & 3 deletions mod/lesson/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,8 @@ public function page_action_links(lesson_page $page, $printmove, $printaddpage=f
$options[0] = get_string('question', 'lesson');

$addpageurl = new moodle_url('/mod/lesson/editpage.php', array('id'=>$this->page->cm->id, 'pageid'=>$page->id, 'sesskey'=>sesskey()));
$addpageselect = html_select::make_popup_form($addpageurl, 'qtype', $options, 'addpageafter'.$page->id);
$addpageselect->nothinglabel = get_string('addanewpage', 'lesson').'...';
$addpageselector = $this->output->select($addpageselect);
$addpageselect = new single_select($addpageurl, 'qtype', $options, null, array(''=>get_string('addanewpage', 'lesson').'...'), 'addpageafter'.$page->id);
$addpageselector = $this->output->render($addpageselect);
}

foreach ($actions as $key=>$action) {
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/report/grading/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ function display($quiz, $cm, $course) {
if (count($gradeableqs)!=1){
$qurl = fullclone($this->viewurl);
$qurl->remove_params('questionid', 'attemptid', 'gradeall', 'gradeungraded', 'gradenextungraded');
$menu = $OUTPUT->select(html_select::make_popup_form($qurl->out(), 'questionid', $qmenu, 'questionid', $questionid));
$menu = $OUTPUT->single_select($qurl, 'questionid', $qmenu, $questionid, array(''=>'choosedots'), 'questionid');
echo '<div class="mdl-align">'.$menu.'</div>';
}
if (!$questionid){
Expand Down
6 changes: 2 additions & 4 deletions mod/scorm/datamodels/aicclib.php
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,8 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
$result->toc .= html_writer::script('', $CFG->wwwroot.'/mod/scorm/datamodels/scorm_datamodels.js');
}

$url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr;
$select = html_select::make_popup_form($url, 'scoid', $tocmenus, "tocmenu", $sco->id);
$select->nothinglabel = false;
$result->tocmenu = $OUTPUT->select($select);
$url = new moodle_url('/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr);
$result->tocmenu = $OUTPUT->single_select($url, 'scoid', $tocmenus, $sco->id, null, "tocmenu");

return $result;
}
Expand Down
6 changes: 2 additions & 4 deletions mod/scorm/datamodels/scorm_12lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,8 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
$PAGE->requires->js('/mod/scorm/datamodels/scorm_datamodels.js');
}

$url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr;
$select = html_select::make_popup_form($url, 'scoid', $tocmenus, "tocmenu", $sco->id);
$select->nothinglabel = false;
$result->tocmenu = $OUTPUT->select($select);
$url = new moodle_url('/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr);
$result->tocmenu = $OUTPUT->single_select($url, 'scoid', $tocmenus, $sco->id, null, "tocmenu");

return $result;
}
Expand Down
6 changes: 2 additions & 4 deletions mod/scorm/datamodels/scorm_13lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,8 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
$PAGE->requires->js('/mod/scorm/datamodels/scorm_datamodels.js');
}

$url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr;
$select = html_select::make_popup_form($url, 'scoid', $tocmenus, "tocmenu", $sco->id);
$select->nothinglabel = false;
$result->tocmenu = $OUTPUT->select($select);
$url = new moodle_url('/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr);
$result->tocmenu = $OUTPUT->single_select($url, 'scoid', $tocmenus, $sco->id, null, "tocmenu");

return $result;
}
Expand Down
12 changes: 3 additions & 9 deletions mod/wiki/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1527,9 +1527,7 @@ function wiki_print_wikilinks_block($cmid, $binary=false, $return=false) {
$name = $matches[1];
}

$select = html_select::make_popup_form(EWIKI_SCRIPT, $name, $links, 'wikilinks');
$select->nothinglabel = get_string("choosewikilinks", "wiki");
echo $OUTPUT->select($select);
echo $OUTPUT->single_select(new moodle_url(EWIKI_SCRIPT), $name, $links, null, array(''=>get_string("choosewikilinks", "wiki")), 'wikilinks');
}

/**
Expand Down Expand Up @@ -1567,9 +1565,7 @@ function wiki_print_page_actions($cmid, $specialpages, $page, $action, $binary=f
$name = $matches[1];
}

$select = html_select::make_popup_form(EWIKI_SCRIPT, $name, $page, 'wikiactions');
$select->nothinglabel = get_string("action", "wiki");
echo $OUTPUT->select($select);
echo $OUTPUT->single_select(new moodle_url(EWIKI_SCRIPT), $name, $page, null, array(''=>get_string("action", "wiki")), 'wikiactions');
}

/**
Expand Down Expand Up @@ -1612,9 +1608,7 @@ function wiki_print_administration_actions($wiki, $cmid, $userid, $groupid, $pag
if($noeditor) {
$action["checklinks"]=get_string("checklinks", "wiki");
}
$select = html_select::make_popup_form($ewscript, 'action', $action, 'wikiadministration');
$select->nothinglabel = get_string("chooseadministration", "wiki");
echo $OUTPUT->select($select);
echo $OUTPUT->single_select(new moodle_url($ewscript), 'action', $action, null, array(''=>get_string("chooseadministration", "wiki")), 'wikiadministration');
}

/**
Expand Down
Loading

0 comments on commit f8dab96

Please sign in to comment.