You are here

function theme_plus1_widget in Plus 1 6

Same name and namespace in other branches
  1. 6.2 plus1.module \theme_plus1_widget()

Theme for the voting widget.

1 theme call to theme_plus1_widget()
plus1_jquery_widget in ./plus1.module
Create voting widget to display on the webpage.

File

./plus1.module, line 162
A simple +1 voting widget module.

Code

function theme_plus1_widget($nid, $score, $logged_in, $is_author, $voted, $teaser) {
  $output = '<div class="plus1-widget">';
  if (!$logged_in || user_access('rate content')) {
    $output .= '<div class="plus1-msg">';
    if (!$logged_in) {
      $output .= '<small>' . l(t('Log in<br />to vote'), 'user', array(
        'html' => TRUE,
      )) . '</small>';
    }
    else {
      if ($is_author) {

        // User is author so he's not allowed to vote.
        $output .= '<small>' . t('Your<br />content') . '</small>';
      }
      else {
        if ($voted) {

          // User already voted.
          $output .= '<small>' . t('You voted') . '</small>';
        }
        else {

          // User is eligible to vote.
          // The class plus1-link is what we will search for in our jQuery later.
          // But we could have used the selector ".plus1-vote a".
          // Beware : l() and url() have different signatures in Drupal 6.
          $output .= '<div class="plus1-vote"' . l(t('Vote'), "plus1/vote/{$nid}", array(
            'attributes' => array(
              'class' => 'plus1-link',
            ),
          )) . '</div>';
        }
      }
    }
    $output .= '</div>';
  }
  $output .= '<div class="plus1-score">';
  $output .= $score;
  $output .= '</div>';
  $output .= '</div>';
  return $output;
}