Commit 05cd7e1a authored by Davide Aprea's avatar Davide Aprea

added links with integrated settings cookies

parent 46f06115
......@@ -61,7 +61,7 @@ class SettingsController extends Controller
}
}
$cookies = Cookie::get();
# Reading cookies for black list entries
$blacklist = [];
foreach($cookies as $key => $value){
if(stripos($key, 'blpage') !== false && stripos($key, $fokus) !== false){
......@@ -69,6 +69,9 @@ class SettingsController extends Controller
}
}
# Generating link with set cookies
$cookieLink = LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('loadSettings', $cookies));
return view('settings.index')
->with('title', trans('titles.settings', ['fokus' => $fokusName]))
->with('fokus', $request->input('fokus', ''))
......@@ -78,7 +81,8 @@ class SettingsController extends Controller
->with('filter', $filters)
->with('settingActive', $settingActive)
->with('url', $url)
->with('blacklist', $blacklist);
->with('blacklist', $blacklist)
->with('cookieLink', $cookieLink);
}
private function getSumas($fokus)
......@@ -353,4 +357,17 @@ class SettingsController extends Controller
return redirect(LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('settings', ["fokus" => $fokus, "url" => $url])));
}
public function loadSettings(Request $request){
$path = \Request::path();
$cookiePath = "/" . substr($path, 0, strpos($path, "meta/") + 5);
$cookies = $request->all();
foreach($cookies as $key => $value){
Cookie::queue($key, $value, 0, $cookiePath, null, false, false);
}
return redirect(LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), url('/')));
}
}
......@@ -23,6 +23,7 @@ return [
'back' => 'Zurück zur letzten Seite',
'add' => 'Hinzufügen',
'clear' => 'Blacklist leeren',
'copy' => 'Kopieren',
// Translations from the settings overview
'noSettings' => 'Aktuell sind keine Einstellungen gesetzt!',
......@@ -35,5 +36,6 @@ return [
'engineDisabled' => 'Die Suchmaschine :engine wird im Fokus :focus nicht abgefragt.',
'inFocus' => 'im Fokus',
'key' => 'Ihr Schlüssel für die werbefreie Suche',
'blentry' => 'Blacklisteintrag',
'removeCookie' => 'Diesen Cookie entfernen',
];
......@@ -23,6 +23,7 @@ return [
"back" => "Back to the last page",
'add' => 'Add',
'clear' => 'Clear black list',
'copy' => 'Copy',
// Translations from the settings overview
'noSettings' => "Currently no settings are set!",
......@@ -35,5 +36,6 @@ return [
'engineDisabled' => "The search engine :engine will not be queried in focus :focus.",
'inFocus' => "in focus",
'key' => "Your key to the ad-free search",
'blentry' => 'Black list entry',
'removeCookie' => "Remove this cookie",
];
......@@ -32,6 +32,8 @@
@endforeach
@elseif($key === "key")
@lang('settings.key')
@elseif(strpos($key, "_blpage"))
@lang('settings.blentry')
@endif
</td>
<td>
......
......@@ -11,6 +11,8 @@
<div class="card-light">
<h2>@lang('settings.hint.header')</h2>
<p>@lang('settings.hint.text', ["link" => LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('showAllSettings', ['url' => url()->full()])) ])</p>
<input id="cookieLink" type="text" value="{{$cookieLink}}" style="width:100%;">
<button class="btn btn-default" onclick="var copyText = document.getElementById('cookieLink');copyText.select();copyText.setSelectionRange(0, 99999);document.execCommand('copy');">@lang('settings.copy')</button>
</div>
<div class="card-light">
<h2>@lang('settings.header.2')</h2>
......
......@@ -28,7 +28,7 @@ Route::group(
Route::get('all-settings', 'SettingsController@allSettingsIndex')->name('showAllSettings');
Route::post('all-settings/removeOne', 'SettingsController@removeOneSetting')->name('removeOneSetting');
Route::post('all-settings/removeAll', 'SettingsController@removeAllSettings')->name('removeAllSettings');
Route::get('load-settings', 'SettingsController@loadSettings')->name('loadSettings');
});
}
);
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