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 $modelRating = new Default_Model_DbTable_ProjectRating();
0024 $rating = $modelRating->fetchRating($this->project_id);
0025 $likesAndDislikes = ($rating['count_likes'] == 0 and $rating['count_dislikes'] == 0) ? '' : '(' . $rating['count_likes'] . '/' . $rating['count_dislikes'] . ')';
0026 $cssNoVotes = ($rating['votes_total'] == 0) ? ';opacity:0.5;' : '';
0027 
0028 // calculate colour
0029 $blue = $red = $green = $default=200;
0030 $score = $rating['laplace_score'] * 100;
0031 
0032 if($score>50) {
0033     $red=dechex($default-(($score-50)*4));
0034     $green=dechex($default);
0035     $blue=dechex($default-(($score-50)*4));
0036 }elseif($score<51) {
0037     $red=dechex($default);
0038     $green=dechex($default-((50-$score)*4));
0039     $blue=dechex($default-((50-$score)*4));
0040 }
0041 if(strlen($green)==1) $green='0'.$green;
0042 if(strlen($red)==1) $red='0'.$red;
0043 
0044 ?>
0045   <div>
0046     <?php /** 
0047     <div style="float: left;width: 12px;">
0048         <div id="outer">
0049             <div id="inner" style="background-color: #<?=$red.$green.$blue?>;height: <?= floor($rating['laplace_score'] * 100) ?>%;">
0050                 <div></div>
0051             </div>
0052         </div>
0053     </div>
0054     **/?>
0055     <div style="float: right;width: 40px;" class="text-center">
0056       <div style="padding-top: 0px;">
0057         <a href="#" onclick="false;"><img src="/theme/flatui/img/new/arrow_up.png" style="width: 20px;"/></a><br/>
0058         <small><?= $rating['count_likes'] ?></small> 
0059       </div>
0060       <div class="rating-text" style="padding-top: 5px;">
0061           <small>Score <?= floor($rating['laplace_score'] * 100) ?>%</small>
0062         </div>
0063         <div style="padding-top: 7px;">
0064         <small><?= $rating['count_dislikes'] ?><br/></small>
0065         <a href="#" onclick="false;"><img src="/theme/flatui/img/new/arrow_down.png" style="width: 20px;"/></a> 
0066       </div>
0067     </div>
0068   </div>
0069   
0070   
0071   <?php /** 
0072                 <div class="rating" style="width:50%;">
0073                   
0074                     <div class="rating-text">
0075                         <small class="center-block text-center">Score <?= floor($rating['laplace_score'] * 100) ?>%</small>
0076                     </div>
0077                     <div class="progress" style="margin-bottom: 0;height:12px;opacity:1.0;background-color: transparent; box-shadow: none; padding:2px;">
0078                         <div class="progress-bar" style="background-color: #<?=$red.$green.$blue?>;width: <?= floor($rating['laplace_score'] * 100) ?>%;">
0079                             <span class="sr-only"><?= $rating['laplace_score'] * 100 ?> Likes</span>
0080                         </div>
0081                         <div class="progress-bar" style="background-color:#eeeeee;width: <?= floor((1 - $rating['laplace_score']) * 100) ?>%;<?=$cssNoVotes?>">
0082                             <span class="sr-only"><?= (1 - $rating['laplace_score']) * 100 ?> Dislikes</span>
0083                         </div>
0084                     </div>
0085                     <table cellpadding="0" cellspacing="0" width="100%">
0086                 <tbody>
0087                 <tr>
0088                     <td width="50%" class="text-left">
0089                         <small><?= $rating['count_dislikes'] ?></small> 
0090                     </td>
0091                     <td width="50%" class="text-right">
0092                         <small><?= $rating['count_likes'] ?></small> 
0093                     </td>
0094             </tr>
0095             </tbody>                  
0096                   </table>
0097                 </div>
0098 **/?>