Commit eacd9fcc authored by Dominik Hebeler's avatar Dominik Hebeler

Merge branch '873-sucheinstellungen-optimieren' into 'development'

Resolve "Sucheinstellungen optimieren"

Closes #873

See merge request !1418
parents 92d71712 9b768f29
Pipeline #2786 passed with stage
in 1 minute and 16 seconds
......@@ -81,6 +81,10 @@ class SettingsController extends Controller
$sumas = [];
foreach ($sumasFoki as $suma) {
if ((!empty($langFile->sumas->{$suma}->disabled) && $langFile->sumas->{$suma}->disabled) ||
(!empty($langFile->sumas->{$suma}->{"auto-disabled"}) && $langFile->sumas->{$suma}->{"auto-disabled"})) {
continue;
}
$sumas[$suma]["display-name"] = $langFile->sumas->{$suma}->{"display-name"};
$sumas[$suma]["filtered"] = false;
if (Cookie::get($fokus . "_engine_" . $suma) === "off") {
......@@ -207,4 +211,37 @@ class SettingsController extends Controller
return redirect(LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('settings', ["fokus" => $fokus, "url" => $url])));
}
public function allSettingsIndex(Request $request)
{
$sumaFile = MetaGer::getLanguageFile();
$sumaFile = json_decode(file_get_contents($sumaFile));
return view('settings.allSettings')
->with('title', trans('titles.allSettings'))
->with('url', $request->input('url', ''))
->with('sumaFile', $sumaFile);
}
public function removeOneSetting(Request $request)
{
$key = $request->input('key', '');
$path = \Request::path();
$cookiePath = "/" . substr($path, 0, strpos($path, "meta/") + 5);
Cookie::queue($key, "", 0, $cookiePath, null, false, false);
return redirect($request->input('url', 'https://metager.de'));
}
public function removeAllSettings(Request $request)
{
$path = \Request::path();
$cookiePath = "/" . substr($path, 0, strpos($path, "meta/") + 5);
foreach (Cookie::get() as $key => $value) {
Cookie::queue($key, "", 0, $cookiePath, null, false, false);
}
return redirect($request->input('url', 'https://metager.de'));
}
}
......@@ -88,52 +88,15 @@ class StartpageController extends Controller
return loadPage($subpage);
}
public function loadPlugin($params, $locale = "de")
public function loadPlugin($locale = "de")
{
$params = unserialize(base64_decode($params));
$requests = $params;
$params = [];
foreach ($requests as $key => $value) {
if (strpos($key, "param_") === 0) {
$key = substr($key, strpos($key, "param_") + 6);
}
$params[$key] = $value;
}
if (!isset($params['focus'])) {
$params['focus'] = 'web';
}
if (!isset($params['encoding'])) {
$params['encoding'] = 'utf8';
}
if (!isset($params['lang'])) {
$params['lang'] = 'all';
}
if (isset($params['request']) && ($params['request'] === "GET" || $params['request'] === "POST")) {
$request = $params['request'];
} else {
$request = "GET";
}
array_forget($params, 'eingabe');
array_forget($params, 'out');
array_forget($params, 'page');
array_forget($params, 'request');
array_forget($params, 'focus');
array_forget($params, 'encoding');
array_forget($params, 'lang');
$link = action('MetaGerSearch@search', []);
$response = Response::make(
view('plugin')
->with('link', $link)
->with('params', $params)
->with('hostname', gethostname())
->with('request', $request), "200");
, "200");
$response->header('Content-Type', "application/opensearchdescription+xml");
return $response;
}
......
......@@ -524,6 +524,7 @@ class MetaGer
}
}
# Implements Yahoo Ads if Yahoo is not enabled as a searchengine
if (!$this->apiAuthorized && empty($this->enabledSearchengines["yahoo"]) && $this->fokus != "bilder" && !empty($this->sumaFile->sumas->{"yahoo-ads"})) {
$this->enabledSearchengines["yahoo-ads"] = $this->sumaFile->sumas->{"yahoo-ads"};
......
......@@ -2,7 +2,10 @@
return [
"header.1" => "Sucheinstellungen",
"text.1" => "Hier können Sie Sucheinstellungen für Ihre MetaGer Suche im Fokus :fokusName vornehmen. Diese bleiben solange gespeichert, wie Sie Cookies im Browser speichern.",
"text.1" => "Hier können Sie dauerhafte Sucheinstellungen für Ihre MetaGer-Suche im Fokus :fokusName vornehmen. Sollten diese nicht dauerhaft gespeichert bleiben, überprüfen Sie bitte in Ihren Browsereinstellungen, ob dieser beim Beenden gespeicherte Cookies löscht.",
"hint.header" => "Hinweis",
"hint.text" => "Um Ihre Sucheinstellungen zu speichern, verwenden wir nicht-personenbeziehbare Cookies. Diese werden im Klartext in Ihrem Browser gespeichert. Sie können sich eine Übersicht aller von Ihnen vorgenommenen Einstellungen und Cookies <a href=\":link\">anzeigen lassen</a>.",
"header.2" => "Verwendete Suchmaschinen",
"text.2" => "Nachfolgend sehen Sie alle für diesen Fokus verfügbaren Suchmaschinen. Mit einem Klick auf den Namen können Sie Ein-/Ausgeschaltet werden. Eingeschaltete Suchmaschinen sind in grün dargestellt. Ausgeschaltete in rot oder grau.",
......@@ -13,4 +16,17 @@ return [
"save" => "Speichern",
"reset" => "Alle Einstellungen löschen",
"back" => "Zurück zur letzten Seite",
// Translations from the settings overview
'noSettings' => "Aktuell sind keine Einstellungen gesetzt!",
'allSettings.header' => "Auf :root gesetzte Einstellungen",
'allSettings.text' => "Hier finden Sie eine Übersicht aller von Ihnen gesetzten Einstellungen und Cookies. Sie können einzelne Einträge löschen, oder alle entfernen. Bedenken Sie, dass die zugehörigen Einstellungen dann nicht mehr verwendet werden.",
'meaning' => "Bedeutung",
'actions' => "Aktionen",
'engineDisabled' => "Die Suchmaschine :engine wird im Fokus :focus nicht abgefragt.",
'inFocus' => "im Fokus",
'key' => "Ihr Schlüssel für die werbefreie Suche",
'removeCookie' => "Diesen Cookie entfernen",
];
......@@ -25,4 +25,5 @@ return [
'plugin' => 'Plugin - MetaGer',
'key' => 'Mitgliederschlüssel - MetaGer',
'settings' => 'Sucheinstellungen (:fokus)',
'allSettings' => 'Alle Sucheinstellungen - MetaGer',
];
......@@ -2,7 +2,10 @@
return [
"header.1" => "Search Preferences",
"text.1" => "Here you can make search settings for your MetaGer search in focus :fokusName. These are stored as long as you save cookies in the browser.",
"text.1" => "Here you can set permanent search settings for your MetaGer search in focus :fokusName. If these do not remain permanently stored, please check in your browser settings whether it deletes cookies stored on exit.",
"hint.header" => "Note",
"hint.text" => "To save your search settings, we use non-personally identifiable cookies. These are saved in clear text in your browser. You can see an overview of all the settings and cookies you have made.",
"header.2" => "Used Search Engines",
"text.2" => "Below are all the search engines available for this focus. With a click on the name they can be switched on / off. Used search engines are shown in green. Not used ones in red or gray.",
......@@ -13,4 +16,17 @@ return [
"save" => "Save",
"reset" => "Delete all settings",
"back" => "Back to the last page",
// Translations from the settings overview
'noSettings' => "Currently no settings are set!",
'allSettings.header' => "Settings on :root",
'allSettings.text' => "Here you will find an overview of all settings and cookies you have set. You can delete individual entries or remove them all. Keep in mind that the associated settings will no longer be used.",
'meaning' => "Meaning",
'actions' => "Actions",
'engineDisabled' => "The search engine :engine will not be queried in focus :focus.",
'inFocus' => "in focus",
'key' => "Your key to the ad-free search",
'removeCookie' => "Remove this cookie",
];
......@@ -593,7 +593,7 @@ a {
#settings {
text-align: center;
a {
color: black;
color: #333;
&:hover {
color: red;
span.badge {
......
......@@ -37,8 +37,13 @@
display: flex;
align-items: center;
justify-content: center;
#back {
margin-left: -8px;
> #back, > a, > form {
margin-left: 8px;
}
}
#no-settings {
text-align: center;
}
}
\ No newline at end of file
......@@ -12,7 +12,7 @@
<meta name="mm" content="{{ $metager->getVerificationId() }}" />
<meta name="mn" content="{{ $metager->getVerificationCount() }}" />
<meta name="searchkey" content="{{ $metager->getSearchUid() }}" />
<link rel="search" type="application/opensearchdescription+xml" title="{!! trans('resultPage.opensearch') !!}" href="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), action('StartpageController@loadPlugin', ['params' => base64_encode(serialize(Request::all()))])) }}">
<link rel="search" type="application/opensearchdescription+xml" title="{!! trans('resultPage.opensearch') !!}" href="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), action('StartpageController@loadPlugin')) }}">
<link href="/fonts/liberationsans/stylesheet.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="{{ mix('css/fontawesome.css') }}" />
<link type="text/css" rel="stylesheet" href="{{ mix('css/fontawesome-solid.css') }}" />
......
......@@ -12,7 +12,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<link href="/favicon.ico" rel="icon" type="image/x-icon" />
<link href="/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<link rel="search" type="application/opensearchdescription+xml" title="{{ trans('staticPages.opensearch') }}" href="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), action('StartpageController@loadPlugin', ['params' => base64_encode(serialize(Request::all()))])) }}">
<link rel="search" type="application/opensearchdescription+xml" title="{{ trans('staticPages.opensearch') }}" href="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), action('StartpageController@loadPlugin')) }}">
<link type="text/css" rel="stylesheet" href="{{ mix('css/bootstrap.css') }}" />
<link type="text/css" rel="stylesheet" href="{{ mix('css/themes/metager.css') }}" />
<link type="text/css" rel="stylesheet" href="{{ mix('css/utility.css') }}" />
......
@if(sizeof($metager->getAvailableParameterFilter()) > 0)
<div id="options">
<div id="toggle-box">
<div id="filter-toggle">
......@@ -28,6 +27,7 @@
</div>
@endif
</div>
@if(sizeof($metager->getAvailableParameterFilter()) > 0)
<input type="checkbox" id="options-toggle" @if(sizeof($metager->getParameterFilter()) > 0)checked @endif />
<div class="scrollbox">
<div id="options-box">
......@@ -51,6 +51,5 @@
</div>
<div class="scrollfade-right"></div>
</div>
</div>
@endif
</div>
......@@ -4,17 +4,6 @@
<Description>{{ trans('plugin.description') }}</Description>
<Contact>office@suma-ev.de</Contact>
<Image width="16" height="16" type="image/x-icon">{{ url('/favicon.ico') }}</Image>
@if ($request == "POST")
<Url type="text/html" template="{{ $link }}" method="{{$request}}">
<Param name="eingabe" value="{searchTerms}" />
@foreach($params as $key => $value)
<Param name="{{$key}}" value="{{$value}}" />
@endforeach
</Url>
@else
<Url type="text/html" template="{{ $link }}?eingabe={searchTerms}@foreach($params as $key => $value)&amp;{{$key}}={{$value}}@endforeach" method="{{$request}}" />
@endif
<Url type="text/html" template="{{ $link }}?eingabe={searchTerms}" method="GET" />
<InputEncoding>UTF-8</InputEncoding>
</OpenSearchDescription>
@extends('layouts.subPages')
@section('title', $title )
@section('content')
<div id="settings">
<div class="card-light">
<h2>@lang('settings.allSettings.header', ["root" => Request::root()])</h2>
<p>@lang('settings.allSettings.text')</p>
@if(sizeof(Cookie::get()) > 0)
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Cookie</th>
<th>@lang('settings.meaning')</th>
<th>@lang('settings.actions')</th>
</tr>
</thead>
<tbody>
@foreach(Cookie::get() as $key => $value)
<tr>
<td>{{ $key . "=" . $value }}</td>
<td>
@if(strpos($key, "_engine_") !== FALSE)
@lang('settings.engineDisabled', ["engine" => $sumaFile->sumas->{substr($key, strrpos($key, "_")+1)}->{"display-name"}, "focus" => trans('index.foki.' . substr($key, 0, strpos($key, "_")))])
@elseif(strpos($key, "_setting_") !== FALSE)
@foreach($sumaFile->filter->{"parameter-filter"} as $filterName => $filter)
@if($filter->{"get-parameter"} === substr($key, strrpos($key, "_")+1))
@lang($filter->name)=@lang($filter->values->$value) @lang('settings.inFocus') @lang('index.foki.' . substr($key, 0, strpos($key, "_")))
@endif
@endforeach
@elseif($key === "key")
@lang('settings.key')
@endif
</td>
<td>
<form action="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('removeOneSetting')) }}" method="post">
<input type="hidden" name="key" value="{{ $key }}">
<input type="hidden" name="url" value="{{ url()->full() }}">
<button type="submit" title="@lang('settings.removeCookie')">
<i class="fas fa-trash-alt"></i>
</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
@else
<p id="no-settings">@lang('settings.noSettings')</p>
@endif
<div id="actions">
<a href="{{ $url }}" class="btn btn-sm btn-default">@lang('settings.back')</a>
@if(sizeof(Cookie::get()) > 0)
<form action="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('removeAllSettings'))}}" method="post">
<input type="hidden" name="url" value="{{ url()->full() }}">
<button type="submit" class="btn btn-sm btn-danger">@lang('settings.reset')</button>
</form>
@endif
</div>
</div>
</div>
</div>
@endsection
......@@ -8,6 +8,10 @@
<h2>@lang('settings.header.1') ({{ $fokusName }})</h2>
<p>@lang('settings.text.1', ["fokusName" => $fokusName])</p>
</div>
<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>
</div>
<div class="card-light">
<h2>@lang('settings.header.2')</h2>
<p>@lang('settings.text.2')</p>
......
......@@ -19,6 +19,12 @@ Route::group(
Route::post('ee', 'SettingsController@enableSearchEngine')->name('enableEngine');
Route::post('ef', 'SettingsController@enableFilter')->name('enableFilter');
Route::post('ds', 'SettingsController@deleteSettings')->name('deleteSettings');
# Route to show and delete all settings
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');
});
}
);
......@@ -189,7 +189,7 @@ Route::group(
Route::get('qt', 'MetaGerSearch@quicktips');
Route::get('tips', 'MetaGerSearch@tips');
Route::get('/plugins/{params}/opensearch.xml', 'StartpageController@loadPlugin');
Route::get('/plugins/opensearch.xml', 'StartpageController@loadPlugin');
Route::get('owi', function () {
return redirect('https://metager.de/klassik/en/owi/');
});
......
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