node_comment_form.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: node_comment_form.inc,v 1.1.2.9 2008/08/03 03:12:07 sdboyer Exp $
00003 
00004 
00005 /**
00006  * Callback function to supply a list of content types.
00007  */
00008 function panels_node_comment_form_panels_content_types() {
00009   if (module_exists('comment')) {
00010     $items['node_comment_form'] = array(
00011       'title' => t('Node comment form'),
00012       // only provides a single content type
00013       'single' => TRUE,
00014       'content_types' => 'panels_admin_content_types_node_comment_form',
00015       'render callback' => 'panels_content_node_comment_form',
00016       'add callback' => 'panels_admin_edit_node_comment_form',
00017       'edit callback' => 'panels_admin_edit_node_comment_form',
00018       'title callback' => 'panels_admin_title_node_comment_form',
00019     );
00020     return $items;
00021   }
00022 }
00023 
00024 /**
00025  * Output function for the 'node' content type. Outputs a node
00026  * based on the module and delta supplied in the configuration.
00027  */
00028 function panels_content_node_comment_form($conf, $panel_args, $context) {
00029   $node = isset($context->data) ? drupal_clone($context->data) : NULL;
00030   $block = new stdClass();
00031   $block->module = 'comments';
00032   $block->delta  = $node->nid;
00033 
00034   $block->subject = t('Add comment');
00035 
00036   if (empty($node)) {
00037     $block->content = t('Comment form here.');
00038   }
00039   else {
00040     if (user_access('post comments') && node_comment_mode($node->nid) == COMMENT_NODE_READ_WRITE) {
00041       $form = drupal_retrieve_form('comment_form', array('nid' => $node->nid));
00042       $form['#action'] = url($_GET['q'], NULL, 'new');
00043       $form['#redirect'] = array($_GET['q'], NULL, 'new');
00044       drupal_process_form('comment_form', $form);
00045       drupal_prepare_form('comment_form', $form);
00046       $block->content = drupal_render_form('comment_form', $form);
00047     }
00048   }
00049 
00050   return $block;
00051 }
00052 
00053 /**
00054  * Return all content types available.
00055  */
00056 function panels_admin_content_types_node_comment_form() {
00057   return array(
00058     'comment_form' => array(
00059       'title' => t('Comment form'),
00060       'icon' => 'icon_node.png',
00061       'path' => panels_get_path('content_types/node'),
00062       'description' => t('A form to add a new comment.'),
00063       'required context' => new panels_required_context(t('Node'), 'node'),
00064       'category' => array(t('Node context'), -9),
00065     ),
00066   );
00067 }
00068 
00069 function panels_admin_title_node_comment_form($conf, $context) {
00070   return t('"@s" comment form', array('@s' => $context->identifier));
00071 }
00072 

Generated on Sun Feb 5 05:00:12 2012 for Panels 2 by  doxygen 1.5.6