]> git.mjollnir.org Git - moodle.git/commitdiff
Merged from 1.7.
authorvyshane <vyshane>
Tue, 24 Oct 2006 08:13:13 +0000 (08:13 +0000)
committervyshane <vyshane>
Tue, 24 Oct 2006 08:13:13 +0000 (08:13 +0000)
course/format/topics/ajax.php [new file with mode: 0644]
course/format/topics/format.php
course/format/weeks/ajax.php [new file with mode: 0644]
course/format/weeks/format.php
course/rest.php
course/view.php

diff --git a/course/format/topics/ajax.php b/course/format/topics/ajax.php
new file mode 100644 (file)
index 0000000..bea6395
--- /dev/null
@@ -0,0 +1,9 @@
+<?php
+/**
+ * This file is required if the course format is to support AJAX.
+ */
+
+
+$CFG->ajaxcapable = true;
+
+?>
\ No newline at end of file
index 8006bf66cb7ef8a73ed5fc861d4c5d59e92940f8..d0befec1b825037d76882b5577279f8a0faf5488 100644 (file)
         $strmarkedthistopic = get_string('markedthistopic');
         $strmoveup = get_string('moveup');
         $strmovedown = get_string('movedown');
-        
-        if (!empty($USER->ajax)){
-
-         // If user doesnt want AJAX, then they wont get it, 
-         // from here everything detects $COURSE->javascriptportal
-                               
-            $COURSE->javascriptportal = new jsportal();
-
-            print_require_js(array('yui_yahoo','yui_dom','yui_event','yui_dragdrop', 'yui_connection',
-                                   'ajaxcourse_blocks','ajaxcourse_sections','ajaxcourse'));
-        }
     }
 
 
 
     echo '</tr></table>';
     
-    //create javascript portal code
-    if (!empty($COURSE->javascriptportal)) {
-        $COURSE->javascriptportal->print_javascript($course->id);
-    }
-
-?>
+?>
\ No newline at end of file
diff --git a/course/format/weeks/ajax.php b/course/format/weeks/ajax.php
new file mode 100644 (file)
index 0000000..bea6395
--- /dev/null
@@ -0,0 +1,9 @@
+<?php
+/**
+ * This file is required if the course format is to support AJAX.
+ */
+
+
+$CFG->ajaxcapable = true;
+
+?>
\ No newline at end of file
index 88594db4549a066356b4ff0a4da226cfd7fbcfc2..bf8922403285ece09cc7fcbde11b8c07f79fd37d 100644 (file)
         $strweekshow = get_string('weekshow', '', $strstudents);
         $strmoveup   = get_string('moveup');
         $strmovedown = get_string('movedown');
-
-        if (!empty($USER->ajax)) {
-
-         // If user doesnt want AJAX, then they wont get it, 
-         // from here everything detects $COURSE->javascriptportal
-            $COURSE->javascriptportal = new jsportal();
-
-            print_require_js(array('yui_yahoo','yui_dom','yui_event','yui_dragdrop', 'yui_connection',
-                                   'ajaxcourse_blocks','ajaxcourse_sections','ajaxcourse'));
-        }
     }
 
     $context = get_context_instance(CONTEXT_COURSE, $course->id);
 
     echo '</tr></table>';
 
-    //create javascript portal code
-    if (!empty($COURSE->javascriptportal)) {
-        $COURSE->javascriptportal->print_javascript($course->id);
-    }
-
-?>
+?>
\ No newline at end of file
index dd6548b2d07107232830424d228047905e449d3d..41fce5d17bd560bb384c399daea44cb64be858c3 100644 (file)
@@ -179,4 +179,4 @@ switch($_SERVER['REQUEST_METHOD']) {
         break;
 }
 
-?>
+?>
\ No newline at end of file
index fb60ea367480cb55022de8dc375632989b3e5684..e26c12782663d506b7640c3a23beb4aff1a3bea9 100644 (file)
@@ -5,6 +5,7 @@
     require_once('../config.php');
     require_once('lib.php');
     require_once($CFG->libdir.'/blocklib.php');
+    require_once($CFG->libdir.'/ajax/ajaxlib.php');
 
     $id          = optional_param('id', 0, PARAM_INT);
     $name        = optional_param('name', '', PARAM_RAW);
     }
 
     $PAGE = page_create_object(PAGE_COURSE_VIEW, $course->id);
-    $pageblocks = blocks_setup($PAGE,BLOCKS_PINNED_BOTH);
+    $pageblocks = blocks_setup($PAGE, BLOCKS_PINNED_BOTH);
+
 
     if (!isset($USER->editing)) {
         $USER->editing = 0;
     }
-
     if ($PAGE->user_allowed_editing()) {
         if (($edit == 1) and confirm_sesskey()) {
             $USER->editing = 1;
 
     $SESSION->fromdiscussion = $CFG->wwwroot .'/course/view.php?id='. $course->id;
 
-    if ($course->id == SITEID) {      // This course is not a real course.
+
+    if ($course->id == SITEID) {
+        // This course is not a real course.
         redirect($CFG->wwwroot .'/');
     }
 
-    $PAGE->print_header(get_string('course').': %fullname%');
 
-    echo '<div class="course-content">';  // course wrapper start
+    // AJAX-capable course format?
+    $useajax = false;
+    $ajaxformatfile = $CFG->dirroot.'/course/format/'.$course->format.'/ajax.php';
+
+    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();
+            "';
+        }
+        // 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();
+    }
+
+
+    $PAGE->print_header(get_string('course').': %fullname%', NULL, $meta, $bodytags);
+    // Course wrapper start.
+    echo '<div class="course-content">';
+
 
     get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
 
         }
     }
 
-    if (empty($course->modinfo)) {       // Course cache was never made
+
+    if (empty($course->modinfo)) {
+        // Course cache was never made.
         rebuild_course_cache($course->id);
         if (! $course = get_record('course', 'id', $course->id) ) {
             error("That's an invalid course id");
         }
     }
 
-    require($CFG->dirroot .'/course/format/'. $course->format .'/format.php');  // Include the actual course format
 
-    echo '</div>';  // content wrapper end
+    // Include the actual course format.
+    require($CFG->dirroot .'/course/format/'. $course->format .'/format.php');
+    // Content wrapper end.
+    echo '</div>';
+
+
+    // Use AJAX?
+    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);
+    }
+
+
     print_footer(NULL, $course);
 
-?>
+?>
\ No newline at end of file