Commit 1a35f976 authored by Davide Aprea's avatar Davide Aprea
Browse files

change quotes cookie location and behavior

parent 0a65ceae
......@@ -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){
......
......@@ -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');
}
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment