Created
November 10, 2013 01:17
-
-
Save pratik60/7392358 to your computer and use it in GitHub Desktop.
Fivestar summary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function insight_client_fivestar_summary($variables) { | |
| $microdata = $variables['microdata']; | |
| extract($variables, EXTR_SKIP); | |
| $output = ''; | |
| $div_class = ''; | |
| $average_rating_microdata = ''; | |
| if (isset($user_rating)) { | |
| $div_class = isset($votes) ? 'user-count' : 'user'; | |
| $user_stars = round(($user_rating * $stars) / 100, 1); | |
| $output .= $user_rating ? '<span class="user-rating">' . t('You voted: <span>!stars</span>', array('!stars' => $user_stars)) .'</span>' : ""; | |
| } | |
| if (isset($user_rating) && isset($average_rating) && $output!="") { | |
| $output .= ' , '; | |
| } | |
| if (isset($average_rating)) { | |
| $div_class = isset($votes) ? 'average-count' : 'average'; | |
| $average_stars = round(($average_rating * $stars) / 100, 1); | |
| if (!empty($microdata['average_rating']['#attributes'])) { | |
| $average_rating_microdata = drupal_attributes($microdata['average_rating']['#attributes']); | |
| } | |
| $output .= '<span class="average-rating">'. t('Average: <span !microdata>!stars</span>', array('!stars' => $average_stars, '!microdata' => $average_rating_microdata)) .'</span>'; | |
| } | |
| if (isset($user_rating) && isset($average_rating)) { | |
| $div_class = 'combo'; | |
| } | |
| if (isset($votes) && !(isset($user_rating) || isset($average_rating))) { | |
| $output .= ' <span class="total-votes">'. format_plural($votes, '<span>@count</span> vote', '<span>@count</span> votes') .'</span>'; | |
| $div_class = 'count'; | |
| } | |
| elseif (isset($votes)) { | |
| $output .= ' <span class="total-votes">, '. format_plural($votes, 'Total Vote: <span>@count</span> vote', 'Total Votes: <span>@count</span>') .'</span>'; | |
| } | |
| if ($votes === 0) { | |
| $output = '<span class="empty"></span>'; | |
| } | |
| $output = '<div class="fivestar-summary fivestar-summary-'. $div_class . '">'. $output .'</div>'; | |
| return $output; | |
| } | |
| function insight_client_links__locale_block($variables) { | |
| foreach($variables['links'] as $key => $value) { | |
| if ($value['attributes']['class']=='locale-untranslated') { | |
| unset($variables['links'][$key]); | |
| } | |
| } | |
| return theme('links', $variables); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment