Display the count of 'if need be'
This commit is contained in:
parent
7ed21ce9fa
commit
551b839292
@ -20,9 +20,8 @@ namespace Framadate\Services;
|
||||
|
||||
use Framadate\Form;
|
||||
use Framadate\FramaDB;
|
||||
use Framadate\Utils;
|
||||
use Framadate\Security\Token;
|
||||
use Framadate\Repositories\RepositoryFactory;
|
||||
use Framadate\Security\Token;
|
||||
|
||||
class PollService {
|
||||
|
||||
@ -117,15 +116,19 @@ class PollService {
|
||||
}
|
||||
|
||||
function computeBestChoices($votes) {
|
||||
$result = [];
|
||||
$result = ['y' => [0], 'inb' => [0]];
|
||||
foreach ($votes as $vote) {
|
||||
$choices = str_split($vote->choices);
|
||||
foreach ($choices as $i => $choice) {
|
||||
if (empty($result[$i])) {
|
||||
$result[$i] = 0;
|
||||
if (!isset($result['y'][$i])) {
|
||||
$result['inb'][$i] = 0;
|
||||
$result['y'][$i] = 0;
|
||||
}
|
||||
if ($choice == 1) {
|
||||
$result['inb'][$i]++;
|
||||
}
|
||||
if ($choice == 2) {
|
||||
$result[$i]++;
|
||||
$result['y'][$i]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,6 +88,10 @@ header h1 {
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.very-small {
|
||||
font-size: 70%;
|
||||
}
|
||||
|
||||
/* Effet sur les images en page d'accueil */
|
||||
.opacity img {
|
||||
opacity: 0.8;
|
||||
|
@ -154,16 +154,16 @@
|
||||
{if !$hidden}
|
||||
{* Line displaying best moments *}
|
||||
{$count_bests = 0}
|
||||
{$max = max($best_choices)}
|
||||
{$max = max($best_choices['y'])}
|
||||
{if $max > 0}
|
||||
<tr id="addition">
|
||||
<td>{__('Poll results', 'Addition')}</td>
|
||||
{foreach $best_choices as $best_choice}
|
||||
{foreach $best_choices['y'] as $i=>$best_choice}
|
||||
{if $max == $best_choice}
|
||||
{$count_bests = $count_bests +1}
|
||||
<td><span class="glyphicon glyphicon-star text-warning"></span>{$best_choice|html}</td>
|
||||
<td><span class="glyphicon glyphicon-star text-warning"></span>{$best_choice|html}{if $best_choices['inb'][$i]>0}<span class="very-small text-muted"> (+{$best_choices['inb'][$i]|html})</span>{/if}</td>
|
||||
{elseif $best_choice > 0}
|
||||
<td>{$best_choice|html}</td>
|
||||
<td>{$best_choice|html}{if $best_choices['inb'][$i]>0}<span class="very-small text-muted"> (+{$best_choices['inb'][$i]|html})</span>{/if}</td>
|
||||
{else}
|
||||
<td></td>
|
||||
{/if}
|
||||
@ -178,7 +178,7 @@
|
||||
|
||||
{if !$hidden}
|
||||
{* Best votes listing *}
|
||||
{$max = max($best_choices)}
|
||||
{$max = max($best_choices['y'])}
|
||||
{if $max > 0}
|
||||
<div class="row">
|
||||
{if $count_bests == 1}
|
||||
@ -195,7 +195,7 @@
|
||||
{$i = 0}
|
||||
<ul style="list-style:none">
|
||||
{foreach $slots as $slot}
|
||||
{if $best_choices[$i] == $max}
|
||||
{if $best_choices['y'][$i] == $max}
|
||||
<li><strong>{$slot->title|markdown:true}</strong></li>
|
||||
{/if}
|
||||
{$i = $i+1}
|
||||
|
@ -207,16 +207,16 @@
|
||||
{if !$hidden}
|
||||
{* Line displaying best moments *}
|
||||
{$count_bests = 0}
|
||||
{$max = max($best_choices)}
|
||||
{$max = max($best_choices['y'])}
|
||||
{if $max > 0}
|
||||
<tr id="addition">
|
||||
<td>{__('Poll results', 'Addition')}</td>
|
||||
{foreach $best_choices as $best_moment}
|
||||
{foreach $best_choices['y'] as $i=>$best_moment}
|
||||
{if $max == $best_moment}
|
||||
{$count_bests = $count_bests +1}
|
||||
<td><i class="glyphicon glyphicon-star text-warning"></i>{$best_moment|html}</td>
|
||||
<td class="text-danger"><i class="glyphicon glyphicon-star text-warning"></i>{$best_moment|html}{if $best_choices['inb'][$i]>0}<span class="very-small text-muted"> (+{$best_choices['inb'][$i]|html})</span>{/if}</td>
|
||||
{elseif $best_moment > 0}
|
||||
<td>{$best_moment|html}</td>
|
||||
<td>{$best_moment|html}{if $best_choices['inb'][$i]>0}<span class="very-small text-muted"> (+{$best_choices['inb'][$i]|html})</span>{/if}</td>
|
||||
{else}
|
||||
<td></td>
|
||||
{/if}
|
||||
@ -231,7 +231,7 @@
|
||||
|
||||
{if !$hidden}
|
||||
{* Best votes listing *}
|
||||
{$max = max($best_choices)}
|
||||
{$max = max($best_choices['y'])}
|
||||
{if $max > 0}
|
||||
<div class="row">
|
||||
{if $count_bests == 1}
|
||||
@ -249,7 +249,7 @@
|
||||
<ul style="list-style:none">
|
||||
{foreach $slots as $slot}
|
||||
{foreach $slot->moments as $moment}
|
||||
{if $best_choices[$i] == $max}
|
||||
{if $best_choices['y'][$i] == $max}
|
||||
<li><strong>{$slot->day|date_format:$date_format.txt_full|html} - {$moment|html}</strong></li>
|
||||
{/if}
|
||||
{$i = $i+1}
|
||||
|
Loading…
Reference in New Issue
Block a user