View source
<?php
function panels_node_panels_content_types() {
$items['node'] = array(
'callback' => 'panels_content_node',
'admin' => 'panels_admin_node',
);
return $items;
}
function panels_content_node($conf) {
$node = node_load($conf['nid']);
if (!node_access('view', $node)) {
return;
}
if ($conf['suppress_title']) {
$node->title = '';
}
$output = node_view($node, $conf['teaser'], FALSE, $conf['links']);
return $output;
}
function panels_admin_node($op, &$arg, $arg2 = NULL) {
switch ($op) {
case 'list':
$conf = $arg;
$node = node_load($conf['nid']);
return '<strong>Node</strong>: ' . check_plain($node->title);
case 'add button':
$form['nid'] = array(
'#title' => t('Enter the title or NID of a post'),
'#type' => 'textfield',
'#maxlength' => 512,
'#autocomplete_path' => 'panels/node/autocomplete',
'#weight' => -10,
);
$form['submit'] = array(
'#type' => 'button',
'#value' => t('Add post'),
);
$form['#prefix'] = '<div class="container-inline">';
$form['#suffix'] = '</div>';
return $form;
case 'add':
if ($_POST['op'] != t('Add post')) {
return;
}
$form =& $arg;
if (is_numeric($form['nid'])) {
$conf = array();
$conf['nid'] = $form['nid'];
}
else {
$conf = db_fetch_array(db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE LOWER(title) = LOWER('%s')"), $form['nid']));
if (!$conf['nid']) {
drupal_set_message(t('Unable to find "%s"', array(
'%s' => check_plain($form['nid']),
)));
return;
}
}
$conf['teaser'] = TRUE;
return $conf;
case 'edit':
$conf =& $arg;
$form['nid'] = array(
'#type' => 'hidden',
'#default_value' => $conf['nid'],
);
$form['teaser'] = array(
'#title' => t('Teaser'),
'#type' => 'checkbox',
'#default_value' => $conf['teaser'],
'#description' => t('Check here to show only the node teaser'),
);
$form['links'] = array(
'#type' => 'checkbox',
'#default_value' => $conf['links'],
'#title' => t('Display links'),
'#description' => t('Check here to display the links with the post.'),
);
$form['suppress_title'] = array(
'#type' => 'checkbox',
'#default_value' => $conf['suppress_title'],
'#title' => t('Suppress node title'),
'#description' => t('Check here to suppress the node title.'),
);
return $form;
case 'validate':
$form =& $arg;
return;
case 'save':
$form =& $arg;
return $form;
}
}