]> git.mjollnir.org Git - moodle.git/commitdiff
Merged from 1.7.
authorvyshane <vyshane>
Thu, 26 Oct 2006 07:46:22 +0000 (07:46 +0000)
committervyshane <vyshane>
Thu, 26 Oct 2006 07:46:22 +0000 (07:46 +0000)
course/view.php

index e26c12782663d506b7640c3a23beb4aff1a3bea9..b77ca0277c22253dda7d64baf588a16acc2c8501 100644 (file)
     // 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 <blockname>_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 <blockname>_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();
     }
 
 
     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);
+        }
     }