diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index b8ffb6629b230c322b09b57bc67327af4134c6c5..fefa5d519a076c625e57243a6c535032d0e7ad50 100644 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -57,7 +57,7 @@ class SettingsController extends Controller $cookies = Cookie::get(); $settingActive = false; foreach ($cookies as $key => $value) { - if (\starts_with($key, [$fokus . "_engine_", $fokus . "_setting_"]) || strpos($key, $fokus . '_blpage') === 0 || $key === 'dark_mode' || $key === 'new_tab' || $key === 'key') { + if (\starts_with($key, [$fokus . "_engine_", $fokus . "_setting_"]) || strpos($key, $fokus . '_blpage') === 0 || $key === 'dark_mode' || $key === 'new_tab' || $key === 'key' || $key === 'zitate') { $settingActive = true; } } @@ -212,16 +212,12 @@ class SettingsController extends Controller // Currently only the setting for quotes is supported $quotes = $request->input('zitate', ''); - if(!empty($quotes)){ - if($quotes === "off"){ - $path = \Request::path(); - $cookiePath = "/" . substr($path, 0, strpos($path, "meta/") + 5); - Cookie::queue($fokus . "_setting_zitate", "off", 0, $cookiePath, null, false, false); - }elseif($quotes === "on") { - $path = \Request::path(); - $cookiePath = "/" . substr($path, 0, strpos($path, "meta/") + 5); - Cookie::queue($fokus . "_setting_zitate", "", 0, $cookiePath, null, false, false); - } + if(!empty($quotes)) { + if($quotes === "off") { + Cookie::queue('zitate', 'off', 0, '/', null, false, false); + }elseif($quotes === "on") { + Cookie::queue('zitate', '', 0, '/', null, false, false); + } } $darkmode = $request->input('dm'); @@ -271,6 +267,9 @@ class SettingsController extends Controller if($key === 'key'){ Cookie::queue($key, "", 0, '/', null, false, false); } + if($key === 'zitate'){ + Cookie::queue($key, "", 0, '/', null, false, false); + } } $this->clearBlacklist($request); @@ -299,7 +298,9 @@ class SettingsController extends Controller Cookie::queue($key, "", 0, '/', null, false, false); } elseif($key === 'key') { Cookie::queue($key, "", 0, '/', null, false, false); - }else{ + } elseif($key === 'zitate') { + Cookie::queue($key, "", 0, '/', null, false, false); + } else{ Cookie::queue($key, "", 0, $cookiePath, null, false, false); } return redirect($request->input('url', 'https://metager.de')); @@ -315,7 +316,11 @@ class SettingsController extends Controller if($key === 'dark_mode'){ Cookie::queue($key, "", 0, '/', null, false, false); } elseif($key === 'new_tab') { - Cookie::queue($key, "", 0, '/', null, false, false); + Cookie::queue($key, "", 0, '/', null, false, false); + } elseif($key === 'key') { + Cookie::queue($key, "", 0, '/', null, false, false); + } elseif($key === 'zitate') { + Cookie::queue($key, "", 0, '/', null, false, false); } else { Cookie::queue($key, "", 0, $cookiePath, null, false, false); } @@ -423,6 +428,8 @@ class SettingsController extends Controller } elseif($key === 'new_tab' && $value === 'on') { Cookie::queue($key, 'on', 0, '/', null, false, false); + }elseif($key === 'zitate' && $value === 'off'){ + Cookie::queue($key, 'off', 0, '/', null, false, false); } else { foreach($langFile->foki as $fokus => $fokusInfo) { if(strpos($key, $fokus . '_blpage') === 0 && preg_match($regexUrl, $value) === 1){ diff --git a/app/MetaGer.php b/app/MetaGer.php index 44e60475f08747f39e7689c0c158c00ba8a23701..25405c3c1681f4ebff34191f3fab7947a96dfe9c 100644 --- a/app/MetaGer.php +++ b/app/MetaGer.php @@ -1084,12 +1084,12 @@ class MetaGer $this->agent = new Agent(); $this->mobile = $this->agent->isMobile(); # Sprüche - if (!App::isLocale("de") || (\Cookie::has($this->getFokus() . '_setting_zitate') && \Cookie::get($this->getFokus() . '_setting_zitate') === "off")) { - $this->sprueche = "off"; + if (!App::isLocale('de') || (\Cookie::has('zitate') && \Cookie::get('zitate') === 'off')) { + $this->sprueche = 'off'; } else { - $this->sprueche = "on"; + $this->sprueche = 'on'; } - if ($request->filled("zitate") && $request->input('zitate') === "on" || $request->input('zitate') === "off") { + if ($request->filled('zitate') && $request->input('zitate') === 'on' || $request->input('zitate') === 'off') { $this->sprueche = $request->input('quotes'); } diff --git a/resources/views/settings/index.blade.php b/resources/views/settings/index.blade.php index ac79e32bf989e18e11d8a83020747da75f0c413a..3bb98f4e67d8ad4fab3b9626af08c2d3ba9e156e 100644 --- a/resources/views/settings/index.blade.php +++ b/resources/views/settings/index.blade.php @@ -149,8 +149,8 @@ <div class="form-group"> <label for="zitate">Zitate</label> <select name="zitate" id="zitate" class="form-control"> - <option value="on" @if(Cookie::get($fokus . "_setting_zitate") === null)disabled selected @endif>Anzeigen</option> - <option value="off" {{ Cookie::get($fokus . "_setting_zitate") === "off" ? "disabled selected" : "" }}>Nicht Anzeigen</option> + <option value="on" @if(Cookie::get("zitate") === null)disabled selected @endif>Anzeigen</option> + <option value="off" {{ Cookie::get("zitate") === "off" ? "disabled selected" : "" }}>Nicht Anzeigen</option> </select> </div> @endif