Add directory Support

This commit is contained in:
seiichiro 2022-01-11 16:25:49 +01:00
parent 45e8519618
commit 75682cb2ba
4 changed files with 15 additions and 3 deletions

View file

@ -22,6 +22,6 @@ $conf['defpage'] = 1;
// Images per Page if not specified // Images per Page if not specified
$conf['defslice'] = 34; $conf['defslice'] = 34;
// Default Subdirectory if none given // Default Subdirectory if none given
$conf['defdir'] = 'r34'; $conf['defdir'] = '';
?> ?>

BIN
img/folder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

@ -36,7 +36,11 @@ if (isset($_SESSION['files'])
{ {
$files = $_SESSION['files']; $files = $_SESSION['files'];
} else { } else {
$files = array_diff(scandir($imagedir.$dir, SCANDIR_SORT_DESCENDING), array('..', '.')); $dirs = glob($imagedir.$dir.'/*' , GLOB_ONLYDIR);
$rmdirs = $dirs;
$rmdirs[] = '.';
$rmdirs[] = '..';
$files = array_diff(scandir($imagedir.$dir, SCANDIR_SORT_DESCENDING), $rmdirs);
$_SESSION['files'] = $files; $_SESSION['files'] = $files;
$_SESSION['dir'] = $dir; $_SESSION['dir'] = $dir;
$_SESSION['cachetime'] = time(); $_SESSION['cachetime'] = time();
@ -60,7 +64,7 @@ $files = array_reverse($files);
// Get Files for current Page // Get Files for current Page
$curfiles = array_slice($files, ($page-1)*$slice ,$slice, true); $curfiles = array_slice($files, ($page-1)*$slice ,$slice, true);
if (count($curfiles) > 0) { if (count($curfiles) > 0 | count($dirs) > 0) {
// Prepare Generic Data for Template // Prepare Generic Data for Template
$data['galleryname'] = $galleryname; $data['galleryname'] = $galleryname;
$data['startpage'] = $_SERVER['PHP_SELF']; $data['startpage'] = $_SERVER['PHP_SELF'];
@ -83,6 +87,7 @@ if (count($curfiles) > 0) {
$tmp['i'] = $index+1; $tmp['i'] = $index+1;
$tmp['t'] = $thumburl.$t->get_thumb($image); $tmp['t'] = $thumburl.$t->get_thumb($image);
$data['images'][] = $tmp; $data['images'][] = $tmp;
$data['dirs'] = $dirs;
} }
Template::view('tpl/gallery.html', $data); Template::view('tpl/gallery.html', $data);
} else { } else {

View file

@ -16,6 +16,13 @@
</div> </div>
</div> </div>
<div class="content"> <div class="content">
{% foreach($dirs as $d): %}
<div class="multi-image">
<a href="index.php?d={{ $d }}&s=1&gs={{ $slice }}&p=1">
<img src="./img/folder.png" alt="{{ $d }}"/>
</a>
</div>
{% endforeach %}
{% 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 }}&s=1&gs={{ $slice }}&p={{ $image['i'] }}{{ $filter }}">