]> git.mjollnir.org Git - moodle.git/commitdiff
moodle_page: MDL-12212 Eliminate legacy blocks_ methods
authortjhunt <tjhunt>
Wed, 6 May 2009 08:53:14 +0000 (08:53 +0000)
committertjhunt <tjhunt>
Wed, 6 May 2009 08:53:14 +0000 (08:53 +0000)
moving blocks will now be broken until the new bockslib is done

admin/pagelib.php
blog/blogpage.php
lib/pagelib.php
mod/lesson/pagelib.php
my/pagelib.php
tag/pagelib.php

index 4b99ab83a20bb81cb990b042c03272adc12680a3..2a7ad1cae2073e29074982b8f1b9344114a6b8c5 100644 (file)
@@ -104,23 +104,6 @@ class page_admin extends page_base {
         return array_merge($this->extraurlparams, array('section' => $this->section));
     }
 
-    function blocks_get_positions() {
-        return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT);
-    }
-
-    function blocks_default_position() {
-        return BLOCK_POS_LEFT;
-    }
-
-    function blocks_move_position(&$instance, $move) {
-        if($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) {
-            return BLOCK_POS_RIGHT;
-        } else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) {
-            return BLOCK_POS_LEFT;
-        }
-        return $instance->position;
-    }
-
     function print_header($section = '', $focus='') {
         global $USER, $CFG, $SITE;
 
index 67c0111308048fae6e7d7c915c2883bd5de3fcbd..aa00ba2323d404d47d6cc3c2f5be7dd19cbc8723 100644 (file)
@@ -110,48 +110,6 @@ class page_blog extends page_base {
         return $array;
     }
 
-
-    // Having defined all identifiers we need, here we declare which block positions we are
-    // going to support.
-    function blocks_get_positions() {
-        return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT);
-    }
-
-    // When a new block is created in this page, which position should it go to?
-    function blocks_default_position() {
-        return BLOCK_POS_RIGHT;
-    }
-
-    // When we are creating a new page, use the data at your disposal to provide a textual representation of the
-    // blocks that are going to get added to this new page. Delimit block names with commas (,) and use double
-    // colons (:) to delimit between block positions in the page. See blocks_get_positions() for additional info.
-    function blocks_get_default() {
-        global $CFG;
-
-        $this->init_full();
-
-        // It's a normal blog page
-        if (!empty($CFG->{'defaultblocks_'. $this->pagetype})) {
-            $blocknames = $CFG->{'defaultblocks_'. $this->pagetype};
-        } else {
-            /// Failsafe - in case nothing was defined.
-            $blocknames = 'admin,calendar_month,online_users,blog_menu';
-        }
-
-        return $blocknames;
-    }
-
-    // And finally, a little block move logic. Given a block's previous position and where
-    // we want to move it to, return its new position. Pretty self-documenting.
-    function blocks_move_position(&$instance, $move) {
-        if ($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) {
-            return BLOCK_POS_RIGHT;
-        } else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) {
-            return BLOCK_POS_LEFT;
-        }
-        return $instance->position;
-    }
-
     /////////// Blog page specific functions
     function get_extra_header_string() {
         global $SESSION, $CFG, $USER;
index 95af986993117233c911b29c2170ab6ef6fc54b4..dcf6a9cd87a8d7a42c6f1c3ae17ec8938cfaaf8b 100644 (file)
@@ -539,6 +539,38 @@ class moodle_page {
         debugging('Call to deprecated method moodle_page::get_legacyclass.');
         return $this->_legacyclass;
     }
+
+    /**
+     * @deprecated since Moodle 2.0
+     * @return string the places on this page where blocks can go.
+     */
+    function blocks_get_positions() {
+        debugging('Call to deprecated method moodle_page::blocks_get_positions. Use $PAGE->blocks->get_positions() instead.');
+        return $PAGE->blocks->get_positions();
+    }
+
+    /**
+     * @deprecated since Moodle 2.0
+     * @return string the default place for blocks on this page.
+     */
+    function blocks_default_position() {
+        debugging('Call to deprecated method moodle_page::blocks_default_position. Use $PAGE->blocks->get_default_position() instead.');
+        return $PAGE->blocks->get_default_position();
+    }
+
+    /**
+     * @deprecated since Moodle 2.0 - no longer used.
+     */
+    function blocks_get_default() {
+        debugging('Call to deprecated method moodle_page::blocks_get_default. This method has no function any more.');
+    }
+
+    /**
+     * @deprecated since Moodle 2.0 - no longer used.
+     */
+    function blocks_move_position(&$instance, $move) {
+        debugging('Call to deprecated method moodle_page::blocks_move_position. This method has no function any more.');
+    }
 }
 
 /**
@@ -675,32 +707,6 @@ class page_base extends moodle_page {
         return;
     }
 
-    // BLOCKS RELATED SECTION
-
-    // By default, pages don't have any blocks. Override this in your derived class if you need blocks.
-    function blocks_get_positions() {
-        return array();
-    }
-
-    // Thus there is no default block position. If you override the above you should override this one too.
-    // Because this makes sense only if blocks_get_positions() is overridden and because these two should
-    // be overridden as a group or not at all, this one issues a warning. The sneaky part is that this warning
-    // will only be seen if you override blocks_get_positions() but NOT blocks_default_position().
-    function blocks_default_position() {
-        trigger_error('Page class does not implement method <strong>blocks_default_position()</strong>', E_USER_WARNING);
-        return NULL;
-    }
-
-    // If you don't override this, newly constructed pages of this kind won't have any blocks.
-    function blocks_get_default() {
-        return '';
-    }
-
-    // If you don't override this, your blocks will not be able to change positions
-    function blocks_move_position(&$instance, $move) {
-        return $instance->position;
-    }
-
     // SELF-REPORTING SECTION
 
     // Derived classes HAVE to define their "home url"
@@ -926,26 +932,10 @@ class page_course extends page_base {
         }
     }
 
-    // BLOCKS RELATED SECTION
-
-    // Which are the positions in this page which support blocks? Return an array containing their identifiers.
-    // BE CAREFUL, ORDER DOES MATTER! In textual representations, lists of blocks in a page use the ':' character
-    // to delimit different positions in the page. The part before the first ':' in such a representation will map
-    // directly to the first item of the array you return here, the second to the next one and so on. This way,
-    // you can add more positions in the future without interfering with legacy textual representations.
-    function blocks_get_positions() {
-        return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT);
-    }
-
-    // When a new block is created in this page, which position should it go to?
-    function blocks_default_position() {
-        return BLOCK_POS_RIGHT;
-    }
-
     // When we are creating a new page, use the data at your disposal to provide a textual representation of the
     // blocks that are going to get added to this new page. Delimit block names with commas (,) and use double
     // colons (:) to delimit between block positions in the page. See blocks_get_positions() for additional info.
-    function blocks_get_default() {
+    function _legacy_blocks_get_default() {
         global $CFG;
 
         $this->init_full();
@@ -986,22 +976,6 @@ class page_course extends page_base {
 
         return $blocknames;
     }
-
-    // Given an instance of a block in this page and the direction in which we want to move it, where is
-    // it going to go? Return the identifier of the instance's new position. This allows us to tell blocklib
-    // how we want the blocks to move around in this page in an arbitrarily complex way. If the move as given
-    // does not make sense, make sure to return the instance's original position.
-    //
-    // Since this is going to get called a LOT, pass the instance by reference purely for speed. Do **NOT**
-    // modify its data in any way, this will actually confuse blocklib!!!
-    function blocks_move_position(&$instance, $move) {
-        if($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) {
-            return BLOCK_POS_RIGHT;
-        } else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) {
-            return BLOCK_POS_LEFT;
-        }
-        return $instance->position;
-    }
 }
 
 /**
index afd5ad0e4bc412688ddce8096defa5d52270b8d8..388ee61cadd69f1042e512b412e563aa7791d815 100644 (file)
@@ -140,23 +140,6 @@ class page_lesson extends page_generic_activity {
         lesson_print_messages();
     }
 
-    function blocks_get_positions() {
-        return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT);
-    }
-
-    function blocks_default_position() {
-        return BLOCK_POS_RIGHT;
-    }
-
-    function blocks_move_position(&$instance, $move) {
-        if($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) {
-            return BLOCK_POS_RIGHT;
-        } else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) {
-            return BLOCK_POS_LEFT;
-        }
-        return $instance->position;
-    }
-
     /**
      * Needed to add the ID of the current lesson page
      *
index d6e2b9f76fc94246e88515fa8cc684c313b77025..d7db4831333b0e7b2c86c34411424a196227aec7 100644 (file)
@@ -71,23 +71,6 @@ class page_my_moodle extends page_base {
             return array();
         }
     }
-       
-    function blocks_default_position() {
-        return BLOCK_POS_LEFT;
-    }
-
-    function blocks_get_positions() {
-        return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT);
-    }
-
-    function blocks_move_position(&$instance, $move) {
-        if($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) {
-            return BLOCK_POS_RIGHT;
-        } else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) {
-            return BLOCK_POS_LEFT;
-        }
-        return $instance->position;
-    }
 }
 
 
index 27a1306df89e339125b46d665fd4f62bd46d974b..9eb8ea9e3f54ac4048855691e5d296d20a365076 100644 (file)
@@ -33,23 +33,6 @@ class page_tag extends page_base {
         $param['id'] = $this->id;
         return $param;
     }
-       
-    function blocks_default_position() {
-        return BLOCK_POS_LEFT;
-    }
-
-    function blocks_get_positions() {
-        return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT);
-    }
-
-    function blocks_move_position(&$instance, $move) {
-        if($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) {
-            return BLOCK_POS_RIGHT;
-        } else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) {
-            return BLOCK_POS_LEFT;
-        }
-        return $instance->position;
-    }
 
     //-----------  printing funtions -----------