Warning, file /webapps/ocs-webserver/application/modules/default/views/helpers/PrintRatingWidgetSimple.php was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 class Default_View_Helper_PrintRatingWidgetSimple extends Zend_View_Helper_Abstract 0023 { 0024 0025 public function printRatingWidgetSimple($score,$count_likes,$count_dislikes) 0026 { 0027 0028 $cssNoVotes = ($count_likes+$count_dislikes == 0) ? ';opacity:0.5;' : ''; 0029 // calculate colour 0030 $blue = $red = $green = $default=200; 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 0047 return $this->getHTML( 0048 floor($score ), 0049 $red, $green, $blue, 0050 floor((100 - $score) ), 0051 $cssNoVotes 0052 ); 0053 } 0054 0055 protected function getHTML($likes, $red, $green , $blue, $dislikes, $cssNoVotes) 0056 { 0057 return <<< _END_HTML_ 0058 0059 <div class="rating-text"> 0060 <small class="center-block text-center">Score {$likes}%</small> 0061 </div> 0062 <div class="progress"> 0063 <div class="progress-bar" style="background-color: #{$red}{$green}{$blue};width: {$likes}%;"> 0064 0065 </div> 0066 <div class="progress-bar" style="background-color:#eeeeee;width: {$dislikes}%;{$cssNoVotes}"> 0067 0068 </div> 0069 </div> 0070 0071 _END_HTML_; 0072 } 0073 0074 }