Пример #1
0
/**
 * Prints blocks for a given position
 *
 * @param array $pageblocks An array of blocks organized by position
 * @param char $position Position that we are currently printing
 * @return void
 **/
function page_print_position($pageblocks, $position, $width)
{
    global $PAGE, $THEME;
    $editing = $PAGE->user_is_editing();
    /// Figure out an appropriate ID
    switch ($position) {
        case BLOCK_POS_LEFT:
            $id = 'left';
            break;
        case BLOCK_POS_RIGHT:
            $id = 'right';
            break;
        case BLOCK_POS_CENTER:
            $id = 'middle';
            break;
        default:
            $id = $position;
            break;
    }
    /// Figure out the width - more for routine than being functional.  May want to impose a minimum width though
    $width = bounded_number($width, blocks_preferred_width($pageblocks[$position]), $width);
    $widthstyle = "";
    if ($width > 1) {
        $widthstyle = 'style="width: ' . $width . 'px"';
    }
    if ($editing || blocks_have_content($pageblocks, $position)) {
        /// Print it
        echo "<td {$widthstyle} id=\"{$id}-column\">";
        print_spacer(1, $width, false);
        if (!empty($THEME->roundcorners)) {
            echo '<div class="bt"><div></div></div>';
            echo '<div class="i1"><div class="i2"><div class="i3">';
        }
        page_blocks_print_group($pageblocks, $position);
        if (!empty($THEME->roundcorners)) {
            echo '</div></div></div>';
            echo '<div class="bb"><div></div></div>';
        }
        echo '</td>';
    } else {
        // just print space to keep width consistent
        echo "<td {$widthstyle} id=\"{$id}-column\">";
        print_spacer(1, $width, false);
        echo "</td>";
    }
}
/**
 * Prints blocks for a given position
 *
 * @param array $pageblocks An array of blocks organized by position
 * @param char $position Position that we are currently printing
 * @return void
 **/
function page_print_position($pageblocks, $position, $width)
{
    global $PAGE, $THEME;
    $editing = $PAGE->user_is_editing();
    if ($editing || blocks_have_content($pageblocks, $position)) {
        /// Figure out an appropriate ID
        switch ($position) {
            case BLOCK_POS_LEFT:
                $id = 'left';
                break;
            case BLOCK_POS_RIGHT:
                $id = 'right';
                break;
            case BLOCK_POS_CENTER:
                $id = 'middle';
                break;
            default:
                $id = $position;
                break;
        }
        /// Figure out the width - more for routine than being functional.  May want to impose a minimum width though
        $width = bounded_number($width, blocks_preferred_width($pageblocks[$position]), $width);
        /// Print it
        if (is_numeric($width)) {
            // default to px  MR-263
            $tdwidth = $width . 'px';
        } else {
            $tdwidth = $width;
        }
        echo "<td style=\"width: {$tdwidth}\" id=\"{$id}-column\">";
        if (is_numeric($width) or strpos($width, 'px')) {
            print_spacer(1, $width, false);
        }
        print_container_start();
        if ($position == BLOCK_POS_CENTER) {
            echo skip_main_destination();
            page_frontpage_settings();
        }
        page_blocks_print_group($pageblocks, $position);
        print_container_end();
        echo '</td>';
    } else {
        // Empty column - no class, style or width
        /// Figure out an appropriate ID
        switch ($position) {
            case BLOCK_POS_LEFT:
                $id = 'left';
                break;
            case BLOCK_POS_RIGHT:
                $id = 'right';
                break;
            case BLOCK_POS_CENTER:
                $id = 'middle';
                break;
            default:
                $id = $position;
                break;
        }
        // we still want to preserve values unles
        if ($width != '0') {
            if (is_numeric($width)) {
                // default to px  MR-263
                $tdwidth = $width . 'px';
            } else {
                $tdwidth = $width;
            }
            echo '<td style="width:' . $tdwidth . '" id="' . $id . '-column" > ';
            if ($width != '0' and is_numeric($width) or strpos($width, 'px')) {
                print_spacer(1, $width, false);
            }
            echo "</td>";
        } else {
            echo '<td></td>';
            // 0 means no column anyway
        }
    }
}