function plus1_build_node_jquery_widget in Plus 1 7
Create voting widget to display on the webpage.
2 calls to plus1_build_node_jquery_widget()
- plus1_node_view in ./
plus1.module - Implements hook_node_view().
- theme_plus1_json_response in theme/
theme.inc - Theming function for json response.
File
- ./
plus1.module, line 288
Code
function plus1_build_node_jquery_widget($entity_id, $tag = 'plus1_node_vote') {
global $user;
$node = node_load($entity_id);
$score = plus1_get_score('node', $node->nid, $tag);
$logged_in = $user->uid > 0;
$is_author = $node->uid == $user->uid;
$voted = plus1_get_votes('node', $node->nid, $user->uid, $tag);
$build = array(
'#theme' => 'plus1_widget__node__' . $tag,
'#weight' => (int) variable_get('plus1_node_widget_weight', '100'),
'#entity_type' => 'node',
'#entity_id' => $node->nid,
'#tag' => $tag,
'#score' => $score,
'#logged_in' => $logged_in,
'#is_author' => $is_author,
'#voted' => $voted,
'#vote_link' => 'plus1/vote/node/' . $node->nid . '/' . $tag,
'#undo_vote_link' => 'plus1/undo-vote/node/' . $node->nid . '/' . $tag,
'#link_query' => array(
'token' => drupal_get_token($node->nid),
plus1_get_cleared_destination(),
),
'#can_vote' => user_access('plus1 vote on node'),
'#can_undo_vote' => variable_get('plus1_node_undo_vote', 0),
'#undo_vote_text' => check_plain(t(variable_get('plus1_node_undo_vote_text', ''))),
'#voted_text' => check_plain(t(variable_get('plus1_node_voted_text', 'You voted'))),
'#vote_text' => check_plain(t(variable_get('plus1_node_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, $node);
return $build;
}