From ad5ea9c6ffbd7b3f712459ec5a1058c08c466bbe Mon Sep 17 00:00:00 2001 From: Olivier PEREZ <olivier@olivierperez.fr> Date: Mon, 15 Dec 2014 13:49:25 +0100 Subject: [PATCH] Display list of comments + Display form to add a comment --- studs.php | 2 ++ tpl/studs.tpl | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/studs.php b/studs.php index 87f8a46b..27f3c86e 100644 --- a/studs.php +++ b/studs.php @@ -84,6 +84,7 @@ if (!$poll) { // Retrieve data $slots = $connect->allSlotsByPollId($poll_id); $votes = $connect->allUserVotesByPollId($poll_id); +$comments = $connect->allCommentsByPollId($poll_id); // Assign data to template $smarty->assign('poll_id', $poll_id); @@ -92,6 +93,7 @@ $smarty->assign('title', _('Poll') . ' - ' . $poll->title); $smarty->assign('slots', split_slots($slots)); $smarty->assign('votes', split_votes($votes)); $smarty->assign('best_moments', computeBestMoments($votes)); +$smarty->assign('comments', $comments); $smarty->assign('editingVoteId', 0); // TODO Replace by the right ID //Utils::debug(computeBestMoments($votes));exit; diff --git a/tpl/studs.tpl b/tpl/studs.tpl index c4167e9d..9df42d08 100644 --- a/tpl/studs.tpl +++ b/tpl/studs.tpl @@ -258,5 +258,39 @@ </div> {/if} + {* Comments *} + + {if $poll->active} + <hr role="presentation" /> + + {* Comment list *} + + {if $comments|count > 0} + {foreach $comments as $comment} + <div class="comment"> + <b>{$comment->usercomment}</b> + <span class="comment">{nl2br($comment->comment)}</span> + </div> + {/foreach} + {/if} + + {* Add comment form *} + + <div class="hidden-print alert alert-info"> + <div class="col-md-6 col-md-offset-3"> + <fieldset id="add-comment"><legend>{_("Add a comment in the poll")}</legend> + <div class="form-group"> + <p><label for="commentuser">{_("Your name")}</label><input type=text class="form-control" name="commentuser" id="commentuser" /></p> + </div> + <div class="form-group"> + <p><label for="comment">{_("Your comment")}</label><br /> + <textarea name="comment" id="comment" class="form-control" rows="2" cols="40"></textarea></p> + </div> + <p class="text-center"><input type="submit" name="ajoutcomment" value="{_("Send the comment")}" class="btn btn-success"></p> + </fieldset> + </div> + <div class="clearfix"></div> + </div> + {/if} </form> {/block} \ No newline at end of file -- GitLab