DLE Сделать рейтинг не активным после клика

Bartlby
На сайте с 30.08.2010
Offline
103
790

Всем привет, в этом ничего не смыслю. Решил сделать рейтинг из 10 звёзд на DLE 12.0 решил (хоть наверное и неправильно, главное работает) почти всё, осталось только сделать невозможным повторно голосовать, даже после обновления страницы, как это сделать?

Что я сделал:

В файле \engine\ajax\rating.php находим:

if( $go_rate > 5 or $go_rate < 1 ) $go_rate = false;

меняем цифру 5 на 10

В файле /engine/modules/functions.php находим:

function ShowRating($id, $rating, $vote_num, $allow = true) {

global $lang, $config;

if( !$config['rating_type'] ) {

if( $rating AND $vote_num ) $rating = round( ($rating / $vote_num), 0 );
else $rating = 0;

if ($rating < 0 ) $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;

} elseif ($config['rating_type'] == "1") {

if( $rating < 0 ) $rating = 0;

if( $allow ) $rated = "<span id=\"ratig-layer-{$id}\" class=\"ignore-select\"><span class=\"ratingtypeplus ignore-select\" >{$rating}</span></span>";
else $rated = "<span class=\"ratingtypeplus ignore-select\" >{$rating}</span>";

return $rated;

} elseif ($config['rating_type'] == "2") {

$extraclass = "ratingzero";

if( $rating < 0 ) {
$extraclass = "ratingminus";
}

if( $rating > 0 ) {
$extraclass = "ratingplus";
$rating = "+".$rating;
}

if( $allow ) $rated = "<span id=\"ratig-layer-{$id}\" class=\"ignore-select\"><span class=\"ratingtypeplusminus ignore-select {$extraclass}\" >{$rating}</span></span>";
else $rated = "<span class=\"ratingtypeplusminus ignore-select {$extraclass}\" >{$rating}</span>";

return $rated;

}

}

Меняем на:

function ShowRating($id, $rating, $vote_num, $allow = true) {

global $lang, $config;

if( !$config['rating_type'] ) {

if( $rating AND $vote_num ) $rating = round( ($rating / $vote_num), 1 );
else $rating = 0;
$rating1 = str_replace( ".", " , ", $rating );
$rating2 = str_replace( ",", "", $rating * 10 );

if( ! $allow ) {

$rated = <<<HTML
<ul class="unit-rating">
<li class="current-rating" style="width:{$rating2}%;">{$rating2}</li>
</ul>
HTML;

return $rated;
}

$rated .= <<<HTML
<div class="ratestats" id='ratig-layer-{$id}'>
<ul class="unit-rating">
<li class="current-rating" style="width:{$rating2}%;">{$rating2}</li>
<li><a href="#" title="1" class="r1-unit" onclick="doRate('1', '{$id}'); return false;">1</a></li>
<li><a href="#" title="2" class="r2-unit" onclick="doRate('2', '{$id}'); return false;">2</a></li>
<li><a href="#" title="3" class="r3-unit" onclick="doRate('3', '{$id}'); return false;">3</a></li>
<li><a href="#" title="4" class="r4-unit" onclick="doRate('4', '{$id}'); return false;">4</a></li>
<li><a href="#" title="5" class="r5-unit" onclick="doRate('5', '{$id}'); return false;">5</a></li>
<li><a href="#" title="6" class="r6-unit" onclick="doRate('6', '{$id}'); return false;">6</a></li>
<li><a href="#" title="7" class="r7-unit" onclick="doRate('7', '{$id}'); return false;">7</a></li>
<li><a href="#" title="8" class="r8-unit" onclick="doRate('8', '{$id}'); return false;">8</a></li>
<li><a href="#" title="9" class="r9-unit" onclick="doRate('9', '{$id}'); return false;">9</a></li>
<li><a href="#" title="10" class="r10-unit" onclick="doRate('10', '{$id}'); return false;">10</a></li>
</ul>
<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"><div class="reiting">
Рейтинг аниме: <b itemprop="ratingValue">{$rating1}</b>
<br>
<small>Голосовало {$vote_num} отаку</small>
<span itemprop="ratingCount" style="display: none;">{$vote_num}</span>
<span itemprop="bestRating" style="display: none;">10</span>
<br>
</div></div></div>
HTML;

return $rated;

} elseif ($config['rating_type'] == "1") {

if( $rating < 0 ) $rating = 0;

if( $allow ) $rated = "<span id=\"ratig-layer-{$id}\" class=\"ignore-select\"><span class=\"ratingtypeplus ignore-select\" >{$rating}</span></span>";
else $rated = "<span class=\"ratingtypeplus ignore-select\" >{$rating}</span>";

return $rated;

} elseif ($config['rating_type'] == "2") {

$extraclass = "ratingzero";

if( $rating < 0 ) {
$extraclass = "ratingminus";
}

if( $rating > 0 ) {
$extraclass = "ratingplus";
$rating = "+".$rating;
}

if( $allow ) $rated = "<span id=\"ratig-layer-{$id}\" class=\"ignore-select\"><span class=\"ratingtypeplusminus ignore-select {$extraclass}\" >{$rating}</span></span>";
else $rated = "<span class=\"ratingtypeplusminus ignore-select {$extraclass}\" >{$rating}</span>";

return $rated;

}

}

Файл engine.css:


/*--- RATING ---*/
.ratestats { color: rgb(94, 94, 94); font-size: 18px; vertical-align: top;}
.ratestats small { font-size: 10px; }
.ratebar { width: 580px; }
.reiting { float: left; margin: -32px; margin-left: 390px;}
.fullrating b { color: rgb(108, 27, 109); }
.fullrating { font-family: Verdana,Arial,Helvetica,sans-serif; margin-top: 8px; box-shadow: 3px 3px 3px 0 rgba(0,0,0,0.1); font-size: 100%; line-height: 1em; color: rgb(57, 57, 57); background: rgb(253, 253, 253) none repeat scroll 0% 0%; border-width: 1px; border-style: solid; border-color: rgb(233, 232, 232) rgb(233, 232, 232) rgb(241, 240, 240); -moz-border-top-colors: none; -moz-border-right-colors: none; -moz-border-bottom-colors: none; -moz-border-left-colors: none; border-image: none; padding: 5px; }

.rating {
color: black;
display: block;
font-size: 10px;
font-family: tahoma;
height: 36px;
margin: 0;
font-weight: bold;
}
.unit-rating { list-style: outside none none; margin: 0px; padding: 0px; width: 380px; height: 38px; position: relative; background: rgba(0, 0, 0, 0) url(../dleimages/ratingv.png) repeat-x scroll 0px -1px; }
.unit-rating li { text-indent: -90000px; padding: 0px; margin: 0px; float: left; }
.unit-rating li a { display: block; width: 38px; height: 39px; text-decoration: none; text-indent: -9000px; z-index: 39; position: absolute; padding: 0px; }
.unit-rating li a:hover { background: rgba(0, 0, 0, 0) url(../dleimages/ratingv.png) repeat scroll 0px -39px; z-index: 2; left: 0px; }
.unit-rating li.current-rating { background: rgba(0, 0, 0, 0) url(../dleimages/ratingv.png) repeat scroll 0px -78px; position: absolute; height: 39px; display: block; text-indent: -9000px; z-index: 1; }

.unit-rating a.r1-unit { left: 0px; }
.unit-rating a.r1-unit:hover { width: 38px; }
.unit-rating a.r2-unit { left: 38px; }
.unit-rating a.r2-unit:hover { width: 76px; }
.unit-rating a.r3-unit { left: 76px; }
.unit-rating a.r3-unit:hover { width: 114px; }
.unit-rating a.r4-unit { left: 114px; }
.unit-rating a.r4-unit:hover { width: 152px; }
.unit-rating a.r5-unit { left: 152px; }
.unit-rating a.r5-unit:hover { width: 190px; }
.unit-rating a.r6-unit { left: 190px; }
.unit-rating a.r6-unit:hover { width: 228px; }
.unit-rating a.r7-unit { left: 228px; }
.unit-rating a.r7-unit:hover { width: 266px; }
.unit-rating a.r8-unit { left: 266px; }
.unit-rating a.r8-unit:hover { width: 304px; }
.unit-rating a.r9-unit { left: 304px; }
.unit-rating a.r9-unit:hover { width: 342px; }
.unit-rating a.r10-unit { left: 342px; }
.unit-rating a.r10-unit:hover { width: 380px; }

В /fullstory.tpl в нужное место вставляем:

[rating-type-1]

<div class="fullrating">
<div class="ratebar">
{rating}
</div>[not-group=5]<div class="mov-compl ic-l">[complaint]<span class="fa fa-exclamation"></span>Сообщить об ошибке[/complaint]</div>[/not-group]</div>
[/rating-type-1]

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий