You are here

function panels_content_node_comment_form in Panels 5.2

Same name and namespace in other branches
  1. 6.2 content_types/node_comment_form.inc \panels_content_node_comment_form()

Output function for the 'node' content type. Outputs a node based on the module and delta supplied in the configuration.

1 string reference to 'panels_content_node_comment_form'
panels_node_comment_form_panels_content_types in content_types/node_comment_form.inc
Callback function to supply a list of content types.

File

content_types/node_comment_form.inc, line 27

Code

function panels_content_node_comment_form($conf, $panel_args, $context) {
  $node = isset($context->data) ? drupal_clone($context->data) : NULL;
  $block = new stdClass();
  $block->module = 'comments';
  $block->delta = $node->nid;
  $block->subject = t('Add comment');
  if (empty($node)) {
    $block->content = t('Comment form here.');
  }
  else {
    if (user_access('post comments') && node_comment_mode($node->nid) == COMMENT_NODE_READ_WRITE) {
      $form = drupal_retrieve_form('comment_form', array(
        'nid' => $node->nid,
      ));
      $form['#action'] = url($_GET['q'], NULL, 'new');
      $form['#redirect'] = array(
        $_GET['q'],
        NULL,
        'new',
      );
      drupal_process_form('comment_form', $form);
      drupal_prepare_form('comment_form', $form);
      $block->content = drupal_render_form('comment_form', $form);
    }
  }
  return $block;
}