nodecomment_nodecomment_form_content_type_render

Versions
6
nodecomment_nodecomment_form_content_type_render($subtype, $conf, $panel_args, $context)

Code

contributions/nodecomment/plugins/content_types/nodecomment_form.inc, line 16

<?php
function nodecomment_nodecomment_form_content_type_render($subtype, $conf, $panel_args, $context) {
  $node = isset($context->data) ? drupal_clone($context->data) : NULL;
  $output = '';
  $block = new stdClass();
  
  // Use comment.module with node_comment_form.inc or nodecomment with custom code depending on what the node requires
  if (module_exists('comment') && !empty($node->comment)) {
    ctools_get_content_type('node_comment_form');
    return ctools_node_comment_form_content_type_render($subtype, $conf, $panel_args, $context);
  }
  else if (module_exists('nodecomment') && !empty($node->node_comment)) {
    // find out what node type serves as the comment type for this node
    $comment_type = variable_get('comment_type_'. $node->type, variable_get('default_comment_type', ''));
    $comment_type_info = node_get_types('type', $comment_type);
    $block->title = t('Add @type', array('@type' => $comment_type_info->name));
    
    if (empty($node)) {
      $output .= t('@type form here.', array('@type' => $comment_type_info->name));
    }
    else {
      if (user_access("create $comment_type content") && $node->node_comment == COMMENT_NODE_READ_WRITE) {
        ctools_include('form');
        global $user;
        
        // create basic comment node 
        $comment = array(
  	      'uid' => $user->uid,
  	      'name' => $user->name,
  	      'type' => $comment_type,
  	      'comment_target_nid' => $node->nid,
  	    );
        
        $form_state = array(
          'ctools comment alter' => 'nodecomment',
          'args' => array($comment),
        );
        
        // make sure node.pages.inc is loaded
        module_load_include('inc', 'node', 'node.pages');
        
        $output .= ctools_build_form("{$comment_type}_node_form", $form_state);
      }
    }
  }
  
  $block->module = 'nodecomment';
  $block->delta  = $node->nid;
  $block->content = $output;

  return $block;
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.