function echoPaginator($currentPage) { $comment_count = commentsCount(); $totalPages = ceil($comment_count / 10); if ($comment_count <= 10) { return; } $currentPageInt = intval($currentPage); $previousPage = $currentPageInt - 1; if ($currentPageInt > 1) { echoPageLink("{$previousPage}", "Προηγούμενη"); echoPageLink("1", "1"); } else { echoPageLinkWithId("{$currentPage}", "1", "currentPage"); } $previous = intval($currentPage) - 2; $count = 1; if ($previous > 2) { echo " ... "; } else { $previous = 2; $count = 5 - $currentPage; } while ($previous <= $totalPages && $count <= 5) { if ($previous == $currentPageInt) { echoPageLinkWithId("{$previous}", "{$previous}", "currentPage"); } else { echoPageLink("{$previous}", "{$previous}"); } echo " "; $count = $count + 1; $previous = $previous + 1; } if ($count == 6 && $previous < $totalPages + 1) { if (intval($currentPage) < $totalPages - 3) { echo " ... "; } echoPageLink("{$totalPages}", "{$totalPages}"); } if ($currentPageInt < $totalPages) { $nextPage = $currentPageInt + 1; echoPageLink("{$nextPage}", "Επόμενη"); } }
href="posts.php?category_id=<?php echo urlencode($post->category_id); ?> "><?php echo $post->name; ?> </a> <i class="fa fa-tags"></i> Tagged <a href=""><?php echo $post->tags; ?> </a> <div class="post-comments-badge"> <a href=""><i class="fa fa-comments"></i> <?php echo commentsCount($post->id); ?> </a> </div><!-- post-comments-badge --> </div><!-- post-details --> </header> <div class="post-image"> <img src="<?php echo BASE_URI; ?> images/<?php echo $post->photo; ?> " alt="city skyline"> </div><!-- post-image -->