function ctools_token_content_type_render

Render the custom content type.

File

plugins/content_types/token/token.inc, line 67

Code

function ctools_token_content_type_render($subtype, $conf, $panel_args, $context) {
    if (empty($context) || empty($context->data)) {
        return FALSE;
    }
    $sanitize = $conf['sanitize'];
    $entity = $context->data;
    list($entity_type, $name) = explode(':', $subtype, 2);
    $info = token_info();
    $values = token_generate($entity_type, array(
        $name => $name,
    ), array(
        $entity_type => $entity,
    ), array(
        'sanitize' => $sanitize,
    ));
    if (!isset($values[$name])) {
        return;
    }
    // Build the content type block.
    $block = new stdClass();
    $block->module = 'ctools';
    $block->title = $info['tokens'][$entity_type][$name]['name'];
    $block->content = $values[$name];
    $block->delta = str_replace('_', '-', $entity_type . '-' . $name);
    return $block;
}