コード例 #1
0
ファイル: class-element.php プロジェクト: seanfbrown/jinzora
 /**
  * Gets the overall rating for the node.
  * 
  * @author Ben Dodson
  * @version 6/5/04
  * @since 6/5/04
  */
 function getRating()
 {
     $cache = $this->readCache();
     return $cache[5] == 0 ? 0 : estimateRating($cache[4] / $cache[5]);
 }
コード例 #2
0
ファイル: media.php プロジェクト: seanfbrown/jinzora
 /**
  * Add a rating for the node.
  * 
  * @author Ben Dodson
  * @version 6/7/04
  * @since 6/7/04
  */
 function addRating($rating, $weight = false)
 {
     global $sql_type, $sql_pw, $sql_usr, $sql_socket, $sql_db, $rating_weight, $jzUSER;
     if ($weight === false) {
         $weight = $jzUSER->getSetting('ratingweight');
     }
     if (!($link = jz_db_connect())) {
         die("could not connect to database.");
     }
     $addRating = $rating * $weight;
     $addWeight = $weight;
     $path = jz_db_escape($this->getPath("String"));
     $results = jz_db_query($link, "SELECT rating,rating_count FROM jz_nodes WHERE path = '{$path}'");
     if ($results->data[0]['rating_count'] == 0) {
         $rval = $rating;
     } else {
         $rval = estimateRating(($results->data[0]['rating'] + $addRating) / ($results->data[0]['rating_count'] + $addWeight));
     }
     $results = jz_db_query($link, "UPDATE jz_nodes SET rating=rating+{$addRating},\n                                                     rating_count=rating_count+{$addWeight}, rating_val={$rval} WHERE path = '{$path}'");
     if ($rating_weight > 0 && $this->getLevel() > 0) {
         $path = $this->getPath();
         array_pop($path);
         $next =& new jzMediaNode($path);
         $next->addRating($rating, $weight * $rating_weight);
     }
     jz_db_close($link);
 }
コード例 #3
0
ファイル: display.php プロジェクト: seanfbrown/jinzora
 /**
  * Displays or returns the rating for an object
  * 
  * 
  * @author Ross Carlson
  * @version 11/20/04
  * @since 11/20/04
  * @param $node The node that we are getting the rating for
  * @param $return Return the data or display (true = return)
  */
 function rating($node, $return = false)
 {
     global $img_star_full, $img_star_half_empty, $img_star_left, $img_star_right, $img_star_full_empty, $include_path, $img_star_full_raw, $img_star_empty_raw;
     // Let's increment the counter
     $_SESSION['jz_stars_group']++;
     // Let's grab the rating from the node
     $rating = estimateRating($node->getRating());
     // First lets see if we should just return if this is nothing
     if (!$rating) {
         return;
     }
     // Now let's start the rating icon
     $retVal .= $img_star_left;
     $total_rating = $rating;
     for ($i = floor($rating); $i > 0; $i--) {
         $retVal .= $img_star_full;
     }
     if ($rating - floor($rating) > 0.25) {
         $retVal .= $img_star_half_empty;
     }
     // Now we need to finish this off to make 5
     for ($i = ceil($rating); $i < 5; $i++) {
         $retVal .= $img_star_full_empty;
     }
     // Now let's finish it off
     $retVal .= $img_star_right;
     if ($return) {
         return $retVal;
     } else {
         echo $retVal;
     }
 }