Add Sorting Support
This commit is contained in:
parent
391e946ea8
commit
d6356648cd
3 changed files with 18 additions and 13 deletions
|
@ -24,6 +24,7 @@ $page = $_GET['p'] ?? $conf['defpage'];
|
||||||
$slice = $_GET['s'] ?? $conf['defslice'];
|
$slice = $_GET['s'] ?? $conf['defslice'];
|
||||||
$gslice = $_GET['gs'] ?? $conf['defslice'];
|
$gslice = $_GET['gs'] ?? $conf['defslice'];
|
||||||
$dir = $_GET['d'] ?? $conf['defdir'];
|
$dir = $_GET['d'] ?? $conf['defdir'];
|
||||||
|
$sort = $_GET['so'] ?? 1;
|
||||||
|
|
||||||
// Create or Load Session
|
// Create or Load Session
|
||||||
session_start();
|
session_start();
|
||||||
|
@ -81,7 +82,9 @@ if (isset($_GET['f'])) {
|
||||||
|
|
||||||
// Sort and Reverse Filelist
|
// Sort and Reverse Filelist
|
||||||
natcasesort($files);
|
natcasesort($files);
|
||||||
$files = array_reverse($files);
|
if ($sort = 1)
|
||||||
|
$files = array_reverse($files);
|
||||||
|
|
||||||
if (!empty($dirs))
|
if (!empty($dirs))
|
||||||
$files = array_merge($dirs, $files);
|
$files = array_merge($dirs, $files);
|
||||||
|
|
||||||
|
@ -93,6 +96,7 @@ if (!empty($curfiles)| !empty($dirs)) {
|
||||||
$data['galleryname'] = $galleryname;
|
$data['galleryname'] = $galleryname;
|
||||||
$data['startpage'] = $_SERVER['PHP_SELF'];
|
$data['startpage'] = $_SERVER['PHP_SELF'];
|
||||||
$data['dir'] = $dir;
|
$data['dir'] = $dir;
|
||||||
|
$data['sort'] = $sort;
|
||||||
$data['slice'] = $slice;
|
$data['slice'] = $slice;
|
||||||
$data['filter'] = $filter;
|
$data['filter'] = $filter;
|
||||||
$data['pretty_filter'] = substr($filter,3);
|
$data['pretty_filter'] = substr($filter,3);
|
||||||
|
@ -144,4 +148,4 @@ if (!empty($curfiles)| !empty($dirs)) {
|
||||||
Template::view('tpl/notfound.html', $data);
|
Template::view('tpl/notfound.html', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<a href="{{ $startpage }}">{{ $galleryname }}</a>
|
<a href="{{ $startpage }}">{{ $galleryname }}</a>
|
||||||
{% if (!empty($crumbs)): %}
|
{% if (!empty($crumbs)): %}
|
||||||
{% foreach($crumbs as $name => $path): %}
|
{% 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 %}
|
{% endforeach %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -19,6 +19,7 @@
|
||||||
<button type="submit"><i class="fa fa-search"></i></button>
|
<button type="submit"><i class="fa fa-search"></i></button>
|
||||||
<input type="hidden" name="d" value="{{ $dir }}">
|
<input type="hidden" name="d" value="{{ $dir }}">
|
||||||
<input type="hidden" name="s" value="{{ $slice }}">
|
<input type="hidden" name="s" value="{{ $slice }}">
|
||||||
|
<input type="hidden" name="so" value="{{ $sort }}">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -26,7 +27,7 @@
|
||||||
{% if(!empty($dirs)): %}
|
{% if(!empty($dirs)): %}
|
||||||
{% foreach($dirs as $d): %}
|
{% foreach($dirs as $d): %}
|
||||||
<div class="multi-image">
|
<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 }}"/>
|
<img src="./img/folder.png" alt="{{ $d }}"/>
|
||||||
</a>
|
</a>
|
||||||
<p class="dirname">{{ $d }}</p>
|
<p class="dirname">{{ $d }}</p>
|
||||||
|
@ -36,7 +37,7 @@
|
||||||
{% if(!empty($images)): %}
|
{% if(!empty($images)): %}
|
||||||
{% foreach($images as $image): %}
|
{% foreach($images as $image): %}
|
||||||
<div class="multi-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'] }}"/>
|
<img src="{{ $image['t'] }}" alt="{{ $image['n'] }}"/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -45,13 +46,13 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="page-footer">
|
<div class="page-footer">
|
||||||
{% if ($page > 1): %}
|
{% if ($page > 1): %}
|
||||||
<a id="link-first" href="/index.php?d={{ $dir }}&p=1&s={{ $slice }}{{ $filter }}">1</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 }}&p={{ $prev_page }}&s={{ $slice }}{{ $filter }}"><i class="fa fa-caret-left"></i></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 %}
|
{% endif %}
|
||||||
<span class="info">{{ $page }}</span>
|
<span class="info">{{ $page }}</span>
|
||||||
{% if ($page < $last_page): %}
|
{% 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-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 }}&p={{ $last_page }}&s={{ $slice }}{{ $filter }}">{{ $last_page }}</a>
|
<a id="link-last" href="/index.php?d={{ $dir }}&so={{ $sort }}&p={{ $last_page }}&s={{ $slice }}{{ $filter }}">{{ $last_page }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,15 +10,15 @@
|
||||||
<img src="{{ $imageurl }}" title="{{ $page }}/{{ $last_page }}" />
|
<img src="{{ $imageurl }}" title="{{ $page }}/{{ $last_page }}" />
|
||||||
</div>
|
</div>
|
||||||
{% if ($page > 1): %}
|
{% 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>
|
<div></div>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% 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>
|
<div></div>
|
||||||
</a>
|
</a>
|
||||||
{% if ($page < $last_page): %}
|
{% 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>
|
<div></div>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<div class="page-footer">
|
<div class="page-footer">
|
||||||
{% if(!empty($tags)): %}
|
{% if(!empty($tags)): %}
|
||||||
{% foreach($tags as $tag): %}
|
{% 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 %}
|
{% endforeach %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue