function plus1_build_comment_jquery_widget in Plus 1 7
Create voting widget to display on the webpage.
2 calls to plus1_build_comment_jquery_widget()
- plus1_comment_view in ./
plus1.module - Implements hook_comment_view().
- theme_plus1_json_response in theme/
theme.inc - Theming function for json response.
File
- ./
plus1.module, line 327
Code
function plus1_build_comment_jquery_widget($entity_id, $tag = 'plus1_comment_vote') {
global $user;
$comment = comment_load($entity_id);
$score = plus1_get_score('comment', $comment->cid, $tag);
$logged_in = $user->uid > 0;
$is_author = $comment->uid == $user->uid;
$voted = plus1_get_votes('comment', $comment->cid, $user->uid, $tag);
$build = array(
'#theme' => 'plus1_widget__comment__' . $tag,
'#weight' => (int) variable_get('plus1_comment_widget_weight', '100'),
'#entity_type' => 'comment',
'#entity_id' => $comment->cid,
'#tag' => $tag,
'#score' => $score,
'#logged_in' => $logged_in,
'#is_author' => $is_author,
'#voted' => $voted,
'#vote_link' => 'plus1/vote/comment/' . $comment->cid . '/' . $tag,
'#undo_vote_link' => 'plus1/undo-vote/comment/' . $comment->cid . '/' . $tag,
'#link_query' => array(
'token' => drupal_get_token($comment->cid),
plus1_get_cleared_destination(),
),
'#can_vote' => user_access('plus1 vote on comment'),
'#can_undo_vote' => variable_get('plus1_comment_undo_vote', 0),
'#undo_vote_text' => check_plain(t(variable_get('plus1_comment_undo_vote_text', ''))),
'#voted_text' => check_plaint(t(variable_get('plus1_comment_voted_text', 'You voted'))),
'#vote_text' => check_plain(t(variable_get('plus1_comment_vote_text', 'Vote'))),
);
if (variable_get('plus1_add_js', 1)) {
$build['#attached']['js'][] = drupal_get_path('module', 'plus1') . '/jquery.plus1.js';
}
if (variable_get('plus1_add_css', 1)) {
$build['#attached']['css'][] = drupal_get_path('module', 'plus1') . '/plus1.css';
}
drupal_alter('plus1_widget', $build, $comment);
return $build;
}