From 210f553b49052ab305f0edeae2ac4775125d79f9 Mon Sep 17 00:00:00 2001 From: Kekskurse Date: Wed, 27 Jan 2021 01:38:17 +0100 Subject: [PATCH] Stuff --- app/Http/Controllers/PublicController.php | 11 ++++-- app/Http/Controllers/TenantController.php | 43 ++++++++++++++++++++++- resources/views/tenant/theme.blade.php | 23 ++++++++++-- routes/web.php | 2 ++ 4 files changed, 73 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/PublicController.php b/app/Http/Controllers/PublicController.php index f26e72f..abf6138 100644 --- a/app/Http/Controllers/PublicController.php +++ b/app/Http/Controllers/PublicController.php @@ -37,14 +37,14 @@ class PublicController extends BaseController $gallery->html = $parser->parse($gallery->description); } - $theme = "kuvia-blog"; + $theme = $tenant->template; if($request->input("theme", false) && $tenant->owner == Auth::id()) { $theme = $request->input("theme"); } return view("themes.tenant.".$theme.".list", ["galleries" => $galleries, "tenant" => $tenant]); } - public function listGalleryImagesView($tenant, $gallery) { + public function listGalleryImagesView($tenant, $gallery, Request $request) { $tenant = Tenant::query()->where("url", "=", $tenant)->firstOrFail(); $gallery = Gallery::getByTenantAndUrl($tenant->id, $gallery); if($gallery->status == "online" || (Auth::check() && $gallery->status == "preview" && Auth::user()->id == $tenant->owner)) { @@ -61,7 +61,12 @@ class PublicController extends BaseController $parser = new \Parsedown(); $gallery->html = $parser->parse($gallery->description); - return view("themes.gallery.kuvia-gallery.list", ["gallery" => $gallery, "tenant" => $tenant, "images" => $images]); + $theme = $tenant->gallery_default_theme; + if($request->input("theme", false) && $tenant->owner == Auth::id()) { + $theme = $request->input("theme"); + } + + return view("themes.gallery.".$theme.".list", ["gallery" => $gallery, "tenant" => $tenant, "images" => $images]); } public function returnWatermakeFile(\App\Helper\Image $imageHelper, \App\Helper\Access $accessHelper) { diff --git a/app/Http/Controllers/TenantController.php b/app/Http/Controllers/TenantController.php index bd71edd..f5c3c58 100644 --- a/app/Http/Controllers/TenantController.php +++ b/app/Http/Controllers/TenantController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Models\Gallery; use App\Models\Image; use App\Models\Tenant; use App\Models\Theme; @@ -121,6 +122,46 @@ class TenantController extends BaseController ->where("status", "=", "public") ->where("typ", "=", "tenant") ->get(); - return view("tenant.theme", ["themes" => $themes]); + + $gallery_themes = Theme::query() + ->where("status", "=", "public") + ->where("typ", "=", "gallery") + ->get(); + + $gallery = Gallery::query() + ->where("tenant", "=", session("current_tenant_id")) + ->orderByDesc("id") + ->first(); + return view("tenant.theme", ["themes" => $themes, "gallery_themes" => $gallery_themes, "gallery" => $gallery]); + } + + public function tenantThemeSet(Request $request) { + $tenant = Tenant::query()->where("id", "=", session("current_tenant_id"))->firstOrFail(); + $theme = Theme::query() + ->where("name", "=", $request->input("name")) + ->where("typ", "=", "tenant") + ->firstOrFail(); + if($theme->status != "public") { + abort(400); + } + + $tenant->template = $theme->name; + $tenant->saveOrFail(); + return Redirect::back(); + } + + public function tenantGalleryDefaultTemplateSet(Request $request) { + $tenant = Tenant::query()->where("id", "=", session("current_tenant_id"))->firstOrFail(); + $theme = Theme::query() + ->where("name", "=", $request->input("name")) + ->where("typ", "=", "gallery") + ->firstOrFail(); + if($theme->status != "public") { + abort(400); + } + + $tenant->gallery_default_theme = $theme->name; + $tenant->saveOrFail(); + return Redirect::back(); } } diff --git a/resources/views/tenant/theme.blade.php b/resources/views/tenant/theme.blade.php index 132c099..e46dcf6 100644 --- a/resources/views/tenant/theme.blade.php +++ b/resources/views/tenant/theme.blade.php @@ -1,7 +1,7 @@ @extends('layout/template') @section('content') -

Themes

+

Themes Tenant

@@ -12,7 +12,26 @@ - + + + @endforeach +
Name
{{ $theme->name }} VorschauAuswählenAuswählen
+

Themes Gallery

+ + + + + + + @foreach($gallery_themes as $theme) + + + + @endforeach
NameVorschauAction
{{ $theme->name }} + @if(!is_null($gallery)) + Vorschau + @endif + Auswählen
diff --git a/routes/web.php b/routes/web.php index 1053f4c..9b6771e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -34,6 +34,8 @@ Route::middleware([\App\Http\Middleware\TenanMiddleware::class])->group(function Route::post("/t/new", [\App\Http\Controllers\TenantController::class, 'newTenant']); Route::get("/t/select/{name}", [\App\Http\Controllers\TenantController::class, 'switchTenant']); Route::get("/s/theme", [\App\Http\Controllers\TenantController::class, 'tenantThemeView']); + Route::get("/s/theme/set", [\App\Http\Controllers\TenantController::class, 'tenantThemeSet']); + Route::get("/s/theme/set-gallery", [\App\Http\Controllers\TenantController::class, 'tenantGalleryDefaultTemplateSet']); Route::get("/g", [\App\Http\Controllers\GalleryController::class, 'listView']); Route::get("/g/new", [\App\Http\Controllers\GalleryController::class, 'newView']);