Skip to content

Commit

Permalink
Since $PAGE knows where the adminblock should be printed, let it do t…
Browse files Browse the repository at this point in the history
…he printing.
  • Loading branch information
defacer committed Mar 2, 2005
1 parent 53dc7cc commit 6649232
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 33 deletions.
7 changes: 2 additions & 5 deletions course/format/social/format.php
Expand Up @@ -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>';
}

Expand Down Expand Up @@ -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>';
}

Expand Down
7 changes: 2 additions & 5 deletions course/format/topics/format.php
Expand Up @@ -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>';
}

Expand Down Expand Up @@ -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>';
}

Expand Down
7 changes: 2 additions & 5 deletions course/format/weeks/format.php
Expand Up @@ -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>';
}

Expand Down Expand Up @@ -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>';
}

Expand Down
7 changes: 2 additions & 5 deletions index.php
Expand Up @@ -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>';
}

Expand Down Expand Up @@ -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>';
}
?>
Expand Down
15 changes: 10 additions & 5 deletions lib/blocklib.php
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions mod/chat/view.php
Expand Up @@ -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>';
}

Expand Down
5 changes: 1 addition & 4 deletions mod/quiz/view.php
Expand Up @@ -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>';
}

Expand Down

0 comments on commit 6649232

Please sign in to comment.