function theme_vote_up_down_widget in Vote Up/Down 5
File
- ./
vote_up_down.module, line 491 - vote_up_down is a module that adds a widget for +1/-1 votes on nodes. It depends upon Voting API. It's based upon "simplevote.module".
Code
function theme_vote_up_down_widget($cid, $type) {
global $user;
if (user_access('view up-down vote')) {
$output = '<div class="vote-up-down-widget">';
if (user_access('use up-down vote') && ($user->uid || variable_get('vote_up_down_anonymous_vote', 0))) {
$user_vote = votingapi_get_user_votes($type, $cid, _vote_up_down_get_uid());
if ($user_vote[0]->value > 0) {
$class = 'vote-up-act';
$class2 = 'vote-down-inact';
}
else {
if ($user_vote[0]->value < 0) {
$class = 'vote-up-inact';
$class2 = 'vote-down-act';
}
else {
$class = 'vote-up-inact';
$class2 = 'vote-down-inact';
}
}
$token = drupal_get_token("vote_up_down/{$type}/{$cid}/1");
$output .= '<span id="vote_up_' . $cid . '" class="' . $class . '" title="' . url("vote_up_down/{$type}/{$cid}/1/1", array(
'query' => 'token=' . $token,
)) . '">' . l('', "vote_up_down/{$type}/{$cid}/1", array(
'class' => $class,
'title' => t('Vote up'),
), drupal_get_destination() . '&token=' . $token, NULL, FALSE, TRUE) . '</span>';
$token = drupal_get_token("vote_up_down/{$type}/{$cid}/-1");
$output .= '<span id="vote_down_' . $cid . '" class="' . $class2 . '" title="' . url("vote_up_down/{$type}/{$cid}/-1/1", array(
'query' => 'token=' . $token,
)) . '">' . l('', "vote_up_down/{$type}/{$cid}/-1", array(
'class' => $class2,
'title' => t('Vote down'),
), drupal_get_destination() . '&token=' . $token, NULL, FALSE, TRUE) . '</span>';
}
else {
$output .= '<span class="up-inact" title="' . t('You must login to vote.') . '"></span>';
$output .= '<span class="down-inact" title="' . t('You must login to vote.') . '"></span>';
}
$output .= '</div>';
return $output;
}
}