Add Sorting Support

This commit is contained in:
seiichiro 2022-02-03 17:16:26 +01:00
parent 391e946ea8
commit d6356648cd
3 changed files with 18 additions and 13 deletions

View file

@ -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);
}
?>
?>

View file

@ -9,7 +9,7 @@
<a href="{{ $startpage }}">{{ $galleryname }}</a>
{% if (!empty($crumbs)): %}
{% foreach($crumbs as $name => $path): %}
<span class="crumb"> / </span><a class="crumb" href="index.php?d={{ $path }}&s={{ $slice }}&p=1">{{ $name }}</a>
<span class="crumb"> / </span><a class="crumb" href="index.php?d={{ $path }}&so={{ $sort }}&s={{ $slice }}&p=1">{{ $name }}</a>
{% endforeach %}
{% endif %}
</div>
@ -19,6 +19,7 @@
<button type="submit"><i class="fa fa-search"></i></button>
<input type="hidden" name="d" value="{{ $dir }}">
<input type="hidden" name="s" value="{{ $slice }}">
<input type="hidden" name="so" value="{{ $sort }}">
</form>
</div>
</div>
@ -26,7 +27,7 @@
{% if(!empty($dirs)): %}
{% foreach($dirs as $d): %}
<div class="multi-image">
<a href="index.php?d={{ $dir }}/{{ $d }}&s={{ $slice }}&p=1">
<a href="index.php?d={{ $dir }}/{{ $d }}&so={{ $sort }}&s={{ $slice }}&p=1">
<img src="./img/folder.png" alt="{{ $d }}"/>
</a>
<p class="dirname">{{ $d }}</p>
@ -36,7 +37,7 @@
{% if(!empty($images)): %}
{% foreach($images as $image): %}
<div class="multi-image">
<a href="index.php?d={{ $dir }}&s=1&gs={{ $slice }}&p={{ $image['i'] }}{{ $filter }}">
<a href="index.php?d={{ $dir }}&{{ $sort }}&s=1&gs={{ $slice }}&p={{ $image['i'] }}{{ $filter }}">
<img src="{{ $image['t'] }}" alt="{{ $image['n'] }}"/>
</a>
</div>
@ -45,13 +46,13 @@
</div>
<div class="page-footer">
{% if ($page > 1): %}
<a id="link-first" href="/index.php?d={{ $dir }}&p=1&s={{ $slice }}{{ $filter }}">1</a>
<a id="link-prev" href="/index.php?d={{ $dir }}&p={{ $prev_page }}&s={{ $slice }}{{ $filter }}"><i class="fa fa-caret-left"></i></a>
<a id="link-first" href="/index.php?d={{ $dir }}&so={{ $sort }}&p=1&s={{ $slice }}{{ $filter }}">1</a>
<a id="link-prev" href="/index.php?d={{ $dir }}&so={{ $sort }}&p={{ $prev_page }}&s={{ $slice }}{{ $filter }}"><i class="fa fa-caret-left"></i></a>
{% endif %}
<span class="info">{{ $page }}</span>
{% if ($page < $last_page): %}
<a id="link-next" href="/index.php?d={{ $dir }}&p={{ $next_page }}&s={{ $slice }}{{ $filter }}"><i class="fa fa-caret-right"></i></a>
<a id="link-last" href="/index.php?d={{ $dir }}&p={{ $last_page }}&s={{ $slice }}{{ $filter }}">{{ $last_page }}</a>
<a id="link-next" href="/index.php?d={{ $dir }}&so={{ $sort }}&p={{ $next_page }}&s={{ $slice }}{{ $filter }}"><i class="fa fa-caret-right"></i></a>
<a id="link-last" href="/index.php?d={{ $dir }}&so={{ $sort }}&p={{ $last_page }}&s={{ $slice }}{{ $filter }}">{{ $last_page }}</a>
{% endif %}
</div>
</div>

View file

@ -10,15 +10,15 @@
<img src="{{ $imageurl }}" title="{{ $page }}/{{ $last_page }}" />
</div>
{% if ($page > 1): %}
<a id="link-prev" class="clickable clickable-left" href="/index.php?d={{ $dir }}&p={{ $prev_page }}&s=1&gs={{ $gallery_slice }}{{ $filter }}">
<a id="link-prev" class="clickable clickable-left" href="/index.php?d={{ $dir }}&so={{ $sort }}&p={{ $prev_page }}&s=1&gs={{ $gallery_slice }}{{ $filter }}">
<div></div>
</a>
{% endif %}
<a id="link-home" class="clickable clickable-center" href="/index.php?d={{ $dir }}&p={{ $gallery_page }}&s={{ $gallery_slice }}{{ $filter }}">
<a id="link-home" class="clickable clickable-center" href="/index.php?d={{ $dir }}&so={{ $sort }}&p={{ $gallery_page }}&s={{ $gallery_slice }}{{ $filter }}">
<div></div>
</a>
{% if ($page < $last_page): %}
<a id="link-next" class="clickable clickable-right" href="/index.php?d={{ $dir }}&p={{ $next_page }}&s=1&gs={{ $gallery_slice }}{{ $filter }}">
<a id="link-next" class="clickable clickable-right" href="/index.php?d={{ $dir }}&so={{ $sort }}&p={{ $next_page }}&s=1&gs={{ $gallery_slice }}{{ $filter }}">
<div></div>
</a>
{% endif %}
@ -26,7 +26,7 @@
<div class="page-footer">
{% if(!empty($tags)): %}
{% foreach($tags as $tag): %}
<a href="/index.php?d={{ $dir }}&s={{ $gallery_slice }}&f={{{ $tag }}}"><span class="tag">{{ $tag }}</span></a>
<a href="/index.php?d={{ $dir }}&so={{ $sort }}&s={{ $gallery_slice }}&f={{{ $tag }}}"><span class="tag">{{ $tag }}</span></a>
{% endforeach %}
{% endif %}
</div>