Описание:
Надоел стандартный рейтинг новостей в DLE? Тогда ставим новый цветной цифровой рейтинг на DLE 10.0!
Установка:
1. Открыть файл engine/ajax/rating.php и найти:
if ($go_rate > 5 OR $go_rate < 1) $go_rate = 0;
Заменить на:
if ($go_rate > 1 OR $go_rate < -1) $go_rate = 0;
2. Открыть файл engine/modules/functions.php и найти:
function ShowRating($id, $rating, $vote_num, $allow = true) {
global $lang;
if( $rating AND $vote_num ) $rating = round( ($rating / $vote_num), 0 );
else $rating = 0;
$rating = $rating * 20;
if( !$allow ) {
$rated = <<<HTML
<div class="rating">
<ul class="unit-rating">
<li class="current-rating" style="width:{$rating}%;">{$rating}</li>
</ul>
</div>
HTML;
return $rated;
}
$rated = <<<HTML
<div id='ratig-layer-{$id}'><div class="rating">
<ul class="unit-rating">
<li class="current-rating" style="width:{$rating}%;">{$rating}</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><a href="#" title="{$lang['excellent']}" class="r5-unit" onclick="doRate('5', '{$id}'); return false;">5</a></li>
</ul>
</div></div>
HTML;
return $rated;
}
Заменить на:
function ShowRating($id, $rating, $vote_num, $allow = true) {
global $is_logged, $member_id, $config, $lang, $db;
if ($rating) $rating = round($rating, 0); else $rating = 0;
if ($rating > 0) $rating="<font color=green>+".$rating."</font>"; elseif ($rating == 0) $rating=$rating; else $rating="<font color=red>".$rating."</font>";
if (!$allow) {
$rated = <<<HTML
<span class="rateinf">{$rating}</span>
HTML;
return $rated;
}
$rated .= <<<HTML
<span id="ratig-layer-{$id}">
<img src="/templates/Light/dleimages/up.gif" title="Отлично" class="ratebut" onclick="doRate('1', '{$id}'); return false;" />
<span class="rateinf">{$rating}</span>
<img src="/templates/Light/dleimages/down.gif" title="Плохо" class="ratebut" onclick="doRate('-1', '{$id}'); return false;" />
</span>
HTML;
return $rated;
}
3. В файл shortstory.tpl и fullstory.tpl вставить:
<div class="rating">{rating}</div>
4. Открыть файл engine.css и найти:
.rating {
color: #757575;
font-size: 11px; /* ! */
font-family: tahoma; /* ! */
width: 85px;
height: 16px;
}
.unit-rating {
list-style: none;
margin: 0px;
padding: 0px;
width: 85px;
height: 16px;
position: relative;
background-image: url(../dleimages/rating.gif);
background-position: top left;
background-repeat: repeat-x;
}
.unit-rating li {
text-indent: -90000px;
padding: 0px;
margin: 0px;
float: left;
}
.unit-rating li a {
display: block;
width: 17px;
height: 16px;
text-decoration: none;
text-indent: -9000px;
z-index: 17;
position: absolute;
padding: 0px;
}
.unit-rating li a:hover {
background-image: url(../dleimages/rating.gif);
background-position: left center;
z-index: 2;
left: 0px;
}
.unit-rating a.r1-unit { left: 0px; }
.unit-rating a.r1-unit:hover { width: 17px; }
.unit-rating a.r2-unit { left: 17px; }
.unit-rating a.r2-unit:hover { width: 34px; }
.unit-rating a.r3-unit { left: 34px; }
.unit-rating a.r3-unit:hover { width: 51px; }
.unit-rating a.r4-unit { left: 51px; }
.unit-rating a.r4-unit:hover { width: 68px; }
.unit-rating a.r5-unit { left: 68px; }
.unit-rating a.r5-unit:hover { width: 85px; }
.unit-rating li.current-rating {
background-image: url(../dleimages/rating.gif);
background-position: left bottom;
position: absolute;
height: 16px;
display: block;
text-indent: -9000px;
z-index: 1;
}
Заменить на:
.rating img {border:0px none; margin:0px 8px -1px 7px; }
.ratebut { cursor:pointer; }
.rateinf { font-weight:bold; }
P.S. Если необходимо чтобы после голосования стрелочки не исчезали, найдите в файле engine/ajax/rating.php строку:
$buffer = ShowRating( $row['news_id'], $row['rating'], $row['vote_num'], false );
И удалите:
, false