Commit d9c26e21 authored by Tim Hunt's avatar Tim Hunt Committed by Petr Skoda
Browse files

blocklib MDL-25654 fix API inconsistency be renaming add_pretend_block 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.
parent 958c04e4
......@@ -176,7 +176,7 @@ class core_calendar_renderer extends plugin_renderer_base {
* @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);
}
/**
......
......@@ -406,21 +406,34 @@ class block_manager {
* 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
*
......
......@@ -156,7 +156,7 @@ $PAGE->set_url('/mod/lesson/view.php', array('id' => $cm->id, 'pageid' => $page-
$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());
}
}
}
......
......@@ -371,7 +371,7 @@ if ($pageid != LESSON_EOL) {
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 @@ if ($pageid != LESSON_EOL) {
$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());
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment