Changeset 2793

Show
Ignore:
Timestamp:
07/16/08 07:41:46 (3 months ago)
Author:
fumiakiy
Message:

Return 0 when no vote has been made to the object from the dynamic template tag. BugId:80592

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-41/php/lib/rating_lib.php

    r2786 r2793  
    8686    } 
    8787    $sum = score_for($ctx, $obj_id, $datasource, $namespace); 
     88    if ( isset($sum) && ( $sum == '' ) ) 
     89        return 0; 
    8890    return sprintf("%.2f", ($sum / $count)); 
    8991} 
     
    149151    } 
    150152    $score = score_for($ctx, $object[$datasource . '_id'], $datasource, $namespace); 
    151     if ( !$score && isset($default) ) 
    152         return $default; 
    153     if ( $score )  
    154         return $ctx->count_format($score, $args); 
    155     return $score; 
     153    if ( !isset($score) || ( $score == '' ) ) { 
     154        if ( isset($default) ) 
     155            return $default; 
     156        else 
     157            $score = 0; 
     158    } 
     159    return $ctx->count_format($score, $args); 
    156160} 
    157161 
     
    202206    } 
    203207    $avg = score_avg($ctx, $object[$datasource . '_id'], $datasource, $namespace); 
    204     if ( $avg )  
     208    if ( isset($avg) && ( $avg != '') )  
    205209        return $ctx->count_format($avg, $args); 
    206210    return $avg; 
     
    221225    } 
    222226    $count = score_count($ctx, $object[$datasource . '_id'], $datasource, $namespace); 
    223     if ( $count )  
     227    if ( isset($count) && ( $count != '') )  
    224228        return $ctx->count_format($count, $args); 
    225229    return $count;