00001 <?php
00002
00003
00004
00005
00006
00007
00008 function panels_node_content_panels_content_types() {
00009 $items['node_content'] = array(
00010 'title' => t('Node content'),
00011 'weight' => -10,
00012
00013 'single' => TRUE,
00014 'content_types' => 'panels_admin_content_types_node_content',
00015 'render callback' => 'panels_content_node_content',
00016 'add callback' => 'panels_admin_edit_node_content',
00017 'edit callback' => 'panels_admin_edit_node_content',
00018 'title callback' => 'panels_admin_title_node_content',
00019 );
00020 return $items;
00021 }
00022
00023
00024
00025
00026 function panels_admin_content_types_node_content() {
00027 return array(
00028 'content' => array(
00029 'title' => t('Node content'),
00030 'icon' => 'icon_node.png',
00031 'path' => panels_get_path('content_types/node'),
00032 'description' => t('The content of the referenced node.'),
00033 'required context' => new panels_required_context(t('Node'), 'node'),
00034 'category' => array(t('Node context'), -9),
00035 ),
00036 );
00037 }
00038
00039
00040
00041
00042
00043 function panels_content_node_content($conf, $panel_args, $context) {
00044 if (!empty($context) && empty($context->data)) {
00045 return;
00046 }
00047
00048 $node = isset($context->data) ? drupal_clone($context->data) : NULL;
00049 $block = new stdClass();
00050 $block->module = 'node';
00051 $block->delta = $node->nid;
00052
00053 if (empty($node)) {
00054 $block->delta = 'placeholder';
00055 $block->subject = t('Node title.');
00056 $block->content = t('Node content goes here.');
00057 }
00058 else {
00059 if (!empty($conf['identifier'])) {
00060 $node->panel_identifier = $conf['identifier'];
00061 }
00062
00063 $block->subject = $node->title;
00064
00065 unset($node->title);
00066 $block->content = panels_admin_node_content($node, $conf);
00067 }
00068
00069 if (node_access('update', $node)) {
00070 $block->admin_links['update'] = array(
00071 'title' => t('Edit node'),
00072 'alt' => t("Edit this node"),
00073 'href' => "node/$node->nid/edit",
00074 'query' => drupal_get_destination(),
00075 );
00076 }
00077
00078 if (!empty($conf['link']) && $node) {
00079 $block->title_link = "node/$node->nid";
00080 }
00081
00082 return $block;
00083 }
00084
00085 function panels_admin_node_content($node, $conf) {
00086
00087 $node->body = str_replace('<!--break-->', '', $node->body);
00088
00089
00090
00091 if (node_hook($node, 'view')) {
00092 $node = node_invoke($node, 'view', $conf['teaser'], $conf['page']);
00093 }
00094 else {
00095 $node = node_prepare($node, $conf['teaser']);
00096 }
00097
00098 if (empty($conf['no_extras'])) {
00099
00100 node_invoke_nodeapi($node, 'view', $conf['teaser'], $conf['page']);
00101 }
00102
00103 if ($conf['links']) {
00104 $node->links = module_invoke_all('link', 'node', $node, $conf['teaser']);
00105
00106 foreach (module_implements('link_alter') AS $module) {
00107 $function = $module .'_link_alter';
00108 $function($node, $node->links);
00109 }
00110 }
00111
00112
00113
00114 $content = drupal_render($node->content);
00115 if ($conf['teaser']) {
00116 $node->teaser = $content;
00117 unset($node->body);
00118 }
00119 else {
00120 $node->body = $content;
00121 unset($node->teaser);
00122 }
00123
00124
00125 node_invoke_nodeapi($node, 'alter', $conf['teaser'], $conf['page']);
00126
00127 return theme('node', $node, $conf['teaser'], $conf['page']);
00128 }
00129
00130
00131
00132
00133 function panels_admin_edit_node_content($id, $parents, $conf = array()) {
00134 if ($conf == array()) {
00135 $conf = array(
00136 'links' => TRUE,
00137 'page' => TRUE,
00138 'no_extras' => TRUE,
00139 );
00140 }
00141
00142 $form['aligner_start'] = array(
00143 '#value' => '<div class="option-text-aligner">',
00144 );
00145 $form['override_title'] = array(
00146 '#type' => 'checkbox',
00147 '#default_value' => $conf['override_title'],
00148 '#title' => t('Override title'),
00149 '#id' => 'override-title-checkbox',
00150 );
00151 $form['override_title_text'] = array(
00152 '#type' => 'textfield',
00153 '#default_value' => $conf['override_title_text'],
00154 '#size' => 35,
00155 '#id' => 'override-title-textfield',
00156 );
00157 $form['aligner_stop'] = array(
00158 '#value' => '</div><div style="clear: both; padding: 0; margin: 0"></div>',
00159 );
00160 $form['link'] = array(
00161 '#title' => t('Link title to node'),
00162 '#type' => 'checkbox',
00163 '#default_value' => $conf['link'],
00164 '#description' => t('Check here to make the title link to the node.'),
00165 );
00166 $form['teaser'] = array(
00167 '#title' => t('Teaser'),
00168 '#type' => 'checkbox',
00169 '#default_value' => $conf['teaser'],
00170 '#description' => t('Check here to show only the node teaser.'),
00171 );
00172 $form['page'] = array(
00173 '#type' => 'checkbox',
00174 '#default_value' => $conf['page'],
00175 '#title' => t('Node page'),
00176 '#description' => t('Check here if the node is being displayed on a page by itself.'),
00177 );
00178 $form['links'] = array(
00179 '#type' => 'checkbox',
00180 '#default_value' => $conf['links'],
00181 '#title' => t('Display links'),
00182 '#description' => t('Check here to display the links with the post.'),
00183 );
00184
00185 $form['no_extras'] = array(
00186 '#type' => 'checkbox',
00187 '#default_value' => $conf['no_extras'],
00188 '#title' => t('No extras'),
00189 '#description' => t('Check here to disable additions that modules might make to the node, such as file attachments and CCK fields; this should just display the basic teaser or body.'),
00190 );
00191
00192 $form['identifier'] = array(
00193 '#type' => 'textfield',
00194 '#default_value' => $conf['identifier'],
00195 '#title' => t('Identifier'),
00196 '#description' => t('Whatever is placed here will appear in $node->panel_identifier to make it easier to theme a node or part of a node as necessary.'),
00197 );
00198
00199 return $form;
00200 }
00201
00202 function panels_admin_title_node_content($conf, $context) {
00203 return t('"@s" content', array('@s' => $context->identifier));
00204 }
00205