Skip to content

Commit

Permalink
blocklib MDL-25654 fix API inconsistency be renaming add_pretend_bloc…
Browse files Browse the repository at this point in the history
…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
timhunt authored and skodak committed Dec 20, 2010
1 parent 958c04e commit d9c26e2
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion calendar/renderer.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function fake_block_threemonths(calendar_information $calendar) {
* @param mixed $pos BLOCK_POS_RIGHT | BLOCK_POS_LEFT * @param mixed $pos BLOCK_POS_RIGHT | BLOCK_POS_LEFT
*/ */
public function add_pretend_calendar_block(block_contents $bc, $pos=BLOCK_POS_RIGHT) { 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);
} }


/** /**
Expand Down
19 changes: 16 additions & 3 deletions lib/blocklib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -406,21 +406,34 @@ public function set_default_region($defaultregion) {
* Add something that looks like a block, but which isn't an actual block_instance, * Add something that looks like a block, but which isn't an actual block_instance,
* to this page. * 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. * @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(); $this->page->initialise_theme_and_output();
if (!$this->is_known_region($region)) { if (!$this->is_known_region($region)) {
$region = $this->get_default_region(); $region = $this->get_default_region();
} }
if (array_key_exists($region, $this->visibleblockcontent)) { if (array_key_exists($region, $this->visibleblockcontent)) {
throw new coding_exception('block_manager has already prepared the blocks in region ' . 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; $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 * Checks to see whether all of the blocks within the given region are docked
* *
Expand Down
2 changes: 1 addition & 1 deletion mod/lesson/continue.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
$PAGE->set_subpage($page->id); $PAGE->set_subpage($page->id);


/// Print the header, heading and tabs /// 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); echo $lessonoutput->header($lesson, $cm, 'view', true, $page->id);


if ($lesson->displayleft) { if ($lesson->displayleft) {
Expand Down
8 changes: 4 additions & 4 deletions mod/lesson/locallib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -411,23 +411,23 @@ function lesson_displayleftif($lesson) {
* @param $page * @param $page
* @return unknown_type * @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); $bc = lesson_menu_block_contents($cm->id, $lesson);
if (!empty($bc)) { if (!empty($bc)) {
$regions = $page->blocks->get_regions(); $regions = $page->blocks->get_regions();
$firstregion = reset($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); $bc = lesson_mediafile_block_contents($cm->id, $lesson);
if (!empty($bc)) { 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)) { if (!empty($timer)) {
$bc = lesson_clock_block_contents($cm->id, $lesson, $timer, $page); $bc = lesson_clock_block_contents($cm->id, $lesson, $timer, $page);
if (!empty($bc)) { 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());
} }
} }
} }
Expand Down
4 changes: 2 additions & 2 deletions mod/lesson/view.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@
ob_end_clean(); 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); echo $lessonoutput->header($lesson, $cm, $currenttab, $extraeditbuttons, $lessonpageid);
if ($attemptflag) { if ($attemptflag) {
echo $OUTPUT->heading(get_string('attempt', 'lesson', $retries)); echo $OUTPUT->heading(get_string('attempt', 'lesson', $retries));
Expand Down Expand Up @@ -553,7 +553,7 @@
$url = new moodle_url('/grade/index.php', array('id'=>$course->id)); $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')); $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 $lessonoutput->header($lesson, $cm, $currenttab, $extraeditbuttons, $lessonpageid);
echo $lessoncontent; echo $lessoncontent;
echo $lessonoutput->footer(); echo $lessonoutput->footer();
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/attempt.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
// Arrange for the navigation to be displayed. // Arrange for the navigation to be displayed.
$navbc = $attemptobj->get_navigation_panel('quiz_attempt_nav_panel', $page); $navbc = $attemptobj->get_navigation_panel('quiz_attempt_nav_panel', $page);
$firstregion = reset($PAGE->blocks->get_regions()); $firstregion = reset($PAGE->blocks->get_regions());
$PAGE->blocks->add_pretend_block($navbc, $firstregion); $PAGE->blocks->add_fake_block($navbc, $firstregion);


// Print the page header // Print the page header
$title = get_string('attempt', 'quiz', $attemptobj->get_attempt_number()); $title = get_string('attempt', 'quiz', $attemptobj->get_attempt_number());
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/review.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
// Arrange for the navigation to be displayed. // Arrange for the navigation to be displayed.
$navbc = $attemptobj->get_navigation_panel('quiz_review_nav_panel', $page, $showall); $navbc = $attemptobj->get_navigation_panel('quiz_review_nav_panel', $page, $showall);
$firstregion = reset($PAGE->blocks->get_regions()); $firstregion = reset($PAGE->blocks->get_regions());
$PAGE->blocks->add_pretend_block($navbc, $firstregion); $PAGE->blocks->add_fake_block($navbc, $firstregion);


/// Print the page header /// Print the page header
$headtags = $attemptobj->get_html_head_contributions($page); $headtags = $attemptobj->get_html_head_contributions($page);
Expand Down

0 comments on commit d9c26e2

Please sign in to comment.