...
This commit is contained in:
parent
e85a45cb17
commit
f3ae2ea1df
4 changed files with 147 additions and 18 deletions
|
|
@ -71,13 +71,43 @@ class GalleryController extends Controller
|
||||||
->with("imagelist",$imagelist)
|
->with("imagelist",$imagelist)
|
||||||
->with("tour_name",$tour_name);
|
->with("tour_name",$tour_name);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/*
|
|
||||||
tour-1
|
|
||||||
2023-04-24-ref1png.jpg
|
|
||||||
*/
|
|
||||||
|
|
||||||
return redirect('/tour/index_old');
|
public function show_deleted_images($tour_id)
|
||||||
|
{
|
||||||
|
Log::info("GalleryController::show_deleted");
|
||||||
|
if(Auth::user()->role!="ADMIN") {
|
||||||
|
return redirect('/tour/index_old');
|
||||||
|
}
|
||||||
|
|
||||||
|
$imagelist_orig = Storage::disk('img_storage')->files("tour-$tour_id-DELETED");
|
||||||
|
$imagelist=[];
|
||||||
|
foreach($imagelist_orig as $image) {
|
||||||
|
|
||||||
|
$arr = explode("/", $image);
|
||||||
|
$image = end($arr);
|
||||||
|
|
||||||
|
$before = $image;
|
||||||
|
if (str_ends_with($image, "_gross.jpg")) {
|
||||||
|
$image = substr($image, 0, -10); # Remove last 10 characters
|
||||||
|
$imagenames=[$image, $image]; # filename, displayname
|
||||||
|
|
||||||
|
$imagefilename=$image.".jpg";
|
||||||
|
Log::info("Searching displayname for filenamename $imagefilename");
|
||||||
|
$row = DB::table('gallery_items')->select('displayname')->where('filename',$imagefilename)->get();
|
||||||
|
$displayname = sizeof($row) ? $row[0]->displayname : $imagefilename;
|
||||||
|
Log::info("=> $displayname");
|
||||||
|
|
||||||
|
array_push($imagelist, [$image, $displayname] );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//dd($imagelist);
|
||||||
|
$tour_name = DB::select("select name from tours where id=".$tour_id)[0]->name;
|
||||||
|
return view('tour/gallery/show_deleted')->with("tour_id",$tour_id)
|
||||||
|
->with("imagelist",$imagelist)
|
||||||
|
->with("tour_name",$tour_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -148,7 +178,8 @@ class GalleryController extends Controller
|
||||||
return redirect("/tour/gallery/$tour_id");
|
return redirect("/tour/gallery/$tour_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete_image($tour_id, $image_name) {
|
public function delete_image($tour_id, $image_name) {
|
||||||
|
Log::info("GalleryController::delete_image, tour_id=$tour_id, image_name=$image_name");
|
||||||
$image_name = explode(".", $image_name)[0];
|
$image_name = explode(".", $image_name)[0];
|
||||||
$files = [$image_name . ".jpg" , $image_name . "_gross.jpg"];
|
$files = [$image_name . ".jpg" , $image_name . "_gross.jpg"];
|
||||||
$sourceDir = storage_path() . "/img_storage/tour-$tour_id";
|
$sourceDir = storage_path() . "/img_storage/tour-$tour_id";
|
||||||
|
|
@ -165,6 +196,23 @@ class GalleryController extends Controller
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function restore_image($tour_id, $image_name) {
|
||||||
|
Log::info("GalleryController::restore_image, tour_id=$tour_id, image_name=$image_name");
|
||||||
|
$image_name = explode(".", $image_name)[0];
|
||||||
|
$files = [$image_name . ".jpg" , $image_name . "_gross.jpg"];
|
||||||
|
$targetDir = storage_path() . "/img_storage/tour-$tour_id";
|
||||||
|
$sourceDir = storage_path() . "/img_storage/tour-$tour_id-DELETED";
|
||||||
|
|
||||||
|
if (!file_exists($targetDir)) {
|
||||||
|
mkdir($targetDir, 0777, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($files as $file) {
|
||||||
|
rename("$sourceDir/$file", "$targetDir/$file");
|
||||||
|
}
|
||||||
|
return redirect("/tour/gallery/$tour_id/show_deleted");
|
||||||
|
}
|
||||||
|
|
||||||
public function name_image(Request $request, $tour_id, $image_name) {
|
public function name_image(Request $request, $tour_id, $image_name) {
|
||||||
$displayname = $request->new_image_name;
|
$displayname = $request->new_image_name;
|
||||||
Log::info("GalleryController::name_image for tour $tour_id , image_name=$image_name, display_name=$displayname");
|
Log::info("GalleryController::name_image for tour $tour_id , image_name=$image_name, display_name=$displayname");
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,8 @@
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="container text-center text-light mt-5">
|
<div class="container text-center text-light mt-5">
|
||||||
|
|
||||||
|
|
||||||
<h1>{{$tour_name}}</h1>
|
<h1>{{$tour_name}}</h1>
|
||||||
|
|
||||||
|
|
||||||
<div class="container text-primary" style="display:flex">
|
<div class="container text-primary" style="display:flex">
|
||||||
<!-- <ul class="list-group offset-2 col-8" style="display:inline"> -->
|
<!-- <ul class="list-group offset-2 col-8" style="display:inline"> -->
|
||||||
<ul class="list-group offset-2 col-8" style="display:flex; flex-direction: row;">
|
<ul class="list-group offset-2 col-8" style="display:flex; flex-direction: row;">
|
||||||
|
|
@ -37,6 +35,8 @@
|
||||||
</label>
|
</label>
|
||||||
@endforeach
|
@endforeach
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Tooltip demo -->
|
<!-- Tooltip demo -->
|
||||||
|
|
@ -90,15 +90,6 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h1 style="color:white;">Hochladen</h1>
|
<h1 style="color:white;">Hochladen</h1>
|
||||||
<form style="background-color: #fff;" class="text-dark" method="post" action="/tour/gallery/{{$tour_id}}" enctype="multipart/form-data">
|
<form style="background-color: #fff;" class="text-dark" method="post" action="/tour/gallery/{{$tour_id}}" enctype="multipart/form-data">
|
||||||
|
|
@ -107,6 +98,9 @@
|
||||||
<input type="submit" value="Hochladen">
|
<input type="submit" value="Hochladen">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
@if(Auth::user()->role=="ADMIN")
|
||||||
|
<a style="color:red; font-size:40px;" href="{{$tour_id}}/show_deleted">Gelöschte Bilder</a>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,85 @@
|
||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container text-center text-light mt-5">
|
||||||
|
|
||||||
|
<h1>{{$tour_name}}</h1>
|
||||||
|
<h1 style="color:red">Gelöschte Bilder</h1>
|
||||||
|
|
||||||
|
<div class="container text-primary" style="display:flex">
|
||||||
|
<!-- <ul class="list-group offset-2 col-8" style="display:inline"> -->
|
||||||
|
<ul class="list-group offset-2 col-8" style="display:flex; flex-direction: row;">
|
||||||
|
@foreach($imagelist as $img_tpl) <!-- 0=filename, 1=displayname -->
|
||||||
|
<label style="display:flex; flex-direction: column;">
|
||||||
|
<a title="{{$img_tpl[1]}}" style="display: inline;" href="/img_storage/tour-{{$tour_id}}-DELETED/{{$img_tpl[0]}}_gross.jpg" data-lightbox="/img_storage/tour-{{$tour_id}}/{{$img_tpl[0]}}_gross.jpg" data-title="{{$img_tpl[1]}}">
|
||||||
|
<img class="mt-3 ml-3" src="/img_storage/tour-{{$tour_id}}-DELETED/{{$img_tpl[0]}}.jpg">
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<a href="/tour/gallery/{{$tour_id}}/restore_image/{{$img_tpl[0]}}.jpg" style="color:red;"><span data-toggle="tooltip" title="Wiederherstellen">Wiederherstellen</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</label>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Tooltip demo -->
|
||||||
|
<!--
|
||||||
|
<a style="color:white" href="#">
|
||||||
|
<span data-toggle="tooltip" title="tooltip for hover">Hover
|
||||||
|
</span> Rest of field
|
||||||
|
</a>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Open the Modal
|
||||||
|
function openModal() {
|
||||||
|
document.getElementById("myModal").style.display = "block";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the Modal
|
||||||
|
function closeModal() {
|
||||||
|
document.getElementById("myModal").style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
var slideIndex = 1;
|
||||||
|
showSlides(slideIndex);
|
||||||
|
|
||||||
|
// Next/previous controls
|
||||||
|
function plusSlides(n) {
|
||||||
|
showSlides(slideIndex += n);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Thumbnail image controls
|
||||||
|
function currentSlide(n) {
|
||||||
|
showSlides(slideIndex = n);
|
||||||
|
}
|
||||||
|
|
||||||
|
function showSlides(n) {
|
||||||
|
var i;
|
||||||
|
var slides = document.getElementsByClassName("mySlides");
|
||||||
|
var dots = document.getElementsByClassName("demo");
|
||||||
|
var captionText = document.getElementById("caption");
|
||||||
|
if (n > slides.length) {slideIndex = 1}
|
||||||
|
if (n < 1) {slideIndex = slides.length}
|
||||||
|
for (i = 0; i < slides.length; i++) {
|
||||||
|
slides[i].style.display = "none";
|
||||||
|
}
|
||||||
|
for (i = 0; i < dots.length; i++) {
|
||||||
|
dots[i].className = dots[i].className.replace(" active", "");
|
||||||
|
}
|
||||||
|
slides[slideIndex-1].style.display = "block";
|
||||||
|
dots[slideIndex-1].className += " active";
|
||||||
|
captionText.innerHTML = dots[slideIndex-1].alt;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<a style="color:green; font-size:40px;" href="/tour/gallery/{{$tour_id}}">Zurück</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@endsection
|
||||||
|
|
@ -68,6 +68,8 @@
|
||||||
Route::get('/tour/gallery/{gallery_id}/delete_image/{imageName}', 'GalleryController@delete_image');
|
Route::get('/tour/gallery/{gallery_id}/delete_image/{imageName}', 'GalleryController@delete_image');
|
||||||
Route::put('/tour/gallery/{gallery_id}/name_image/{imageName}', 'GalleryController@name_image');
|
Route::put('/tour/gallery/{gallery_id}/name_image/{imageName}', 'GalleryController@name_image');
|
||||||
|
|
||||||
|
Route::get('/tour/gallery/{gallery_id}/show_deleted', 'GalleryController@show_deleted_images');
|
||||||
|
Route::get('/tour/gallery/{gallery_id}/restore_image/{imageName}', 'GalleryController@restore_image');
|
||||||
|
|
||||||
Auth::routes();
|
Auth::routes();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue