function ctools_node_content_type_render

Output function for the 'node' content type.

Outputs a node based on the module and delta supplied in the configuration.

1 call to ctools_node_content_type_render()
ctools_node_content_type_admin_info in plugins/content_types/node/node.inc
Display the administrative information for a node pane.

File

plugins/content_types/node/node.inc, line 35

Code

function ctools_node_content_type_render($subtype, $conf, $panel_args) {
    $nid = $conf['nid'];
    $block = new stdClass();
    foreach (explode('/', $_GET['q']) as $id => $arg) {
        $nid = str_replace("%{$id}", $arg, $nid);
    }
    foreach ($panel_args as $id => $arg) {
        if (is_string($arg)) {
            $nid = str_replace("@{$id}", $arg, $nid);
        }
    }
    // Support node translation.
    if (module_exists('translation')) {
        if ($translations = module_invoke('translation', 'node_get_translations', $nid)) {
            if (isset($translations[$GLOBALS['language']->language])) {
                $nid = $translations[$GLOBALS['language']->language]->nid;
            }
        }
    }
    if (!is_numeric($nid)) {
        return;
    }
    $node = node_load($nid);
    if (!node_access('view', $node)) {
        return;
    }
    // Don't store viewed node data on the node, this can mess up other
    // views of the node.
    $node = clone $node;
    $block->module = 'node';
    $block->delta = $node->nid;
    // Set block->title to the plain node title, then additionally set block->title_link to
    // the node url if required. The actual link is rendered in ctools_content_render().
    $block->title = check_plain($node->title);
    if (!empty($conf['link_node_title'])) {
        $block->title_link = 'node/' . $node->nid;
    }
    if (empty($conf['leave_node_title'])) {
        $node->title = NULL;
    }
    if (!empty($conf['identifier'])) {
        $node->ctools_template_identifier = $conf['identifier'];
    }
    // Handle existing configurations with the deprecated 'teaser' option.
    if (isset($conf['teaser'])) {
        $conf['build_mode'] = $conf['teaser'] ? 'teaser' : 'full';
    }
    $block->content = node_view($node, $conf['build_mode']);
    // Hide links if they've been suppressed.
    if (empty($conf['links'])) {
        $block->content['links']['#access'] = FALSE;
    }
    return $block;
}