Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-37085 Load modchooser only when needed

  • Loading branch information...
commit 697ff9999758db4881b439578296876be445960a 1 parent 1707933
Marina Glancy marinaglancy authored
14 course/lib.php
@@ -1800,7 +1800,8 @@ function print_section_add_menus($course, $section, $modnames = null, $vertical=
1800 1800 $output = html_writer::tag('div', $output, array('class' => 'show addresourcedropdown'));
1801 1801 $modchooser = html_writer::tag('div', $modchooser, array('class' => 'hide addresourcemodchooser'));
1802 1802 }
1803   - $output = $modchooser . $output;
  1803 + $courserenderer = $PAGE->get_renderer('core', 'course');
  1804 + $output = $courserenderer->course_modchooser($modules, $course) . $modchooser . $output;
1804 1805 }
1805 1806
1806 1807 if ($return) {
@@ -4481,17 +4482,6 @@ function include_course_ajax($course, $usedmodules = array(), $enabledmodules =
4481 4482 // Load drag and drop upload AJAX.
4482 4483 dndupload_add_to_course($course, $enabledmodules);
4483 4484
4484   - // Add the module chooser
4485   - $PAGE->requires->yui_module('moodle-course-modchooser',
4486   - 'M.course.init_chooser',
4487   - array(array('courseid' => $course->id, 'closeButtonTitle' => get_string('close', 'editor')))
4488   - );
4489   - $PAGE->requires->strings_for_js(array(
4490   - 'addresourceoractivity',
4491   - 'modchooserenable',
4492   - 'modchooserdisable',
4493   - ), 'moodle');
4494   -
4495 4485 return true;
4496 4486 }
4497 4487
17 course/renderer.php
@@ -211,7 +211,22 @@ protected function course_category_tree_category(stdClass $category, $depth=1) {
211 211 * @return string The composed HTML for the module
212 212 */
213 213 public function course_modchooser($modules, $course) {
214   - global $OUTPUT;
  214 + static $isdisplayed = false;
  215 + if ($isdisplayed) {
  216 + return '';
  217 + }
  218 + $isdisplayed = true;
  219 +
  220 + // Add the module chooser
  221 + $this->page->requires->yui_module('moodle-course-modchooser',
  222 + 'M.course.init_chooser',
  223 + array(array('courseid' => $course->id, 'closeButtonTitle' => get_string('close', 'editor')))
  224 + );
  225 + $this->page->requires->strings_for_js(array(
  226 + 'addresourceoractivity',
  227 + 'modchooserenable',
  228 + 'modchooserdisable',
  229 + ), 'moodle');
215 230
216 231 // Add the header
217 232 $header = html_writer::tag('div', get_string('addresourceoractivity', 'moodle'),
6 course/view.php
@@ -269,10 +269,6 @@
269 269 echo html_writer::end_tag('div');
270 270
271 271 // Include course AJAX
272   - if (include_course_ajax($course, $modnamesused)) {
273   - // Add the module chooser
274   - $renderer = $PAGE->get_renderer('core', 'course');
275   - echo $renderer->course_modchooser(get_module_metadata($course, $modnames, $displaysection), $course);
276   - }
  272 + include_course_ajax($course, $modnamesused);
277 273
278 274 echo $OUTPUT->footer();
2  course/yui/modchooser/modchooser.js
@@ -158,6 +158,6 @@ YUI.add('moodle-course-modchooser', function(Y) {
158 158 }
159 159 },
160 160 '@VERSION@', {
161   - requires:['base', 'overlay', 'moodle-core-chooserdialogue', 'transition']
  161 + requires:['base', 'overlay', 'moodle-core-chooserdialogue', 'transition', 'moodle-course-coursebase']
162 162 }
163 163 );
6 index.php
@@ -151,11 +151,7 @@
151 151 }
152 152 }
153 153 // Include course AJAX
154   - if (include_course_ajax($SITE, $modnamesused)) {
155   - // Add the module chooser
156   - $renderer = $PAGE->get_renderer('core', 'course');
157   - echo $renderer->course_modchooser(get_module_metadata($SITE, $modnames), $SITE);
158   - }
  154 + include_course_ajax($SITE, $modnamesused);
159 155
160 156 if (isloggedin() and !isguestuser() and isset($CFG->frontpageloggedin)) {
161 157 $frontpagelayout = $CFG->frontpageloggedin;

0 comments on commit 697ff99

Please sign in to comment.
Something went wrong with that request. Please try again.