Commit 66492322 authored by defacer's avatar defacer
Browse files

Since $PAGE knows where the adminblock should be printed, let it do the printing.
parent 53dc7cc6
......@@ -27,7 +27,7 @@
if(blocks_have_content($pageblocks[BLOCK_POS_LEFT]) || $editing) {
echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_LEFT]);
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
echo '</td>';
}
......@@ -56,10 +56,7 @@
// The right column
if(blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing) {
echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_RIGHT]);
if ($editing) {
blocks_print_adminblock($PAGE, $pageblocks);
}
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
echo '</td>';
}
......
......@@ -65,7 +65,7 @@
if (blocks_have_content($pageblocks[BLOCK_POS_LEFT]) || $editing) {
echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_LEFT]);
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
echo '</td>';
}
......@@ -256,10 +256,7 @@
// The right column
if (blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing) {
echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_RIGHT]);
if ($editing) {
blocks_print_adminblock($PAGE, $pageblocks);
}
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
echo '</td>';
}
......
......@@ -56,7 +56,7 @@
if (blocks_have_content($pageblocks[BLOCK_POS_LEFT]) || $editing) {
echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_LEFT]);
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
echo '</td>';
}
......@@ -246,10 +246,7 @@
// The right column
if (blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing) {
echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_RIGHT]);
if ($editing) {
blocks_print_adminblock($PAGE, $pageblocks);
}
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
echo '</td>';
}
......
......@@ -71,7 +71,7 @@
if(blocks_have_content($pageblocks[BLOCK_POS_LEFT]) || $editing) {
echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_LEFT]);
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
echo '</td>';
}
......@@ -186,10 +186,7 @@
echo '<div align="center">'.update_course_icon($SITE->id).'</div>';
echo '<br />';
}
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_RIGHT]);
if ($editing) {
blocks_print_adminblock($PAGE, $pageblocks);
}
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
echo '</td>';
}
?>
......
......@@ -202,17 +202,17 @@ function blocks_have_content(&$instances) {
// This function prints one group of blocks in a page
// Parameters passed by reference for speed; they are not modified.
function blocks_print_group(&$page, &$instances) {
if(empty($instances)) {
function blocks_print_group(&$page, &$pageblocks, $position) {
if(empty($pageblocks[$position])) {
return;
}
$isediting = $page->user_is_editing();
$maxweight = max(array_keys($instances));
$maxweight = max(array_keys($pageblocks[$position]));
foreach($instances as $instance) {
foreach($pageblocks[$position] as $instance) {
$block = blocks_get_record($instance->blockid);
if(!$block->visible) {
// Disabled by the admin
......@@ -250,6 +250,11 @@ function blocks_print_group(&$page, &$instances) {
$obj->_print_block();
}
}
if($page->blocks_default_position() == $position) {
blocks_print_adminblock($page, $pageblocks);
}
}
// This iterates over an array of blocks and calculates the preferred width
......
......@@ -71,10 +71,7 @@
if(blocks_have_content($pageblocks[BLOCK_POS_LEFT]) || $PAGE->user_is_editing()) {
echo '<td style="width: '.$blocks_preferred_width.'px;" id="left-column">';
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_LEFT]);
if ($PAGE->user_is_editing()) {
blocks_print_adminblock($PAGE, $pageblocks);
}
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
echo '</td>';
}
......
......@@ -69,10 +69,7 @@
if(blocks_have_content($pageblocks[BLOCK_POS_LEFT]) || $PAGE->user_is_editing()) {
echo '<td style="width: '.$blocks_preferred_width.'px;" id="left-column">';
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_LEFT]);
if ($PAGE->user_is_editing()) {
blocks_print_adminblock($PAGE, $pageblocks);
}
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
echo '</td>';
}
......
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