From 4873f5f709c32306c4f7cb587ca5d05803e18f7b Mon Sep 17 00:00:00 2001 From: tjhunt Date: Wed, 6 May 2009 08:53:14 +0000 Subject: [PATCH] moodle_page: MDL-12212 Eliminate legacy blocks_ methods moving blocks will now be broken until the new bockslib is done --- admin/pagelib.php | 17 -------- blog/blogpage.php | 42 ------------------- lib/pagelib.php | 92 +++++++++++++++--------------------------- mod/lesson/pagelib.php | 17 -------- my/pagelib.php | 17 -------- tag/pagelib.php | 17 -------- 6 files changed, 33 insertions(+), 169 deletions(-) diff --git a/admin/pagelib.php b/admin/pagelib.php index 4b99ab83a20bb..2a7ad1cae2073 100644 --- a/admin/pagelib.php +++ b/admin/pagelib.php @@ -104,23 +104,6 @@ function url_get_parameters() { // only handles parameters relevant to the admi 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; diff --git a/blog/blogpage.php b/blog/blogpage.php index 67c0111308048..aa00ba2323d40 100644 --- a/blog/blogpage.php +++ b/blog/blogpage.php @@ -110,48 +110,6 @@ function url_get_parameters() { 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; diff --git a/lib/pagelib.php b/lib/pagelib.php index 95af986993117..dcf6a9cd87a8d 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -539,6 +539,38 @@ public function get_legacyclass() { 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 @@ function print_header($title, $morenavlinks=NULL) { 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 blocks_default_position()', 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 @@ function url_get_parameters() { } } - // 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 @@ function blocks_get_default() { 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; - } } /** diff --git a/mod/lesson/pagelib.php b/mod/lesson/pagelib.php index afd5ad0e4bc41..388ee61cadd69 100644 --- a/mod/lesson/pagelib.php +++ b/mod/lesson/pagelib.php @@ -140,23 +140,6 @@ function print_header($title = '', $morenavlinks = array()) { 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 * diff --git a/my/pagelib.php b/my/pagelib.php index d6e2b9f76fc94..d7db4831333b0 100644 --- a/my/pagelib.php +++ b/my/pagelib.php @@ -71,23 +71,6 @@ function url_get_parameters() { 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; - } } diff --git a/tag/pagelib.php b/tag/pagelib.php index 27a1306df89e3..9eb8ea9e3f54a 100644 --- a/tag/pagelib.php +++ b/tag/pagelib.php @@ -33,23 +33,6 @@ function url_get_parameters() { $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 -----------