Permalink
Browse files

blocklib MDL-25654 fix API inconsistency be renaming add_pretend_bloc…

…k to add_fake_block.

I added a deprecated method add_pretend_block that forwards to add_fake_block, so old code should be break. However, I aslo updated all the callers in core code.
  • Loading branch information...
1 parent 958c04e commit d9c26e2174fff3aa89a985cea40c986a31aaf4dc @timhunt timhunt committed with skodak Dec 13, 2010
Showing with 26 additions and 13 deletions.
  1. +1 −1 calendar/renderer.php
  2. +16 −3 lib/blocklib.php
  3. +1 −1 mod/lesson/continue.php
  4. +4 −4 mod/lesson/locallib.php
  5. +2 −2 mod/lesson/view.php
  6. +1 −1 mod/quiz/attempt.php
  7. +1 −1 mod/quiz/review.php
@@ -176,7 +176,7 @@ public function fake_block_threemonths(calendar_information $calendar) {
* @param mixed $pos BLOCK_POS_RIGHT | BLOCK_POS_LEFT
*/
public function add_pretend_calendar_block(block_contents $bc, $pos=BLOCK_POS_RIGHT) {
- $this->page->blocks->add_pretend_block($bc, $pos);
+ $this->page->blocks->add_fake_block($bc, $pos);
}
/**
View
@@ -406,22 +406,35 @@ public function set_default_region($defaultregion) {
* Add something that looks like a block, but which isn't an actual block_instance,
* to this page.
*
- * @param block_contents $bc the content of the block like thing.
+ * @param block_contents $bc the content of the block-like thing.
* @param string $region a block region that exists on this page.
*/
- public function add_pretend_block($bc, $region) {
+ public function add_fake_block($bc, $region) {
$this->page->initialise_theme_and_output();
if (!$this->is_known_region($region)) {
$region = $this->get_default_region();
}
if (array_key_exists($region, $this->visibleblockcontent)) {
throw new coding_exception('block_manager has already prepared the blocks in region ' .
- $region . 'for output. It is too late to add a pretend block.');
+ $region . 'for output. It is too late to add a fake block.');
}
$this->extracontent[$region][] = $bc;
}
/**
+ * When the block_manager class was created, the {@link add_fake_block()}
+ * was called add_pretend_block, which is inconsisted with
+ * {@link show_only_fake_blocks()}. To fix this inconsistency, this method
+ * was renamed to add_fake_block. Please update your code.
+ * @param block_contents $bc the content of the block-like thing.
+ * @param string $region a block region that exists on this page.
+ */
+ public function add_pretend_block($bc, $region) {
+ debugging(DEBUG_DEVELOPER, 'add_pretend_block has been renamed to add_fake_block. Please rename the method call in your code.');
+ $this->add_fake_block($bc, $region);
+ }
+
+ /**
* Checks to see whether all of the blocks within the given region are docked
*
* @see region_uses_dock
@@ -156,7 +156,7 @@
$PAGE->set_subpage($page->id);
/// Print the header, heading and tabs
-lesson_add_pretend_blocks($PAGE, $cm, $lesson, $timer);
+lesson_add_fake_blocks($PAGE, $cm, $lesson, $timer);
echo $lessonoutput->header($lesson, $cm, 'view', true, $page->id);
if ($lesson->displayleft) {
@@ -411,23 +411,23 @@ function lesson_displayleftif($lesson) {
* @param $page
* @return unknown_type
*/
-function lesson_add_pretend_blocks($page, $cm, $lesson, $timer = null) {
+function lesson_add_fake_blocks($page, $cm, $lesson, $timer = null) {
$bc = lesson_menu_block_contents($cm->id, $lesson);
if (!empty($bc)) {
$regions = $page->blocks->get_regions();
$firstregion = reset($regions);
- $page->blocks->add_pretend_block($bc, $firstregion);
+ $page->blocks->add_fake_block($bc, $firstregion);
}
$bc = lesson_mediafile_block_contents($cm->id, $lesson);
if (!empty($bc)) {
- $page->blocks->add_pretend_block($bc, $page->blocks->get_default_region());
+ $page->blocks->add_fake_block($bc, $page->blocks->get_default_region());
}
if (!empty($timer)) {
$bc = lesson_clock_block_contents($cm->id, $lesson, $timer, $page);
if (!empty($bc)) {
- $page->blocks->add_pretend_block($bc, $page->blocks->get_default_region());
+ $page->blocks->add_fake_block($bc, $page->blocks->get_default_region());
}
}
}
View
@@ -371,7 +371,7 @@
ob_end_clean();
}
- lesson_add_pretend_blocks($PAGE, $cm, $lesson, $timer);
+ lesson_add_fake_blocks($PAGE, $cm, $lesson, $timer);
echo $lessonoutput->header($lesson, $cm, $currenttab, $extraeditbuttons, $lessonpageid);
if ($attemptflag) {
echo $OUTPUT->heading(get_string('attempt', 'lesson', $retries));
@@ -553,7 +553,7 @@
$url = new moodle_url('/grade/index.php', array('id'=>$course->id));
$lessoncontent .= html_writer::link($url, get_string('viewgrades', 'lesson'), array('class'=>'centerpadded lessonbutton standardbutton'));
- lesson_add_pretend_blocks($PAGE, $cm, $lesson, $timer);
+ lesson_add_fake_blocks($PAGE, $cm, $lesson, $timer);
echo $lessonoutput->header($lesson, $cm, $currenttab, $extraeditbuttons, $lessonpageid);
echo $lessoncontent;
echo $lessonoutput->footer();
@@ -97,7 +97,7 @@
// Arrange for the navigation to be displayed.
$navbc = $attemptobj->get_navigation_panel('quiz_attempt_nav_panel', $page);
$firstregion = reset($PAGE->blocks->get_regions());
- $PAGE->blocks->add_pretend_block($navbc, $firstregion);
+ $PAGE->blocks->add_fake_block($navbc, $firstregion);
// Print the page header
$title = get_string('attempt', 'quiz', $attemptobj->get_attempt_number());
View
@@ -93,7 +93,7 @@
// Arrange for the navigation to be displayed.
$navbc = $attemptobj->get_navigation_panel('quiz_review_nav_panel', $page, $showall);
$firstregion = reset($PAGE->blocks->get_regions());
- $PAGE->blocks->add_pretend_block($navbc, $firstregion);
+ $PAGE->blocks->add_fake_block($navbc, $firstregion);
/// Print the page header
$headtags = $attemptobj->get_html_head_contributions($page);

0 comments on commit d9c26e2

Please sign in to comment.