<?php
/**
 * Rating Helper
 *
 * @author        Matt Smith
 * @copyright    Copyright (c) 2008
 * @link        http://dml.cs.byu.edu/matthewsmith
 * @since        Version 1.0
 */
// ------------------------------------------------------------------------
// rater : depends on CSS classes img.off and img.on (in rating.css)
// rater : depends on JS helper functions (in rating.js)
function rater($numStars=5,$groupID=NULL){
    
//GroupID should be unique among all raters created on a given page
    
if($groupID==NULL$groupID=substr(md5(rand()),5);
    
$str '<span>';
    for(
$i=1$i<=$numStars$i++){
        
$title 'Rate '.$i.' of '.$numStars.' stars';
        
$str .= '<img id="'.$groupID.'_'.$i.'" src="star.png" title="'.$title.'" class="off" 
        onmouseover="toggleRatings(\''
.$groupID.'\','.$i.','.$numStars.');" 
        onclick="saveRatings(\''
.$groupID.'\','.$i.');" 
        onmouseout="revertRatings(\''
.$groupID.'\',\''.$numStars.'\');"
        >'
;        
    }
    
$str .= '</span>';
    return 
$str;
}
function 
fixed_rater($numStars=5,$maxStars=5){
    if(
$numStars>$maxStars)$numStars=$maxStars;
    
$str '<span title="Rated '.$numStars.' of '.$maxStars.' stars">';
    
$str .= str_repeat('<img src="smallstar.png" class="on">',$numStars);
    
$str .= str_repeat('<img src="smallstar.png" class="off">',$maxStars-$numStars);
    
$str .= '</span>';
    return 
$str;
}
?>