From 64e12bb710e90e9a84e9f40ed38b8081820ef291 Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Sat, 8 Aug 2009 09:31:01 +0000 Subject: [PATCH] MDL-19794 Converting calls to popup_form() --- course/category.php | 9 ++++++++- course/format/topics/format.php | 9 ++++++--- course/format/weeks/format.php | 9 ++++++--- course/index.php | 7 ++++++- course/lib.php | 27 +++++++++++++++++---------- course/report/stats/lib.php | 12 ++++++------ 6 files changed, 49 insertions(+), 24 deletions(-) diff --git a/course/category.php b/course/category.php index 7f1f1ad8d8..bced679cd7 100644 --- a/course/category.php +++ b/course/category.php @@ -171,7 +171,14 @@ make_categories_list($displaylist, $notused); echo '
'; - popup_form('category.php?id=', $displaylist, 'switchcategory', $category->id, '', '', '', false, 'self', $strcategories.':'); + $popupurl = 'category.php?id='; + foreach ($displaylist as $key => $val) { + $displaylist[$popupurl.$key] = $val; + unset($displaylist[$key]); + } + $select = moodle_select::make_popup_form($displaylist, 'switchcategory', $popupurl.$category->id); + $select->set_label($strcategories.':'); + echo $OUTPUT->select($select); echo '
'; /// Print current category description diff --git a/course/format/topics/format.php b/course/format/topics/format.php index 36efe2551e..54b93f25f3 100644 --- a/course/format/topics/format.php +++ b/course/format/topics/format.php @@ -130,6 +130,8 @@ $timenow = time(); $section = 1; $sectionmenu = array(); + + $popupurl = $CFG->wwwroot.'/course/view.php?id='.$course->id.'&topic='; while ($section <= $course->numsections) { @@ -155,7 +157,7 @@ } else { $strsummary = ' - '.substr($strsummary, 0, 60).'...'; } - $sectionmenu[$section] = s($section.$strsummary); + $sectionmenu[$popupurl.$section] = s($section.$strsummary); } $section++; continue; @@ -252,7 +254,8 @@ if (!empty($sectionmenu)) { echo '
'; - echo popup_form($CFG->wwwroot.'/course/view.php?id='.$course->id.'&topic=', $sectionmenu, - 'sectionmenu', '', get_string('jumpto'), '', '', true); + $select = moodle_select::make_popup_form($sectionmenu, 'sectionmenu'); + $select->set_label(get_string('jumpto')); + echo $OUTPUT->select($select); echo '
'; } diff --git a/course/format/weeks/format.php b/course/format/weeks/format.php index d75ef476af..cdecf5d39d 100644 --- a/course/format/weeks/format.php +++ b/course/format/weeks/format.php @@ -126,6 +126,8 @@ $weekofseconds = 604800; $course->enddate = $course->startdate + ($weekofseconds * $course->numsections); + $popupurl = $CFG->wwwroot.'/course/view.php?id='.$course->id.'&week='; + $strftimedateshort = ' '.get_string('strftimedateshort'); while ($weekdate < $course->enddate) { @@ -150,7 +152,7 @@ if (!empty($displaysection) and $displaysection != $section) { // Check this week is visible if ($showsection) { - $sectionmenu[$section] = s("$strweek $section | $weekday - $endweekday"); + $sectionmenu[$popupurl.$section] = s("$strweek $section | $weekday - $endweekday"); } $section++; $weekdate = $nextweekdate; @@ -244,7 +246,8 @@ if (!empty($sectionmenu)) { echo '
'; - echo popup_form($CFG->wwwroot.'/course/view.php?id='.$course->id.'&week=', $sectionmenu, - 'sectionmenu', '', get_string('jumpto'), '', '', true); + $select = moodle_select::make_popup_form($sectionmenu, 'sectionmenu'); + $select->set_label(get_string('jumpto')); + echo $OUTPUT->select($select); echo '
'; } diff --git a/course/index.php b/course/index.php index 9c6ca4695a..b064d30aca 100644 --- a/course/index.php +++ b/course/index.php @@ -330,13 +330,18 @@ function print_category_edit($category, $displaylist, $parentslist, $depth=-1, $ echo ''; if (has_capability('moodle/category:manage', $category->context)) { $tempdisplaylist = $displaylist; + $popupurl = "index.php?move=$category->id&sesskey=".sesskey()."&moveto="; unset($tempdisplaylist[$category->id]); foreach ($parentslist as $key => $parents) { if (in_array($category->id, $parents)) { unset($tempdisplaylist[$key]); } } - popup_form ("index.php?move=$category->id&sesskey=".sesskey()."&moveto=", $tempdisplaylist, "moveform$category->id", $category->parent, '', '', '', false); + foreach ($tempdisplaylist as $key => $val) { + $tempdisplaylist[$popupurl.$key] = $val; + unset($tempdisplaylist[$key]); + } + echo $OUTPUT->select(moodle_select::make_popup_form($tempdisplaylist, "moveform$category->id", $popupurl.$category->parent)); } echo ''; echo ''; diff --git a/course/lib.php b/course/lib.php index e388f61fc4..c9326bbf50 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1546,7 +1546,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false, * Prints the menus to add activities and resources. */ function print_section_add_menus($course, $section, $modnames, $vertical=false, $return=false) { - global $CFG; + global $CFG, $OUTPUT; // check to see if user can add menus if (!has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id))) { @@ -1556,6 +1556,8 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false, static $resources = false; static $activities = false; + $popupurl = "$CFG->wwwroot/course/mod.php?id=$course->id§ion=$section&sesskey=".sesskey()."&add="; + if ($resources === false) { $resources = array(); $activities = array(); @@ -1573,20 +1575,22 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false, $gettypesfunc = $modname.'_get_types'; if (function_exists($gettypesfunc)) { $types = $gettypesfunc(); + foreach($types as $type) { + $type->type = str_replace('&', '&', $type->type); if (!isset($type->modclass) or !isset($type->typestr)) { debugging('Incorrect activity type in '.$modname); continue; } if ($type->modclass == MOD_CLASS_RESOURCE) { - $resources[$type->type] = $type->typestr; + $resources[$popupurl.$type->type] = $type->typestr; } else { - $activities[$type->type] = $type->typestr; + $activities[$popupurl.$type->type] = $type->typestr; } } } else { // all mods without type are considered activity - $activities[$modname] = $modnamestr; + $activities[$popupurl.$modname] = $modnamestr; } } } @@ -1599,16 +1603,19 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false, if (!$vertical) { $output .= '
'; } - + if (!empty($resources)) { - $output .= popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$section&sesskey=".sesskey()."&add=", - $resources, "ressection$section", "", $straddresource, 'resource/types', $straddresource, true); + $select = moodle_select::make_popup_form($resources, "ressection$section", null); + $select->nothinglabel = $straddresource; + $select->set_help_icon('resource/types', $straddresource); + $output .= $OUTPUT->select($select); } if (!empty($activities)) { - $output .= ' '; - $output .= popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$section&sesskey=".sesskey()."&add=", - $activities, "section$section", "", $straddactivity, 'mods', $straddactivity, true); + $select = moodle_select::make_popup_form($activities, "section$section", null); + $select->nothinglabel = $straddactivity; + $select->set_help_icon('mods', $straddactivity); + $output .= $OUTPUT->select($select); } if (!$vertical) { diff --git a/course/report/stats/lib.php b/course/report/stats/lib.php index 237ea02bc2..a3c38f164f 100644 --- a/course/report/stats/lib.php +++ b/course/report/stats/lib.php @@ -8,7 +8,7 @@ function report_stats_mode_menu($course, $mode, $time, $url) { - global $CFG; + global $CFG, $OUTPUT; /* $reportoptions = stats_get_report_options($course->id, $mode); $timeoptions = report_stats_timeoptions($mode); @@ -18,13 +18,13 @@ */ $options = array(); - $options[STATS_MODE_GENERAL] = get_string('statsmodegeneral'); - $options[STATS_MODE_DETAILED] = get_string('statsmodedetailed'); + $popupurl = $url."?course=$course->id&time=$time&mode="; + $options[$popupurl.STATS_MODE_GENERAL] = get_string('statsmodegeneral'); + $options[$popupurl.STATS_MODE_DETAILED] = get_string('statsmodedetailed'); if (has_capability('coursereport/stats:view', get_context_instance(CONTEXT_SYSTEM))) { - $options[STATS_MODE_RANKED] = get_string('reports'); + $options[$popupurl.STATS_MODE_RANKED] = get_string('reports'); } - - return popup_form($url."?course=$course->id&time=$time&mode=", $options, 'switchmode', $mode, '', '', '', true); + return $OUTPUT->select(moodle_select::make_popup_form($options, 'switchmode', $popupurl.$mode)); } -- 2.39.5