mercredi 5 mars 2014

BARS-RATING BY SANDER - Eng

In Bars-Rating Rating saved standard values ​​and using "smart" algorithm automatically calculates the number of ratings from 1 to 5 points on the basis of the original data. Author: Sander Version DLE: 9.7 - 10.1

Installation.
Connected to the template file styles prescribe such styles:
.b-rating-area{height:120px;width:270px;margin:10px 0;text-align:left;}
.b-rating-lines{list-style:none;margin:0;padding:0;}
.b-rating-lines li{height:18px;display:block;font:normal 12px/17px Arial;color:#333;width:200px;padding:0 50px 0 20px;}
.b-rating-lines li:hover{background:#fafafa;}
.b-rating-lines-bar{float:left;height:16px;}
.b-color-5{background:#7cac16;border-bottom:1px solid #699212;}
.b-color-4{background:#a8d12e;border-bottom:1px solid #8fb127;}
.b-color-3{background:#ffcf00;border-bottom:1px solid #d9b000;}
.b-color-2{background:#faa732;border-bottom:1px solid #d48e2a;}
.b-color-1{background:#d9534f;border-bottom:1px solid #b84643;}

.b-rating-lines-rate{float:left;width:14px;height:100%;border-right:1px solid #444;margin-left:-15px;}
.b-rating-lines-votes{float:right;width:40px;height:100%;margin-right:-50px;color:#666;}

.b-rating-vote-area{height:25px;padding-top:5px;font:normal 16px/25px Arial;color:#444;}
.b-rating-stars{float:right;margin:0;padding:0;list-style:none;}
.b-rating-stars li{float:left;width:25px;height:25px;background:url('../images/b_rating.png') no-repeat 0 0;cursor:pointer;}
.b-rating-stars li.b-current{background-position:0 -25px;}
.b-rating-stars li.b-hover{background-position:0 -50px;}

And as in any connected to the template file to insert JS code:
$(document).on("mouseenter",".b-rating-stars li",function(){
var b_index = $(this).index()+1;
$(this).parent().find('li').each(function(i){
if(b_index>i) $(this).addClass('b-hover');
});
}).on("mouseleave",".b-rating-stars li",function(){
$(this).parent().find('li').removeClass('b-hover');
});


Now the fun part. Run the query to the database:
ALTER TABLE `dle_post` ADD `b_rating` VARCHAR( 20 ) NOT NULL;


Open File engine/modules/functions.php Find the line:
function ShowRating(

It should be renamed the function like this
function ShowRating2(


Before and paste it:
function b_sander_rating($id,$rate,$vote){
global $db;
if(!$vote) return "0|0|0|0|0";
$vt = array_fill(0,$vote,1);
if(($rate-$vote)>=5) $vt[0] = 5;
$vt[$vote-1] = 1;
$i = 0;
$r = 0;
while($r<$rate){
$i++;
if($i>10000) return "0|0|0|0|0";
if($r<$rate){
shuffle($vt);
foreach($vt as $k=>$v){
if($v<5 data-blogger-escaped-as="" data-blogger-escaped-break="" data-blogger-escaped-db-="" data-blogger-escaped-foreach="" data-blogger-escaped-k="" data-blogger-escaped-r="" data-blogger-escaped-v="" data-blogger-escaped-votes="" data-blogger-escaped-vt="">query("UPDATE ".PREFIX."_post SET b_rating='{$votes}' WHERE id={$id}");
return $votes;
}

function ShowRating($id, $rating, $vote_num, $allow = true){
global $row;
if(!$row['b_rating']) $row['b_rating'] = b_sander_rating($id,$rating,$vote_num);
$b_rating = explode("|",$row['b_rating']);
$max = max($b_rating);
if($vote_num) $rateval = round($rating/$vote_num);
else $rateval = 0;
$list = '';
$pc = array();
for($i=4;$i>=0;$i--){
$k = $i+1;
$w = ceil(100*$b_rating[$i]/$max);
if($rateval>=$k) $pc[$k] = "class='b-current'";
$list .= "\t

  • {$k}




    {$b_rating[$i]}


  • \n";
    }

    return <<


      {$list}









    Vote


    HTML;
    }


    Open File engine/ajax/rating.php Find the line:
        $db->query( "UPDATE " . PREFIX . "_post_extras SET rating=rating+'$go_rate', vote_num=vote_num+1 WHERE news_id ='$news_id'" );


    After it insert:
        $r = $db->super_query("SELECT b_rating FROM ".PREFIX."_post WHERE id={$news_id}");
    if($r['b_rating']) $b_rating = explode("|",$r['b_rating']);
    else $b_rating = array_fill(0,5,0);
    $b_rating[$go_rate-1]++;
    $b_rating = implode("|",$b_rating);
    $db->query( "UPDATE " . PREFIX . "_post SET b_rating='$b_rating' WHERE id ='$news_id'" );


    Find the line:
    $row = $db->super_query( "SELECT news_id, rating, vote_num FROM " . PREFIX . "_post_extras WHERE news_id ='$news_id'" );


    Replace with:
    $row = $db->super_query( "SELECT e.news_id, e.rating, e.vote_num, p.b_rating FROM ".PREFIX."_post p LEFT JOIN " . PREFIX . "_post_extras e ON p.id=e.news_id WHERE news_id ='$news_id'" );

    Pass Unrar: dle-guides.blogspot.com
    Download

    BARS-RATING BY SANDER

    Size: 5 KB .Rar

    Aucun commentaire:

    Enregistrer un commentaire