00001 <?php
00002
00003
00004
00005
00006
00007
00008 function panels_node_meta_panels_content_types() {
00009 $items['node_meta'] = array(
00010 'single' => TRUE,
00011 'content_types' => 'panels_admin_content_types_node_meta',
00012 'render callback' => 'panels_content_node_meta',
00013 'add callback' => 'panels_admin_edit_node_meta',
00014 'edit callback' => 'panels_admin_edit_node_meta',
00015 'title callback' => 'panels_admin_title_node_meta',
00016 );
00017 return $items;
00018 }
00019
00020
00021
00022
00023 function panels_admin_content_types_node_meta() {
00024 return array(
00025 'content' => array(
00026 'title' => t('Node meta data'),
00027 'icon' => 'icon_node.png',
00028 'path' => panels_get_path('content_types/node'),
00029 'description' => t('Meta data of the referenced node.'),
00030 'required context' => new panels_required_context(t('Node'), 'node'),
00031 'category' => array(t('Node context'), -9),
00032 ),
00033 );
00034 }
00035
00036 function panels_content_node_meta($conf, $panel_args, $context) {
00037 if (!empty($context) && empty($context->data)) {
00038 return;
00039 }
00040
00041 $node = isset($context->data) ? drupal_clone($context->data) : NULL;
00042 $block = new stdClass();
00043 $block->module = 'node';
00044 $block->delta = $node->nid;
00045
00046 if (empty($node)) {
00047 $block->delta = 'placeholder';
00048 $block->subject = t('Node title.');
00049 $block->content = t('Node meta content goes here.');
00050 }
00051 else {
00052 $block->content = theme('panels_node_meta', $node, $conf);
00053 }
00054 if (empty($block->content)) {
00055 return;
00056 }
00057
00058 if (node_access('update', $node)) {
00059 $block->admin_links['update'] = array(
00060 'title' => t('Edit node'),
00061 'alt' => t("Edit this node"),
00062 'href' => "node/$node->nid/edit",
00063 'query' => drupal_get_destination(),
00064 );
00065 }
00066
00067 return $block;
00068 }
00069
00070
00071
00072
00073
00074 function theme_panels_node_meta($node, $conf) {
00075 $output = '';
00076 if ($conf['title']) {
00077 $output .= '<div class="node-title">';
00078 $output .= check_plain($node->title);
00079 $output .= '</div>';
00080 }
00081 if ($conf['author']) {
00082 $output .= '<div class="node-author">';
00083
00084 $output .= theme('username', $node, 'panels_node_meta_'. $node->type);
00085 $output .= '</div>';
00086 }
00087 if ($conf['created']) {
00088 $output .= '<div class="node-created">';
00089 $output .= format_date($node->created);
00090 $output .= '</div>';
00091 }
00092 if ($conf['changed']) {
00093 $output .= '<div class="node-modified">';
00094 $output .= format_date($node->changed);
00095 $output .= '</div>';
00096 }
00097
00098 return $output;
00099 }
00100
00101
00102
00103
00104 function panels_admin_edit_node_meta($id, $parents, $conf = array()) {
00105 $conf += array(
00106 'override_title' => FALSE,
00107 'override_title_text' => '',
00108 'title' => TRUE,
00109 'author' => FALSE,
00110 'created' => FALSE,
00111 'modified' => FALSE,
00112 );
00113
00114 $form['aligner_start'] = array(
00115 '#value' => '<div class="option-text-aligner">',
00116 );
00117 $form['override_title'] = array(
00118 '#type' => 'checkbox',
00119 '#default_value' => $conf['override_title'],
00120 '#title' => t('Override title'),
00121 '#id' => 'override-title-checkbox',
00122 );
00123 $form['override_title_text'] = array(
00124 '#type' => 'textfield',
00125 '#default_value' => $conf['override_title_text'],
00126 '#size' => 35,
00127 '#id' => 'override-title-textfield',
00128 );
00129 $form['aligner_stop'] = array(
00130 '#value' => '</div><div style="clear: both; padding: 0; margin: 0"></div>',
00131 );
00132 $form['title'] = array(
00133 '#title' => t('Title'),
00134 '#type' => 'checkbox',
00135 '#default_value' => $conf['title'],
00136 '#description' => t('Check here to display the title of the node.'),
00137 );
00138 $form['author'] = array(
00139 '#title' => t('Author'),
00140 '#type' => 'checkbox',
00141 '#default_value' => $conf['author'],
00142 '#description' => t('Check here to display the author of the node.'),
00143 );
00144 $form['created'] = array(
00145 '#title' => t('Created date'),
00146 '#type' => 'checkbox',
00147 '#default_value' => $conf['created'],
00148 '#description' => t('Check here to display the creation date of the node.'),
00149 );
00150 $form['changed'] = array(
00151 '#title' => t('Modified date'),
00152 '#type' => 'checkbox',
00153 '#default_value' => $conf['modified'],
00154 '#description' => t('Check here to display the modification date of the node.'),
00155 );
00156 return $form;
00157 }
00158
00159 function panels_admin_title_node_meta($conf, $context) {
00160 return t('"@s" meta content', array('@s' => $context->identifier));
00161 }
00162