Commit d8657b10 authored by Dominik Hebeler's avatar Dominik Hebeler

implemented setting to disable quotes

parent 298d692a
......@@ -192,6 +192,30 @@ class SettingsController extends Controller
}
public function enableSetting(Request $request) {
$fokus = $request->input('fokus', '');
$url = $request->input('url', '');
// Currently only the setting for quotes is supported
$quotes = $request->input('sprueche', '');
if (empty($fokus) || empty($quotes)) {
abort(404);
}
if($quotes === "off"){
$path = \Request::path();
$cookiePath = "/" . substr($path, 0, strpos($path, "meta/") + 5);
Cookie::queue($fokus . "_setting_sprueche", "off", 0, $cookiePath, null, false, false);
}elseif($quotes === "on") {
$path = \Request::path();
$cookiePath = "/" . substr($path, 0, strpos($path, "meta/") + 5);
Cookie::queue($fokus . "_setting_sprueche", "", 0, $cookiePath, null, false, false);
}else{
dd($quotes);
}
return redirect(LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('settings', ["fokus" => $fokus, "url" => $url])));
}
public function deleteSettings(Request $request)
{
$fokus = $request->input('fokus', '');
......
......@@ -951,15 +951,15 @@ class MetaGer
$this->agent = new Agent();
$this->mobile = $this->agent->isMobile();
# Sprüche
if (!App::isLocale("de") || (\Cookie::has('quotes') && \Cookie::get('quotes') === "off")) {
if (!App::isLocale("de") || (\Cookie::has($this->getFokus() . '_setting_sprueche') && \Cookie::get($this->getFokus() . '_setting_sprueche') === "off")) {
$this->sprueche = "off";
}else{
$this->sprueche = "on";
}
if($request->filled("quotes") && $request->input('quotes') === "on" || $request->input('quotes') === "off"){
if($request->filled("sprueche") && $request->input('sprueche') === "on" || $request->input('sprueche') === "off"){
$this->sprueche = $request->input('quotes');
}
$this->newtab = $request->input('newtab', 'on');
if ($this->newtab === "on") {
$this->newtab = "_blank";
......
$(document).ready(function () {
$("#filter-form").find("button[type=submit]").css("display", "none");
$("#filter-form").find("select").on("change", function () {
$("#filter-form").submit();
$("#filter-form, #setting-form").find("button[type=submit]").css("display", "none");
$("#filter-form, #setting-form").find("select").on("change", function () {
$(this).closest('form').submit();
});
console.log("Test");
});
\ No newline at end of file
......@@ -84,6 +84,23 @@
</form>
</div>
@if(LaravelLocalization::getCurrentLocale() === "de")
<div class="card-light">
<h2>Weitere Einstellungen</h2>
<form id="setting-form" action="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('enableSetting')) }}" method="post" class="form">
<input type="hidden" name="fokus" value="{{ $fokus }}">
<input type="hidden" name="url" value="{{ $url }}">
<div class="form-group">
<label for="sprueche">Sprüche</label>
<select name="sprueche" id="sprueche" class="form-control">
<option value="on" @if(Cookie::get($fokus . "_setting_sprueche") === null)disabled selected @endif>Anzeigen</option>
<option value="off" {{ Cookie::get($fokus . "_setting_sprueche") === "off" ? "disabled selected" : "" }}>Nicht Anzeigen</option>
</select>
</div>
<button type="submit" class="btn btn-default">@lang('settings.save')</button>
</form>
</div>
@endif
<div class="card-light" id="actions">
@if($settingActive)
<div id="reset">
......
......@@ -18,6 +18,7 @@ Route::group(
Route::post('de', 'SettingsController@disableSearchEngine')->name('disableEngine');
Route::post('ee', 'SettingsController@enableSearchEngine')->name('enableEngine');
Route::post('ef', 'SettingsController@enableFilter')->name('enableFilter');
Route::post('es', 'SettingsController@enableSetting')->name('enableSetting');
Route::post('ds', 'SettingsController@deleteSettings')->name('deleteSettings');
# Route to show and delete all settings
......
Markdown is supported
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