From d6356648cd06890cf3fd410c877f55c512090fb0 Mon Sep 17 00:00:00 2001 From: Stefan Brand Date: Thu, 3 Feb 2022 17:16:26 +0100 Subject: [PATCH] Add Sorting Support --- index.php | 8 ++++++-- tpl/gallery.html | 15 ++++++++------- tpl/single.html | 8 ++++---- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/index.php b/index.php index 7e197ec..efd8d0e 100644 --- a/index.php +++ b/index.php @@ -24,6 +24,7 @@ $page = $_GET['p'] ?? $conf['defpage']; $slice = $_GET['s'] ?? $conf['defslice']; $gslice = $_GET['gs'] ?? $conf['defslice']; $dir = $_GET['d'] ?? $conf['defdir']; +$sort = $_GET['so'] ?? 1; // Create or Load Session session_start(); @@ -81,7 +82,9 @@ if (isset($_GET['f'])) { // Sort and Reverse Filelist natcasesort($files); -$files = array_reverse($files); +if ($sort = 1) + $files = array_reverse($files); + if (!empty($dirs)) $files = array_merge($dirs, $files); @@ -93,6 +96,7 @@ if (!empty($curfiles)| !empty($dirs)) { $data['galleryname'] = $galleryname; $data['startpage'] = $_SERVER['PHP_SELF']; $data['dir'] = $dir; + $data['sort'] = $sort; $data['slice'] = $slice; $data['filter'] = $filter; $data['pretty_filter'] = substr($filter,3); @@ -144,4 +148,4 @@ if (!empty($curfiles)| !empty($dirs)) { Template::view('tpl/notfound.html', $data); } -?> \ No newline at end of file +?> diff --git a/tpl/gallery.html b/tpl/gallery.html index 6bb69a2..c59e964 100644 --- a/tpl/gallery.html +++ b/tpl/gallery.html @@ -9,7 +9,7 @@ {{ $galleryname }} {% if (!empty($crumbs)): %} {% foreach($crumbs as $name => $path): %} - / {{ $name }} + / {{ $name }} {% endforeach %} {% endif %} @@ -19,6 +19,7 @@ + @@ -26,7 +27,7 @@ {% if(!empty($dirs)): %} {% foreach($dirs as $d): %}
- + {{ $d }}

{{ $d }}

@@ -36,7 +37,7 @@ {% if(!empty($images)): %} {% foreach($images as $image): %} @@ -45,13 +46,13 @@
diff --git a/tpl/single.html b/tpl/single.html index 66c604e..dd5f4fd 100644 --- a/tpl/single.html +++ b/tpl/single.html @@ -10,15 +10,15 @@ {% if ($page > 1): %} - {% endif %} - +
{% if ($page < $last_page): %} - {% endif %} @@ -26,7 +26,7 @@