به کمک این ماژول امکان دادن امتیاز به مطالب به صورت منفی و مثبت فراهم می شود.
دانلود
آموزش نصب
1. فایل پیوست شده را دانلود و در داخل پوشه قالب خود از حالت زیپ خارج کنید.
2. فایل engine.css قالب خود را باز کنید و در آخرین خط کد های زیر را قرار دهید.
3. فایل 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;
4. فایل engine/modules/functions.php را باز کنید و به دنیال ک زیر بگردید.
کد زیر را جایگزین کد بالای کنید
2. فایل engine.css قالب خود را باز کنید و در آخرین خط کد های زیر را قرار دهید.
rating {
color: #555555;
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-text {float: right;}
#ratig-layer {
font-weight: bold;
float: right;
padding-right: 5px;
}
#ratig-layer a, #ratig-layer a:hover {text-decoration: none;}
.r2-unit{
cursor: pointer;
}
color: #555555;
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-text {float: right;}
#ratig-layer {
font-weight: bold;
float: right;
padding-right: 5px;
}
#ratig-layer a, #ratig-layer a:hover {text-decoration: none;}
.r2-unit{
cursor: pointer;
}
3. فایل 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;
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 * 17;
if( ! $allow ) {
$rated = <<<HTML
<div style="float:right;">
<ul>
<li style="width:{$rating}px;">{$rating}</li>
</ul>
</div>
HTML;
return $rated;
}
$rated = <<<HTML
<div id='ratig-layer'><div style="float:right;">
<ul>
<li style="width:{$rating}px;">{$rating}</li>
<li><a href="#" title="{$lang['useless']}" onclick="doRate('1', '{$id}'); return false;">1</a></li>
<li><a href="#" title="{$lang['poor']}" onclick="doRate('2', '{$id}'); return false;">2</a></li>
<li><a href="#" title="{$lang['fair']}" onclick="doRate('3', '{$id}'); return false;">3</a></li>
<li><a href="#" title="{$lang['good']}" onclick="doRate('4', '{$id}'); return false;">4</a></li>
<li><a href="#" title="{$lang['excellent']}" onclick="doRate('5', '{$id}'); return false;">5</a></li>
</ul>
</div></div>
HTML;
return $rated;
}
function ShortRating($id, $rating, $vote_num, $allow = true) {
global $lang;
if( $rating AND $vote_num ) $rating = round( ($rating / $vote_num), 0 );
else $rating = 0;
$rating = $rating * 17;
if( ! $allow ) {
$rated = <<<HTML
<div style="float:right;">
<ul>
<li style="width:{$rating}px;">{$rating}</li>
</ul>
</div>
HTML;
return $rated;
}
$rated = "<div id='ratig-layer-" . $id . "'>";
$rated .= <<<HTML
<div style="float:right;">
<ul>
<li style="width:{$rating}px;">{$rating}</li>
<li><a href="#" title="{$lang['useless']}" onclick="dleRate('1', '{$id}'); return false;">1</a></li>
<li><a href="#" title="{$lang['poor']}" onclick="dleRate('2', '{$id}'); return false;">2</a></li>
<li><a href="#" title="{$lang['fair']}" onclick="dleRate('3', '{$id}'); return false;">3</a></li>
<li><a href="#" title="{$lang['good']}" onclick="dleRate('4', '{$id}'); return false;">4</a></li>
<li><a href="#" title="{$lang['excellent']}" onclick="dleRate('5', '{$id}'); return false;">5</a></li>
</ul>
</div>
HTML;
$rated .= "</div>";
return $rated;
}
function userrating($name) {
global $db;
$row = $db->super_query( "SELECT SUM(rating) as rating, SUM(vote_num) as num FROM " . PREFIX . "_post where autor ='$name'" );
if( $row['num'] ) $rating = round( ($row['rating'] / $row['num']), 0 );
else $rating = 0;
$rating = $rating * 17;
$rated = <<<HTML
<div style="display:inline;">
<ul>
<li style="width:{$rating}px;">{$rating}</li>
</ul>
</div>
HTML;
return $rated;
}
global $lang;
if( $rating AND $vote_num ) $rating = round( ($rating / $vote_num), 0 );
else $rating = 0;
$rating = $rating * 17;
if( ! $allow ) {
$rated = <<<HTML
<div style="float:right;">
<ul>
<li style="width:{$rating}px;">{$rating}</li>
</ul>
</div>
HTML;
return $rated;
}
$rated = <<<HTML
<div id='ratig-layer'><div style="float:right;">
<ul>
<li style="width:{$rating}px;">{$rating}</li>
<li><a href="#" title="{$lang['useless']}" onclick="doRate('1', '{$id}'); return false;">1</a></li>
<li><a href="#" title="{$lang['poor']}" onclick="doRate('2', '{$id}'); return false;">2</a></li>
<li><a href="#" title="{$lang['fair']}" onclick="doRate('3', '{$id}'); return false;">3</a></li>
<li><a href="#" title="{$lang['good']}" onclick="doRate('4', '{$id}'); return false;">4</a></li>
<li><a href="#" title="{$lang['excellent']}" onclick="doRate('5', '{$id}'); return false;">5</a></li>
</ul>
</div></div>
HTML;
return $rated;
}
function ShortRating($id, $rating, $vote_num, $allow = true) {
global $lang;
if( $rating AND $vote_num ) $rating = round( ($rating / $vote_num), 0 );
else $rating = 0;
$rating = $rating * 17;
if( ! $allow ) {
$rated = <<<HTML
<div style="float:right;">
<ul>
<li style="width:{$rating}px;">{$rating}</li>
</ul>
</div>
HTML;
return $rated;
}
$rated = "<div id='ratig-layer-" . $id . "'>";
$rated .= <<<HTML
<div style="float:right;">
<ul>
<li style="width:{$rating}px;">{$rating}</li>
<li><a href="#" title="{$lang['useless']}" onclick="dleRate('1', '{$id}'); return false;">1</a></li>
<li><a href="#" title="{$lang['poor']}" onclick="dleRate('2', '{$id}'); return false;">2</a></li>
<li><a href="#" title="{$lang['fair']}" onclick="dleRate('3', '{$id}'); return false;">3</a></li>
<li><a href="#" title="{$lang['good']}" onclick="dleRate('4', '{$id}'); return false;">4</a></li>
<li><a href="#" title="{$lang['excellent']}" onclick="dleRate('5', '{$id}'); return false;">5</a></li>
</ul>
</div>
HTML;
$rated .= "</div>";
return $rated;
}
function userrating($name) {
global $db;
$row = $db->super_query( "SELECT SUM(rating) as rating, SUM(vote_num) as num FROM " . PREFIX . "_post where autor ='$name'" );
if( $row['num'] ) $rating = round( ($row['rating'] / $row['num']), 0 );
else $rating = 0;
$rating = $rating * 17;
$rated = <<<HTML
<div style="display:inline;">
<ul>
<li style="width:{$rating}px;">{$rating}</li>
</ul>
</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;
switch($rating) {
case ($rating >= 0):
$rating = '<span style="color: #009900;">+'.$rating.'</span>';
break;
case ($rating <= 0):
$rating = '<span style="color: #FF0000;">'.$rating.'</span>';
break;
case($rating == 0):
$rating = '<span style="color: #000000;">'.$rating.'</span>';
break;
}
if (!$allow) {
$rated = <<<HTML
<div id="ratig-layer">
<a href="#" title="پسندیدم (+)" alt="پسندیدم (+)" onclick="doRate('1', '{$id}'); return false;">
<img src="/templates/Default/dleimages/up.png" title="پسندیدم (+)" alt="پسندیدم (+)" width="11" height="11" align="middle" />
</a>
{$rating}
<a href="#" title="نپسنیدم (-)" alt="نپسنیدم (-)" onclick="doRate('-1', '{$id}'); return false;">
<img src="/templates/Default/dleimages/down.png" title="نپسنیدم (-)" alt="نپسنیدم (-)" width="11" height="11" align="middle" />
</a>
</div>
HTML;
return $rated;
}
$rated .= <<<HTML
<span id="ratig-layer-{$id}">
<div id="ratig-layer">
<a href="#" title="پسندیدم (+)" alt="پسندیدم (+)" onclick="doRate('1', '{$id}'); return false;">
<img src="{THEME}/dleimages/up.png" title="پسندیدم (+)" alt="پسندیدم (+)" width="11" height="11" align="middle" />
</a>
{$rating}
<a href="#" title="نپسنیدم (-)" alt="نپسنیدم (-)" onclick="doRate('-1', '{$id}'); return false;">
<img src="{THEME}/dleimages/down.png" title="نپسنیدم (-)" alt="نپسنیدم (-)" width="11" height="11" align="middle" />
</a>
</div>
</span>
HTML;
return $rated;
}
function ShortRating($id, $rating, $vote_num, $allow = true) {
global $config, $lang;
if ($rating) $rating = round($rating, 0); else $rating = 0;
switch($rating) {
case ($rating >= 0):
$rating = '<span style=\"color: #009900;\">+'.$rating.'</span>';
break;
case ($rating <= 0):
$rating = '<span style="color: #FF0000;">'.$rating.'</span>';
break;
case($rating == 0):
$rating = '<span style="color: #000000;">'.$rating.'</span>';
break;
}
if (!$allow) {
$rated = <<<HTML
<div id="ratig-layer">
<a href="#" title=" پسندیدم (+) " alt=" پسندیدم (+) " onclick="doRate('1', '{$id}'); return false;">
<img src="/templates/Default/dleimages/up.png" title="پسندیدم (+)" alt=" پسندیدم (+) " width="11" height="11" align="middle" />
</a>
{$rating}
<a href="#" title=" نپسنیدم (-) " alt=" نپسنیدم (-) " onclick="doRate('-1', '{$id}'); return false;">
<img src="/templates/Default/dleimages/down.png" title="نپسنیدم (-)" alt=" نپسنیدم (-) " width="11" height="11" align="middle" />
</a>
</div>
HTML;
return $rated;
}
$rated = "<span id=\"ratig-layer-" . $id . "\">";
$rated .= <<<HTML
<div id="ratig-layer">
<a href="#" title="پسندیدم (+)" alt="پسندیدم (+)" onclick="dleRate('1', '{$id}'); return false;">
<img src="{THEME}/dleimages/up.png" title="پسندیدم (+)" alt="پسندیدم (+)" width="11" height="11" align="middle" />
</a>
{$rating}
<a href="#" title="نپسنیدم (-)" alt="نپسنیدم (-)" onclick="dleRate('-1', '{$id}'); return false;">
<img src="{THEME}/dleimages/down.png" title="نپسنیدم (-)" alt="نپسنیدم (-)" width="11" height="11" align="middle" />
</a>
</div>
HTML;
$rated .= "</span>";
return $rated;
}
function userrating($name) {
global $db;
$row = $db->super_query("SELECT SUM(rating) as rating, SUM(vote_num) as num FROM " . PREFIX . "_post where autor ='$name'");
if ($row['num']) $rating = round(($row['rating'] / $row['num']), 0); else $rating = 0;
$rating = $rating;
$rated = <<<HTML
{$rating}
HTML;
return $rated;
}
global $is_logged, $member_id, $config, $lang, $db;
if ($rating) $rating = round($rating, 0); else $rating = 0;
switch($rating) {
case ($rating >= 0):
$rating = '<span style="color: #009900;">+'.$rating.'</span>';
break;
case ($rating <= 0):
$rating = '<span style="color: #FF0000;">'.$rating.'</span>';
break;
case($rating == 0):
$rating = '<span style="color: #000000;">'.$rating.'</span>';
break;
}
if (!$allow) {
$rated = <<<HTML
<div id="ratig-layer">
<a href="#" title="پسندیدم (+)" alt="پسندیدم (+)" onclick="doRate('1', '{$id}'); return false;">
<img src="/templates/Default/dleimages/up.png" title="پسندیدم (+)" alt="پسندیدم (+)" width="11" height="11" align="middle" />
</a>
{$rating}
<a href="#" title="نپسنیدم (-)" alt="نپسنیدم (-)" onclick="doRate('-1', '{$id}'); return false;">
<img src="/templates/Default/dleimages/down.png" title="نپسنیدم (-)" alt="نپسنیدم (-)" width="11" height="11" align="middle" />
</a>
</div>
HTML;
return $rated;
}
$rated .= <<<HTML
<span id="ratig-layer-{$id}">
<div id="ratig-layer">
<a href="#" title="پسندیدم (+)" alt="پسندیدم (+)" onclick="doRate('1', '{$id}'); return false;">
<img src="{THEME}/dleimages/up.png" title="پسندیدم (+)" alt="پسندیدم (+)" width="11" height="11" align="middle" />
</a>
{$rating}
<a href="#" title="نپسنیدم (-)" alt="نپسنیدم (-)" onclick="doRate('-1', '{$id}'); return false;">
<img src="{THEME}/dleimages/down.png" title="نپسنیدم (-)" alt="نپسنیدم (-)" width="11" height="11" align="middle" />
</a>
</div>
</span>
HTML;
return $rated;
}
function ShortRating($id, $rating, $vote_num, $allow = true) {
global $config, $lang;
if ($rating) $rating = round($rating, 0); else $rating = 0;
switch($rating) {
case ($rating >= 0):
$rating = '<span style=\"color: #009900;\">+'.$rating.'</span>';
break;
case ($rating <= 0):
$rating = '<span style="color: #FF0000;">'.$rating.'</span>';
break;
case($rating == 0):
$rating = '<span style="color: #000000;">'.$rating.'</span>';
break;
}
if (!$allow) {
$rated = <<<HTML
<div id="ratig-layer">
<a href="#" title=" پسندیدم (+) " alt=" پسندیدم (+) " onclick="doRate('1', '{$id}'); return false;">
<img src="/templates/Default/dleimages/up.png" title="پسندیدم (+)" alt=" پسندیدم (+) " width="11" height="11" align="middle" />
</a>
{$rating}
<a href="#" title=" نپسنیدم (-) " alt=" نپسنیدم (-) " onclick="doRate('-1', '{$id}'); return false;">
<img src="/templates/Default/dleimages/down.png" title="نپسنیدم (-)" alt=" نپسنیدم (-) " width="11" height="11" align="middle" />
</a>
</div>
HTML;
return $rated;
}
$rated = "<span id=\"ratig-layer-" . $id . "\">";
$rated .= <<<HTML
<div id="ratig-layer">
<a href="#" title="پسندیدم (+)" alt="پسندیدم (+)" onclick="dleRate('1', '{$id}'); return false;">
<img src="{THEME}/dleimages/up.png" title="پسندیدم (+)" alt="پسندیدم (+)" width="11" height="11" align="middle" />
</a>
{$rating}
<a href="#" title="نپسنیدم (-)" alt="نپسنیدم (-)" onclick="dleRate('-1', '{$id}'); return false;">
<img src="{THEME}/dleimages/down.png" title="نپسنیدم (-)" alt="نپسنیدم (-)" width="11" height="11" align="middle" />
</a>
</div>
HTML;
$rated .= "</span>";
return $rated;
}
function userrating($name) {
global $db;
$row = $db->super_query("SELECT SUM(rating) as rating, SUM(vote_num) as num FROM " . PREFIX . "_post where autor ='$name'");
if ($row['num']) $rating = round(($row['rating'] / $row['num']), 0); else $rating = 0;
$rating = $rating;
$rated = <<<HTML
{$rating}
HTML;
return $rated;
}
تصاویر