stars
[ class tree: stars ] [ index: stars ] [ all elements ]

Source for file details.php

Documentation is available at details.php

  1. <?php
  2. /**
  3. * $Header$
  4. * date created 2006/02/10
  5. * @author xing <xing@synapse.plus.com>
  6. * @version $Revision$
  7. * @package stars
  8. */
  9.  
  10. /**
  11.  * Setup
  12.  */
  13. require_once( "../kernel/setup_inc.php" );
  14. require_once( STARS_PKG_PATH."LibertyStars.php" );
  15.  
  16. $gBitSystem->verifyPackage( 'stars' );
  17.  
  18. if( !@BitBase::verifyId( $_REQUEST['content_id'] ) && !@BitBase::verifyId( $_REQUEST['user_id'] )) {
  19.     header( "Location: ".BIT_ROOT_URL );
  20. }
  21.  
  22. if( @BitBase::verifyId( $_REQUEST['content_id'] )) {
  23.     // content details
  24.     $stars = new LibertyStars( $_REQUEST['content_id'] );
  25.     $stars->loadRatingDetails();
  26.     $gBitSmarty->assign( 'starsDetails', $stars->mInfo );
  27. } elseif( @BitBase::verifyId( $_REQUEST['user_id'] )) {
  28.     // user details
  29.     $stars = new LibertyStars();
  30.     $listHash = array(
  31.         'user_id' => $_REQUEST['user_id'],
  32.     );
  33.     $userRatings = $stars->getList( $listHash );
  34.  
  35.     // calculate this users average ratings
  36.     $sum = 0;
  37.     foreach( $userRatings as $rating ) {
  38.         $sum += $rating['user_rating'];
  39.     }
  40.     $average = round( $sum / count( $userRatings ));
  41.     $stars = $gBitSystem->getConfig( 'stars_used_in_display', 5 );
  42.     $pixels = $stars *  $gBitSystem->getConfig( 'stars_icon_width', 22 );
  43.     $average_pixels = $average * $pixels / 100;
  44.  
  45.     $gBitSmarty->assign( 'average_pixels', $average_pixels );
  46.     $gBitSmarty->assign( 'userRatings', $userRatings );
  47. }
  48.  
  49. $gBitSystem->display( 'bitpackage:stars/details.tpl', tra( 'Details of Rated Content' ) , array( 'display_mode' => 'display' ));
  50. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:22 +0000 by phpDocumentor 1.5.0-lsces