function ajax_comments_handler_field_ajax_add_comment::render in AJAX Comments 7
Render the field.
Parameters
array $values: The values retrieved from the database.
Overrides views_handler_field_comment_node_link::render
File
- views/
ajax_comments_handler_field_ajax_add_comment.inc, line 52
Class
Code
function render($values) {
if (user_access('post comments') && ($node = $this
->get_value($values))) {
// Add Comment wrapper
$result = '<div class="comment-wrapper views-comment-wrapper-nid-' . $node->nid . '">';
// Add result text
$result .= '<p class="views-comment-result-nid-' . $node->nid . '" style="display: none;">' . t('Your comment has been posted.') . '</p>';
// Add dummy comment
$result .= '<div class="ajax-comment-wrapper ajax-comment-dummy-comment"></div>';
// Generate a unique token to prevent illegitimate requests.
$options = array(
'attributes' => array(
'class' => array(
'use-ajax-comments',
'ajax-comments-reply-' . $node->nid . '-0',
),
),
);
$path = 'comment/reply/' . $node->nid . '/0/' . $this->options['submit_action'];
$text = !empty($this->options['text']) ? $this->options['text'] : t('Add new comment');
// Close Comment wrapper
$result .= l($text, $path, $options) . '</div>';
return $result;
}
}