From: vyshane Date: Tue, 24 Oct 2006 08:13:13 +0000 (+0000) Subject: Merged from 1.7. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f45cc76fb30931cb9a3f96b3759f16194de523d6;p=moodle.git Merged from 1.7. --- diff --git a/course/format/topics/ajax.php b/course/format/topics/ajax.php new file mode 100644 index 0000000000..bea639597d --- /dev/null +++ b/course/format/topics/ajax.php @@ -0,0 +1,9 @@ +ajaxcapable = true; + +?> \ No newline at end of file diff --git a/course/format/topics/format.php b/course/format/topics/format.php index 8006bf66cb..d0befec1b8 100644 --- a/course/format/topics/format.php +++ b/course/format/topics/format.php @@ -61,17 +61,6 @@ $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')); - } } @@ -281,9 +270,4 @@ echo ''; - //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 index 0000000000..bea639597d --- /dev/null +++ b/course/format/weeks/ajax.php @@ -0,0 +1,9 @@ +ajaxcapable = true; + +?> \ No newline at end of file diff --git a/course/format/weeks/format.php b/course/format/weeks/format.php index 88594db454..bf89224032 100644 --- a/course/format/weeks/format.php +++ b/course/format/weeks/format.php @@ -47,16 +47,6 @@ $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); @@ -275,9 +265,4 @@ echo ''; - //create javascript portal code - if (!empty($COURSE->javascriptportal)) { - $COURSE->javascriptportal->print_javascript($course->id); - } - -?> +?> \ No newline at end of file diff --git a/course/rest.php b/course/rest.php index dd6548b2d0..41fce5d17b 100644 --- a/course/rest.php +++ b/course/rest.php @@ -179,4 +179,4 @@ switch($_SERVER['REQUEST_METHOD']) { break; } -?> +?> \ No newline at end of file diff --git a/course/view.php b/course/view.php index fb60ea3674..e26c127826 100644 --- a/course/view.php +++ b/course/view.php @@ -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); @@ -74,12 +75,12 @@ } $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; @@ -112,13 +113,53 @@ $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 '
'; // 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 _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 '
'; + get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused); @@ -135,16 +176,31 @@ } } - 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 '
'; // content wrapper end + // Include the actual course format. + require($CFG->dirroot .'/course/format/'. $course->format .'/format.php'); + // Content wrapper end. + echo '
'; + + + // 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