From 4e86c6d7358980b2d5f17508927e591bc4819dea Mon Sep 17 00:00:00 2001 From: vyshane Date: Thu, 26 Oct 2006 07:46:22 +0000 Subject: [PATCH] Merged from 1.7. --- course/view.php | 65 +++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/course/view.php b/course/view.php index e26c127826..b77ca0277c 100644 --- a/course/view.php +++ b/course/view.php @@ -123,36 +123,43 @@ // AJAX-capable course format? $useajax = false; $ajaxformatfile = $CFG->dirroot.'/course/format/'.$course->format.'/ajax.php'; + $meta = ''; + $bodytags = ''; if (file_exists($ajaxformatfile)) { require_once($ajaxformatfile); + if ($USER->editing && !empty($USER->ajax) && $CFG->ajaxcapable) { - $useajax = true; - } - } - $meta = ''; - $bodytags = ''; - - if ($useajax) { - $meta = require_js(array('yui_yahoo', 'yui_dom', 'yui_event', 'yui_dragdrop', 'yui_connection')); - - if (debugging('', DEBUG_DEVELOPER)) { // Need to detect whether we're using ajax too. - $meta .= require_js(array('yui_logger')); - - $bodytags = 'onLoad = "javascript: - show_logger = function() { - var logreader = new YAHOO.widget.LogReader(); - logreader.newestOnTop = false; - logreader.setTitle(\'Moodle Debug: YUI Log Console\'); - }; - show_logger(); - "'; + + if ($meta = require_js(array('yui_yahoo', + 'yui_dom', + 'yui_event', + 'yui_dragdrop', + 'yui_connection'))) { + + if (debugging('', DEBUG_DEVELOPER)) { + $meta .= require_js(array('yui_logger')); + + $bodytags = 'onLoad = "javascript: + show_logger = function() { + var logreader = new YAHOO.widget.LogReader(); + logreader.newestOnTop = false; + logreader.setTitle(\'Moodle Debug: YUI Log Console\'); + }; + show_logger(); + "'; + } + // Okay, global variable alert. VERY UGLY. We need to create + // this object here before the _print_block() + // function is called, since that function needs to set some + // stuff in the javascriptportal object. + $COURSE->javascriptportal = new jsportal(); + $useajax = true; + + } else { + $useajax = false; + } } - // Okay, global variable alert. VERY UGLY. We need to create this object - // here before the _print_block() function is called, since - // that function needs to set some stuff in the javascriptportal object. - // Like I said... VERY UGLY. - $COURSE->javascriptportal = new jsportal(); } @@ -196,8 +203,12 @@ if ($useajax) { // At the bottom because we want to process sections and activities // after the relevant html has been generated. - echo require_js(array('ajaxcourse_blocks', 'ajaxcourse_sections', 'ajaxcourse')); - $COURSE->javascriptportal->print_javascript($course->id); + if ($jsincludes = require_js(array('ajaxcourse_blocks', + 'ajaxcourse_sections', + 'ajaxcourse'))) { + echo $jsincludes; + $COURSE->javascriptportal->print_javascript($course->id); + } } -- 2.39.5