summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.php2
-rw-r--r--src/partials.php23
-rw-r--r--src/utils.php2
3 files changed, 25 insertions, 2 deletions
diff --git a/src/config.php b/src/config.php
index 7c740d1..e224b72 100644
--- a/src/config.php
+++ b/src/config.php
@@ -1,4 +1,6 @@
<?php
+define("CLIENT_REQUIRES_JSON", isset($_SERVER["HTTP_ACCEPT"]) && $_SERVER["HTTP_ACCEPT"] == "application/json");
+
// DATABASE
define("DB_USER", "kochan");
define("DB_PASS", "kochan");
diff --git a/src/partials.php b/src/partials.php
index 0b21b50..9b02a7b 100644
--- a/src/partials.php
+++ b/src/partials.php
@@ -94,4 +94,27 @@ function html_navigation_search()
</div>
</section>
<?php ;
+}
+
+function html_pagination(int $total_pages, int $current_page, string $redirect)
+{
+ if (str_contains($redirect, "?")) {
+ $redirect .= "&p=";
+ } else {
+ $redirect .= "?p=";
+ }
+
+ if ($total_pages > 1) {
+ echo '' ?>
+ <div class="pagination">
+ <?php if ($current_page > 1): ?>
+ <a href="<?php echo $redirect . ($current_page - 1) ?>">[ prev ]</a>
+ <?php endif; ?>
+ <?php if ($current_page < $total_pages): ?>
+ <a href="<?php echo $redirect . ($current_page + 1) ?>">[ next ]</a>
+ <?php endif; ?>
+
+ </div>
+ <?php ;
+ }
} \ No newline at end of file
diff --git a/src/utils.php b/src/utils.php
index a11fa16..6356cfb 100644
--- a/src/utils.php
+++ b/src/utils.php
@@ -1,6 +1,4 @@
<?php
-define("CLIENT_REQUIRES_JSON", isset($_SERVER["HTTP_ACCEPT"]) && $_SERVER["HTTP_ACCEPT"] == "application/json");
-
function json_response(mixed $response, int $status = 200)
{
http_response_code($status);