]> git.mjollnir.org Git - moodle.git/commitdiff
blocklib: MDL-19010 finally fix the regressions that mean that you could not create...
authortjhunt <tjhunt>
Fri, 8 May 2009 03:11:24 +0000 (03:11 +0000)
committertjhunt <tjhunt>
Fri, 8 May 2009 03:11:24 +0000 (03:11 +0000)
course/lib.php
lib/adminlib.php
lib/blocklib.php
theme/standard/styles_layout.css

index 82a5044172d1aa18fe4369b9e6025168aed8d006..8ab86c2eccc7557803858c34ac57e20ac89a4e44 100644 (file)
@@ -3536,8 +3536,7 @@ function create_course($data) {
         $course = $DB->get_record('course', array('id'=>$newcourseid));
 
         // Setup the blocks
-        $page = page_create_object(PAGE_COURSE_VIEW, $course->id);
-        blocks_repopulate_page($page); // Return value not checked because you can always edit later
+        blocks_add_default_course_blocks($course);
 
         update_restricted_mods($course, $allowedmods);
 
index 59e74f23e23cdcfa7a9bcd05c4f7cb80b7c352e3..c944bea9d9144727abacf79a1597c29913656a27 100644 (file)
@@ -3913,6 +3913,9 @@ function admin_externalpage_setup($section, $extrabutton = '',
     }
     $PAGE->set_url(str_replace($CFG->wwwroot . '/', '', $actualurl),
             array_merge($extraurlparams, array('section' => $section)));
+    if (strpos($PAGE->pagetype, 'admin-') !== 0) {
+        $PAGE->set_pagetype('admin-' . $PAGE->pagetype);
+    }
 
     if (empty($extpage) or !($extpage instanceof admin_externalpage)) {
         print_error('sectionerror', 'admin', "$CFG->wwwroot/$CFG->admin/");
index ceeba07b681856fcbf242b485b9a0c4f4bc36b68..a2d3876a81eacee9278a6d3e7f4aee355903cd90 100644 (file)
@@ -54,8 +54,20 @@ require_once($CFG->libdir.'/pagelib.php');
  * only at the point that the load_blocks() method is called. It is the caller's
  * responsibility to ensure that those fields do not subsequently change.
  *
- * The implements ArrayAccess is a horrible backwards_compatibility thing.
- * TODO explain!
+ *
+ * Note about the weird 'implements ArrayAccess' part of the declaration:
+ *
+ * ArrayAccess is a magic PHP5 thing. If your class implements the ArrayAccess
+ * interface, then other code can use the $object[$index] syntax, and it will
+ * call the offsetGet method of the object.
+ * See http://php.net/manual/en/class.arrayaccess.php
+ *
+ * So, why do we do this here? Basically, some of the deprecated blocks methods
+ * like blocks_setup used to return an array of blocks on the page, with array
+ * keys BLOCK_POS_LEFT, BLOCK_POS_RIGHT. We can keep legacy code that calls those
+ * deprecated functions mostly working by changing blocks_setup to return the
+ * block_manger object, and then use 'implements ArrayAccess' so that the right
+ * thing happens when legacy code does something like $pageblocks[BLOCK_POS_LEFT].
  */
 class block_manager implements ArrayAccess {
 
@@ -1355,8 +1367,8 @@ function blocks_add_default_course_blocks($course) {
             $blocknames = blocks_parse_default_blocks_list($CFG->$defaultblocks);
 
         } else {
-            $formatconfig = $CFG->dirroot.'/course/format/'.$pageformat.'/config.php';
-            if (file_exists_and_readable($formatconfig)) {
+            $formatconfig = $CFG->dirroot.'/course/format/'.$course->format.'/config.php';
+            if (is_readable($formatconfig)) {
                 require($formatconfig);
             }
             if (!empty($format['defaultblocks'])) {
@@ -1382,9 +1394,6 @@ function blocks_add_default_course_blocks($course) {
 
     $page = new moodle_page();
     $page->set_course($course);
-    print_object($page); // DONOTCOMMIT
-    print_object($pagetypepattern); // DONOTCOMMIT
-    print_object($blocknames); // DONOTCOMMIT
     $page->blocks->add_blocks($blocknames, $pagetypepattern);
 }
 
index b8515af3a1e63558b5d1644a0ed05e9914932a76..19bbd9afed1c8f6e731bf015ad8c79f67bfa2781 100644 (file)
@@ -2305,46 +2305,46 @@ body#course-index .courseboxes {
   padding:20px;
 }
 
-body#course-category .rolelink {
+body#admin-course-category .rolelink {
   text-align:right;
   padding:10px;
 }
 
-body#course-category .addcategory {
+body#admin-course-category .addcategory {
   text-align: center;
   padding: 10px;
 }
 
-body#course-index .buttons .singlebutton,
-body#course-category .buttons .singlebutton {
+body#admin-course-index .buttons .singlebutton,
+body#admin-course-category .buttons .singlebutton {
   display: inline;
 }
 
-body#course-index .buttons,
-body#course-category .buttons {
+body#admin-course-index .buttons,
+body#admin-course-category .buttons {
   text-align: center;
   margin-bottom: 15px;
 }
 
-body#course-index #middle-column .editcourse {
+body#admin-course-index #middle-column .editcourse {
   margin-left:auto;
   margin-right:auto;
   margin-top:20px;
   margin-bottom:20px;
 }
 
-body#course-index #middle-column .editcourse th,
-body#course-index #middle-column .editcourse td {
+body#admin-course-index #middle-column .editcourse th,
+body#admin-course-index #middle-column .editcourse td {
   padding-left:10px;
   padding-right:10px;
 }
 
-body#course-index #middle-column .editcourse .count {
+body#admin-course-index #middle-column .editcourse .count {
   text-align:right;
 }
 
-body#course-index .singlebutton,
-body#course-index .addcategory {
+body#admin-course-index .singlebutton,
+body#admin-course-index .addcategory {
   text-align: center;
 }