Browse files

MDL-37085 Load modchooser only when needed

  • Loading branch information...
1 parent 1707933 commit 697ff9999758db4881b439578296876be445960a @marinaglancy marinaglancy committed Dec 12, 2012
Showing with 21 additions and 24 deletions.
  1. +2 −12 course/lib.php
  2. +16 −1 course/renderer.php
  3. +1 −5 course/view.php
  4. +1 −1 course/yui/modchooser/modchooser.js
  5. +1 −5 index.php
View
14 course/lib.php
@@ -1800,7 +1800,8 @@ function print_section_add_menus($course, $section, $modnames = null, $vertical=
$output = html_writer::tag('div', $output, array('class' => 'show addresourcedropdown'));
$modchooser = html_writer::tag('div', $modchooser, array('class' => 'hide addresourcemodchooser'));
}
- $output = $modchooser . $output;
+ $courserenderer = $PAGE->get_renderer('core', 'course');
+ $output = $courserenderer->course_modchooser($modules, $course) . $modchooser . $output;
}
if ($return) {
@@ -4481,17 +4482,6 @@ function include_course_ajax($course, $usedmodules = array(), $enabledmodules =
// Load drag and drop upload AJAX.
dndupload_add_to_course($course, $enabledmodules);
- // Add the module chooser
- $PAGE->requires->yui_module('moodle-course-modchooser',
- 'M.course.init_chooser',
- array(array('courseid' => $course->id, 'closeButtonTitle' => get_string('close', 'editor')))
- );
- $PAGE->requires->strings_for_js(array(
- 'addresourceoractivity',
- 'modchooserenable',
- 'modchooserdisable',
- ), 'moodle');
-
return true;
}
View
17 course/renderer.php
@@ -211,7 +211,22 @@ protected function course_category_tree_category(stdClass $category, $depth=1) {
* @return string The composed HTML for the module
*/
public function course_modchooser($modules, $course) {
- global $OUTPUT;
+ static $isdisplayed = false;
+ if ($isdisplayed) {
+ return '';
+ }
+ $isdisplayed = true;
+
+ // Add the module chooser
+ $this->page->requires->yui_module('moodle-course-modchooser',
+ 'M.course.init_chooser',
+ array(array('courseid' => $course->id, 'closeButtonTitle' => get_string('close', 'editor')))
+ );
+ $this->page->requires->strings_for_js(array(
+ 'addresourceoractivity',
+ 'modchooserenable',
+ 'modchooserdisable',
+ ), 'moodle');
// Add the header
$header = html_writer::tag('div', get_string('addresourceoractivity', 'moodle'),
View
6 course/view.php
@@ -269,10 +269,6 @@
echo html_writer::end_tag('div');
// Include course AJAX
- if (include_course_ajax($course, $modnamesused)) {
- // Add the module chooser
- $renderer = $PAGE->get_renderer('core', 'course');
- echo $renderer->course_modchooser(get_module_metadata($course, $modnames, $displaysection), $course);
- }
+ include_course_ajax($course, $modnamesused);
echo $OUTPUT->footer();
View
2 course/yui/modchooser/modchooser.js
@@ -158,6 +158,6 @@ YUI.add('moodle-course-modchooser', function(Y) {
}
},
'@VERSION@', {
- requires:['base', 'overlay', 'moodle-core-chooserdialogue', 'transition']
+ requires:['base', 'overlay', 'moodle-core-chooserdialogue', 'transition', 'moodle-course-coursebase']
}
);
View
6 index.php
@@ -151,11 +151,7 @@
}
}
// Include course AJAX
- if (include_course_ajax($SITE, $modnamesused)) {
- // Add the module chooser
- $renderer = $PAGE->get_renderer('core', 'course');
- echo $renderer->course_modchooser(get_module_metadata($SITE, $modnames), $SITE);
- }
+ include_course_ajax($SITE, $modnamesused);
if (isloggedin() and !isguestuser() and isset($CFG->frontpageloggedin)) {
$frontpagelayout = $CFG->frontpageloggedin;

0 comments on commit 697ff99

Please sign in to comment.