function views_block_view

Implements hook_block_view().

File

./views.module, line 817

Code

function views_block_view($delta) {
    // If this is 32, this should be an md5 hash.
    if (strlen($delta) == 32) {
        $hashes = variable_get('views_block_hashes', array());
        if (!empty($hashes[$delta])) {
            $delta = $hashes[$delta];
        }
    }
    // This indicates it's a special one.
    if (substr($delta, 0, 1) == '-') {
        list(, $type, $name, $display_id) = explode('-', $delta);
        // Put the - back on.
        $type = '-' . $type;
        if ($view = views_get_view($name)) {
            if ($view->access($display_id)) {
                $view->set_display($display_id);
                if (isset($view->display_handler)) {
                    $output = $view->display_handler
                        ->view_special_blocks($type);
                    // Before returning the block output, convert it to a renderable
                    // array with contextual links.
                    views_add_block_contextual_links($output, $view, $display_id, 'special_block_' . $type);
                    $view->destroy();
                    return $output;
                }
            }
            $view->destroy();
        }
    }
    // If the delta doesn't contain valid data return nothing.
    $explode = explode('-', $delta);
    if (count($explode) != 2) {
        return;
    }
    list($name, $display_id) = $explode;
    // Load the view.
    if ($view = views_get_view($name)) {
        if ($view->access($display_id)) {
            $output = $view->execute_display($display_id);
            // Before returning the block output, convert it to a renderable array
            // with contextual links.
            views_add_block_contextual_links($output, $view, $display_id);
            $view->destroy();
            return $output;
        }
        $view->destroy();
    }
}