node_title.inc in Chaos Tool Suite (ctools) 6
File
plugins/content_types/node_context/node_title.inc
View source
<?php
$plugin = array(
'single' => TRUE,
'title' => t('Node title'),
'icon' => 'icon_node.png',
'description' => t('The title of the referenced node.'),
'required context' => new ctools_context_required(t('Node'), 'node'),
'category' => t('Node'),
'defaults' => array(
'link' => TRUE,
),
);
function ctools_node_title_content_type_render($subtype, $conf, $panel_args, $context) {
if (empty($context) || empty($context->data)) {
return;
}
$node = $context->data;
$type = node_get_types('type', $node->type);
$block = new stdClass();
$block->module = 'node_title';
$block->title = $type->title_label;
$block->content = !empty($conf['link']) ? l($node->title, 'node/' . $node->nid) : check_plain($node->title);
$block->delta = $node->nid;
return $block;
}
function ctools_node_title_content_type_edit_form(&$form, &$form_state) {
$conf = $form_state['conf'];
$form['link'] = array(
'#title' => t('Link to node'),
'#type' => 'checkbox',
'#default_value' => $conf['link'],
'#description' => t('Check here to make the title link to the node.'),
);
}
function ctools_node_title_content_type_edit_form_submit(&$form, &$form_state) {
foreach (array_keys($form_state['plugin']['defaults']) as $key) {
$form_state['conf'][$key] = $form_state['values'][$key];
}
}
function ctools_node_title_content_type_admin_title($subtype, $conf, $context) {
return t('"@s" title', array(
'@s' => $context->identifier,
));
}