Добрый вечер.
function ShowRating($id, $rating, $vote_num, $allow = true) {
global $lang;
if( $rating AND $vote_num ) $rating = round( ($rating / $vote_num), 0 );
else $rating = 4;
$AVERrating = $rating;
$rating = $rating * 17;
if( !$allow ) {
$rated = <<<HTML
<div class="rating">
<ul class="unit-rating">
<li class="current-rating" style="width:{$rating}px;">{$rating}</li>
</ul>
</div>
HTML;
return $rated;
}
$rated = <<<HTML
<div id='ratig-layer-{$id}'><div class="rating">
<ul itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating" class="unit-rating">
<li itemprop="average" class="current-rating" style="width:{$rating}px;">{$AVERrating}</li>
<li><a href="#" title="{$lang['useless']}" class="r1-unit" onclick="doRate('1', '{$id}'); return false;">1</a></li>
<li><a href="#" title="{$lang['poor']}" class="r2-unit" onclick="doRate('2', '{$id}'); return false;">2</a></li>
<li><a href="#" title="{$lang['fair']}" class="r3-unit" onclick="doRate('3', '{$id}'); return false;">3</a></li>
<li><a href="#" title="{$lang['good']}" class="r4-unit" onclick="doRate('4', '{$id}'); return false;">4</a></li>
<li itemprop="best"><a href="#" title="{$lang['excellent']}" class="r5-unit" onclick="doRate('5', '{$id}'); return false;">5</a></li>
</ul>
</div></div>
HTML;
return $rated;
}
function userrating($id) {
if ( $row['vote_num'] == 0 ) $row['vote_num'] = 1;
if( $row['allow_rate'] ) {
$tpl->set( '{rating}', ShowRating( $row['id'], $row['rating'], $row['vote_num'], $user_group[$member_id['user_group']]['allow_rating'] ) );
$tpl->set( '{vote-num}', "<span itemprop=\"votes\" id=\"vote-num-id-".$row['id']."\">".$row['vote_num']."</span>" );
$tpl->set( '[rating]', "" );
$tpl->set( '[/rating]', "" );
} else {
/*---Рейтинг---*/
.rating {
margin: 0 0 10px 105px;
position: relative;
}
.view-info-tit {
font-weight: bold;
font-size: 14px;
float: left;
line-height: 27px;
}
.votes {
text-align: right;
position: relative;
font-size: 10px;
}
.unit-rating {
list-style: none;
margin: 0;
padding: 0;
width: 169px;
height: 27px;
position: relative;
background: url("../img/rating.png") repeat-x;
}
.unit-rating li {
text-indent: -90000px;
padding: 0;
margin: 0;
float: left;
}
.unit-rating li a {
display: block;
width: 30px;
height: 27px;
text-decoration: none;
text-indent: -9000px;
z-index: 27;
position: absolute;
padding: 0;
}
.unit-rating li a:hover {
background: url("../img/rating.png") 0 -27px;
z-index: 2;
left: 0;
}
.unit-rating a.r1-unit {
left: 0;
}
.unit-rating a.r1-unit:hover {
width:30px;
}
.unit-rating a.r2-unit {
left: 30px;
}
.unit-rating a.r2-unit:hover {
width: 65px;
}
.unit-rating a.r3-unit {
left: 65px;
}
.unit-rating a.r3-unit:hover {
width: 100px;
}
.unit-rating a.r4-unit {
left: 100px;
}
.unit-rating a.r4-unit:hover {
width: 135px;
}
.unit-rating a.r5-unit {
left: 135px;
}
.unit-rating a.r5-unit:hover {
width: 169px;
}
.unit-rating li.current-rating {
background: url("../img/rating.png") 0 -27px;
position: absolute;
height: 27px;
display: block;
text-indent: -9000px;
z-index: 1;
}
тут 12 голосов и все по 5 баллов, но почему рейтинг стоит на 2,5? Так на всех страницах.