nodecomment_nodecomment_form_content_type_render($subtype, $conf, $panel_args, $context)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;
}
?>