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 /** 0024 Get the voting-data from table project for better performance 0025 $modelRating = new Default_Model_DbTable_ProjectRating(); 0026 $rating = $modelRating->fetchRating($this->product->project_id); 0027 **/ 0028 //$helper = new Default_View_Helper_BuildProductUrl(); 0029 //$urlDislike = $helper->buildProductUrl($this->product->project_id, 'rating', array('rate' => 2)); 0030 //$urlLike = $helper->buildProductUrl($this->product->project_id, 'rating', array('rate' => 1)); 0031 0032 //$likesAndDislikes = ($this->product->count_likes == 0 and $this->product->count_dislikes == 0) ? '' : '(' . $this->product->count_likes . '/' . $this->product->count_dislikes . ')'; 0033 //$cssNoVotes = (($this->product->count_likes+$this->product->count_dislikes) == 0) ? ';opacity:0.5;' : ''; 0034 0035 // calculate colour 0036 $blue = $red = $green = $default=200; 0037 //$score = $this->product->laplace_score; 0038 $model = new Default_Model_DbTable_ProjectRating(); 0039 $score = $model->getScoreOld($this->product->project_id); 0040 /* 0041 if($score==0) 0042 $score = 50;*/ 0043 0044 if($score>50) { 0045 $red=dechex($default-(($score-50)*4)); 0046 $green=dechex($default); 0047 $blue=dechex($default-(($score-50)*4)); 0048 }elseif($score<51) { 0049 $red=dechex($default); 0050 $green=dechex($default-((50-$score)*4)); 0051 $blue=dechex($default-((50-$score)*4)); 0052 } 0053 if(strlen($green)==1) $green='0'.$green; 0054 if(strlen($red)==1) $red='0'.$red; 0055 0056 0057 ?> 0058 <div id="widget-rating" class="prod-widget-box right" style="border:0px !important"> 0059 <!--<h4 id="extra-products-heading" class="small upcase sidebar-heading">Vote for this product</h4>--> 0060 0061 <table cellpadding="0" cellspacing="0" width="100%"> 0062 <tbody> 0063 <tr> 0064 <td width="10%" class="text-center"> 0065 <a class="btn btn-danger partialreview votedown <?=$this->ratingOfUser!=null && $this->ratingOfUser['user_dislike']>0 ? 'active' :''?>" 0066 role="button" 0067 style="line-height:10px;" 0068 data-target="#widget-rating" 0069 data-fragment="#widget-rating > *"> 0070 <span class="fa fa-minus" aria-hidden="true"></span> 0071 </a> 0072 <?php /** <span><?= $rating['count_dislikes'] ?></span>**/?> 0073 </td> 0074 <td style="padding-left:0.2em;padding-right: 0.2em;"> 0075 <div class="rating"> 0076 <div class="rating-text"> 0077 <small class="center-block text-center">Score <?= floor($score)?>% 0078 0079 </small> 0080 </div> 0081 <div class="progress" style="margin-bottom: 0;height:12px;background-color: transparent; box-shadow: none; padding:2px;"> 0082 <div class="progress-bar" style="background-color: #<?=$red.$green.$blue?>;width: <?= floor($score) ?>%;"> 0083 0084 </div> 0085 <div class="progress-bar" style="background-color:#eeeeee;width: <?= floor(100 - $score) ?>%;"> 0086 0087 </div> 0088 </div> 0089 </div> 0090 </td> 0091 <td width="10%" class="text-center"> 0092 <a class="btn btn-success partialreview voteup <?=$this->ratingOfUser!=null && $this->ratingOfUser['user_like']>0 ? 'active' :''?> " 0093 role="button" 0094 style="line-height:10px;" 0095 data-target="#widget-rating" 0096 data-fragment="#widget-rating > *"> 0097 <span class="fa fa-plus" aria-hidden="true"></span> 0098 </a> 0099 0100 </td> 0101 </tr> 0102 </tbody> 0103 </table> 0104 </div> 0105 <?php 0106 $this->inlineScript()->appendScript( 0107 ' $(document).ready(function(){ 0108 PartialsReview.setup(); 0109 }); 0110 ');