Display list of comments + Display form to add a comment

This commit is contained in:
Olivier PEREZ 2014-12-15 13:49:25 +01:00
parent 497762165f
commit ad5ea9c6ff
2 changed files with 36 additions and 0 deletions

View File

@ -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;

View File

@ -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>&nbsp;
<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}