Implement Error for nothing found
This commit is contained in:
parent
5650d15de0
commit
12f9149ca9
2 changed files with 47 additions and 31 deletions
66
index.php
66
index.php
|
@ -58,40 +58,44 @@ $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);
|
||||||
|
|
||||||
// Prepare Generic Data for Template
|
if (count($curfiles > 0)) {
|
||||||
$data['dir'] = $dir;
|
|
||||||
$data['slice'] = $slice;
|
|
||||||
$data['filter'] = $filter;
|
|
||||||
$data['page'] = $page;
|
|
||||||
$data['prev_page'] = $page - 1;
|
|
||||||
if ($data['prev_page'] < 1)
|
|
||||||
$data['prev_page'] = 1;
|
|
||||||
$data['next_page'] = $page + 1;
|
|
||||||
if ($data['next_page'] > ceil(count($files)/$slice))
|
|
||||||
$data['next_page'] = $page;
|
|
||||||
$data['last_page'] = ceil(count($files)/$slice);
|
|
||||||
|
|
||||||
// Prepare Mode Specific Data and Render Template
|
// Prepare Generic Data for Template
|
||||||
if ($slice > 1) {
|
$data['dir'] = $dir;
|
||||||
foreach ($curfiles as $index => $image) {
|
$data['slice'] = $slice;
|
||||||
print_r($image."\n");
|
$data['filter'] = $filter;
|
||||||
$tmp['n'] = $image;
|
$data['page'] = $page;
|
||||||
$tmp['i'] = $index+1;
|
$data['prev_page'] = $page - 1;
|
||||||
$tmp['t'] = $thumburl.$t->get_thumb($image);
|
if ($data['prev_page'] < 1)
|
||||||
$data['images'][] = $tmp;
|
$data['prev_page'] = 1;
|
||||||
|
$data['next_page'] = $page + 1;
|
||||||
|
if ($data['next_page'] > ceil(count($files)/$slice))
|
||||||
|
$data['next_page'] = $page;
|
||||||
|
$data['last_page'] = ceil(count($files)/$slice);
|
||||||
|
|
||||||
|
// Prepare Mode Specific Data and Render Template
|
||||||
|
if ($slice > 1) {
|
||||||
|
foreach ($curfiles as $index => $image) {
|
||||||
|
$tmp['n'] = $image;
|
||||||
|
$tmp['i'] = $index+1;
|
||||||
|
$tmp['t'] = $thumburl.$t->get_thumb($image);
|
||||||
|
$data['images'][] = $tmp;
|
||||||
|
}
|
||||||
|
Template::view('tpl/gallery.html', $data);
|
||||||
|
} else {
|
||||||
|
$data['gallery_page'] = ceil($page/$gslice);
|
||||||
|
$data['gallery_slice'] = $gslice;
|
||||||
|
foreach ($curfiles as $index => $image) {
|
||||||
|
$data['imageurl'] = $imageurl.$dir.'/'.$image;
|
||||||
|
$data['imagename'] = $image;
|
||||||
|
$data['tags'] = explode(" ", pathinfo(trim(strstr(strtolower($image), ' - '), " -"))['filename']);
|
||||||
|
}
|
||||||
|
Template::view('tpl/single.html', $data);
|
||||||
}
|
}
|
||||||
Template::view('tpl/gallery.html', $data);
|
|
||||||
} else {
|
} else {
|
||||||
$data['gallery_page'] = ceil($page/$gslice);
|
$data['filter'] = substr($filter,2);
|
||||||
$data['gallery_slice'] = $gslice;
|
$data['script'] = $_SERVER['PHP_SELF'];
|
||||||
foreach ($curfiles as $index => $image) {
|
Template::view('tpl/notfound.html', $data);
|
||||||
$data['imageurl'] = $imageurl.$dir.'/'.$image;
|
|
||||||
$data['imagename'] = $image;
|
|
||||||
$data['tags'] = explode(" ", pathinfo(trim(strstr(strtolower($image), ' - '), " -"))['filename']);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Template::view('tpl/single.html', $data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
12
tpl/notfound.html
Normal file
12
tpl/notfound.html
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{% extends tpl/layout.html %}
|
||||||
|
|
||||||
|
{% block title %}Nothing found{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<p class="error">Nothing found with search term {{ $filter }}</p>
|
||||||
|
<p class="error">Return to <a href="{{ $script }}">Homepage</a></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
Loading…
Reference in a new issue