File indexing completed on 2024-12-29 05:24:45
0001 <?php 0002 /** 0003 * ocs-webserver 0004 * 0005 * Copyright 2016 by pling GmbH. 0006 * 0007 * This file is part of ocs-webserver. 0008 * 0009 * This program is free software: you can redistribute it and/or modify 0010 * it under the terms of the GNU Affero General Public License as 0011 * published by the Free Software Foundation, either version 3 of the 0012 * License, or (at your option) any later version. 0013 * 0014 * This program is distributed in the hope that it will be useful, 0015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 * GNU Affero General Public License for more details. 0018 * 0019 * You should have received a copy of the GNU Affero General Public License 0020 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 **/ 0022 0023 $cssNoVotes = (($this->widgetRating->count_likes + $this->widgetRating->count_dislikes) == 0) ? ';opacity:0.5;' : ''; 0024 0025 0026 // calculate colour 0027 $blue = $red = $green = $default=200; 0028 $score = $this->widgetRating->laplace_score; 0029 0030 $score = round($score/10,0); 0031 0032 if($score==0) 0033 $score = 50; 0034 0035 if($score>50) { 0036 $red=dechex($default-(($score-50)*4)); 0037 $green=dechex($default); 0038 $blue=dechex($default-(($score-50)*4)); 0039 }elseif($score<51) { 0040 $red=dechex($default); 0041 $green=dechex($default-((50-$score)*4)); 0042 $blue=dechex($default-((50-$score)*4)); 0043 } 0044 if(strlen($green)==1) $green='0'.$green; 0045 if(strlen($red)==1) $red='0'.$red; 0046 if(strlen($blue)==1) $blue='0'.$blue; 0047 0048 ?> 0049 <div class="rating"> 0050 0051 <div class="rating-text"> 0052 <small class="center-block text-center"> 0053 Score <?=number_format($this->widgetRating->laplace_score/10,1)?>% 0054 </small> 0055 </div> 0056 <div class="progress"> 0057 <div class="progress-bar" style="background-color: #<?= $red . $green . $blue ?>;width: <?= floor($score) ?>%;"> 0058 </div> 0059 <div class="progress-bar" style="background-color:#eeeeee;width: <?= (100 - floor($score)) ?>%;<?= $cssNoVotes ?>"> 0060 </div> 0061 </div> 0062 0063 </div>