From 60ae6bc3644356d5b00ba2a884c3ff1418d881da Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Sat, 27 Dec 2014 00:00:14 +0100 Subject: [PATCH] Display a diffrent table if poll is a classic one --- adminstuds.php | 2 +- studs.php | 2 +- tpl/part/vote_table_classic.tpl | 190 ++++++++++++++++++ .../{vote_table.tpl => vote_table_date.tpl} | 0 tpl/studs.tpl | 6 +- 5 files changed, 197 insertions(+), 3 deletions(-) create mode 100644 tpl/part/vote_table_classic.tpl rename tpl/part/{vote_table.tpl => vote_table_date.tpl} (100%) diff --git a/adminstuds.php b/adminstuds.php index 05aed7e..aae0bbd 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -327,7 +327,7 @@ $smarty->assign('poll_id', $poll_id); $smarty->assign('admin_poll_id', $admin_poll_id); $smarty->assign('poll', $poll); $smarty->assign('title', _('Poll') . ' - ' . $poll->title); -$smarty->assign('slots', $pollService->splitSlots($slots)); +$smarty->assign('slots', $poll->format === 'D' ? $pollService->splitSlots($slots) : $slots); $smarty->assign('votes', $pollService->splitVotes($votes)); $smarty->assign('best_moments', $pollService->computeBestMoments($votes)); $smarty->assign('comments', $comments); diff --git a/studs.php b/studs.php index a893a27..7ff18a5 100644 --- a/studs.php +++ b/studs.php @@ -169,7 +169,7 @@ $comments = $pollService->allCommentsByPollId($poll_id); $smarty->assign('poll_id', $poll_id); $smarty->assign('poll', $poll); $smarty->assign('title', _('Poll') . ' - ' . $poll->title); -$smarty->assign('slots', $pollService->splitSlots($slots)); +$smarty->assign('slots', $poll->format === 'D' ? $pollService->splitSlots($slots) : $slots); $smarty->assign('votes', $pollService->splitVotes($votes)); $smarty->assign('best_moments', $pollService->computeBestMoments($votes)); $smarty->assign('comments', $comments); diff --git a/tpl/part/vote_table_classic.tpl b/tpl/part/vote_table_classic.tpl new file mode 100644 index 0000000..7d7e703 --- /dev/null +++ b/tpl/part/vote_table_classic.tpl @@ -0,0 +1,190 @@ +{if !is_array($best_moments) || empty($best_moments)} + {$best_moments = [0]} +{/if} + +

{_('Votes of the poll')}

+ +
+
+ + + + {if $admin} + + + {foreach $slots as $id=>$slot} + + {/foreach} + + + {/if} + + + {foreach $slots as $id=>$slot} + + {/foreach} + + + + + {foreach $votes as $vote} + + {* Edited line *} + + + + {if $editingVoteId == $vote->id} + {foreach $vote->choices as $id=>$choice} + + + {/foreach} + + {else} + + {* Voted line *} + + {foreach $vote->choices as $choice} + + {if $choice==2} + + {elseif $choice==1} + + {else} + + {/if} + + {/foreach} + + {if $active && $poll->editable} + + {else} + + {/if} + {/if} + + {/foreach} + + {* Line to add a new vote *} + + {if $active && $editingVoteId == 0} + + + {foreach $slots as $id=>$slot} + + {/foreach} + + + {/if} + + {* Line displaying best moments *} + {$count_bests = 0} + {$max = max($best_moments)} + {if $max > 0} + + + {foreach $best_moments as $best_moment} + {if $max == $best_moment} + {$count_bests = $count_bests +1} + + {else} + + {/if} + {/foreach} + + {/if} + +
{_('Votes of the poll')} {$poll->title}
+ + + +
{$slot->sujet}
{$vote->name} +
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
+
{_('Yes')}(){_('Ifneedbe')}{_('No')} + + {if $admin} + + {/if} +
+
+ + +
+
+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
+
{_("Addition")}{$max}
+
+
+ +{* Best votes listing *} + +{$max = max($best_moments)} +{if $max > 0} +
+ {if $count_bests == 1} +

{_("Best choice")}

+
+

{_("The best choice at this time is:")}

+ {elseif $count_bests > 1} +

{_("Best choices")}

+
+

{_("The bests choices at this time are:")}

+ {/if} + + + {$i = 0} +
    + {foreach $slots as $slot} + {foreach $slot->moments as $moment} + {if $best_moments[$i] == $max} +
  • {$slot->sujet}
  • + {/if} + {$i = $i+1} + {/foreach} + {/foreach} +
+

{_("with")} {$max} {if $max==1}{_('vote')}{else}{_('votes')}{/if}.

+
+
+{/if} \ No newline at end of file diff --git a/tpl/part/vote_table.tpl b/tpl/part/vote_table_date.tpl similarity index 100% rename from tpl/part/vote_table.tpl rename to tpl/part/vote_table_date.tpl diff --git a/tpl/studs.tpl b/tpl/studs.tpl index 5eeb84c..c9ed65e 100644 --- a/tpl/studs.tpl +++ b/tpl/studs.tpl @@ -33,7 +33,11 @@ {* Vote table *} -{include 'part/vote_table.tpl' active=$poll->active} +{if $poll->format === 'D'} + {include 'part/vote_table_date.tpl' active=$poll->active} +{else} + {include 'part/vote_table_classic.tpl' active=$poll->active} +{/if} {* Comments *}