function ctools_block_content_type_render

Output function for the 'block' content type. Outputs a block based on the module and delta supplied in the configuration.

File

plugins/content_types/block/block.inc, line 144

Code

function ctools_block_content_type_render($subtype, $conf) {
    list($module, $delta) = _ctools_block_get_module_delta($subtype, $conf);
    $info = _ctools_get_block_info($module, $delta);
    $block = module_invoke($module, 'block_view', $delta);
    if (!empty($info)) {
        // Valid PHP function names cannot contain hyphens.
        $block_delta = str_replace('-', '_', $delta);
        // Allow modules to modify the block before it is viewed, via either
        // hook_block_view_alter() or hook_block_view_MODULE_DELTA_alter().
        drupal_alter(array(
            'block_view',
            "block_view_{$module}_{$block_delta}",
        ), $block, $info);
    }
    if (empty($block)) {
        return;
    }
    $block = (object) $block;
    $block->module = $module;
    $block->delta = $delta;
    if (!isset($block->title)) {
        if ($module == 'block' && !empty($info) && isset($info->title)) {
            $block->title = $info->title;
        }
        elseif (isset($block->subject)) {
            $block->title = $block->subject;
        }
        else {
            $block->title = NULL;
        }
    }
    if (module_exists('block') && user_access('administer blocks')) {
        $block->admin_links = array(
            array(
                'title' => t('Configure block'),
                'href' => "admin/structure/block/manage/{$module}/{$delta}/configure",
                'query' => drupal_get_destination(),
            ),
        );
    }
    return $block;
}