Skip to content

Commit

Permalink
Merge pull request #529 from wmde/commentpagination
Browse files Browse the repository at this point in the history
Added pagination to comment list html template
  • Loading branch information
JeroenDeDauw committed Jun 29, 2016
2 parents 085831d + cb5f0f2 commit 9412cf4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ function( Request $request ) use ( $app, $ffFactory ) {
10,
(int)$request->query->get( 'page', '1' )
)
)
),
(int)$request->query->get( 'page', '1' )
)
);
}
Expand Down
16 changes: 15 additions & 1 deletion app/templates/CommentList.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,21 @@
</div>
{% endfor %}

<!-- TODO: pagination -->
<div style="display: inline-block; width: 100%">
<div style="display: inline-block; text-align:left; width: 33%;">
{% if page > 1 %}
<a href="?page=1"><span class="icon-first"></span></a>
<a href="?page={$ page - 1 $}"><span class="icon-previous"></span></a>
{% endif %}
</div>
<div style="display: inline-block; text-align:center; width: 32%;">{$ 'pagination_page_n_of_x'|trans( { '%page%': page, '%max_pages%': max_pages } ) $}</div>
<div style="display: inline-block; text-align:right; width: 33%;">
{% if page < max_pages %}
<a href="?page={$ page + 1 $}"><span class="icon-next"></span></a>
<a href="?page={$ max_pages $}"><span class="icon-last"></span></a>
{% endif %}
</div>
</div>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/translations/messages.de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"comment_failure_donation_has_comment": "Die Spende wurde bereits kommentiert.",
"comment_failure_save_error": "Der Kommentar konte nicht gespeichert werden.",
"comment_success_ok": "Vielen Dank! Die Nachricht wurde verschickt!",
"comment_success_needs_moderation": "Ihr Kommentar wurde von unserem System zur 脺berpr眉fung vorgemerkt und steht daher nicht automatisch in der 枚ffentlichen Spenderliste."

"comment_success_needs_moderation": "Ihr Kommentar wurde von unserem System zur 脺berpr眉fung vorgemerkt und steht daher nicht automatisch in der 枚ffentlichen Spenderliste.",
"pagination_page_n_of_x": "Seite %page% von %max_pages%+"
}
4 changes: 3 additions & 1 deletion src/Presentation/Presenters/CommentListHtmlPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct( TwigTemplate $template ) {
$this->template = $template;
}

public function present( CommentList $commentList ): string {
public function present( CommentList $commentList, int $pageNumber ): string {
return $this->template->render( [
'comments' => array_map(
function( CommentWithAmount $comment ) {
Expand All @@ -33,6 +33,8 @@ function( CommentWithAmount $comment ) {
},
$commentList->toArray()
),
'page' => $pageNumber,
'max_pages' => 100
] );
}

Expand Down

0 comments on commit 9412cf4

Please sign in to comment.