Commit 5023c703 authored by Dominik Hebeler's avatar Dominik Hebeler

Merge branch '391-meldung-fur-den-sprachfilter-in-die-quicktips-verschieben' into 'development'

Quicktip für die Sprachauswahl hinzugefügt

Closes #391

See merge request !617
parents 5633368a f66cd182
...@@ -45,7 +45,7 @@ class MetaGerSearch extends Controller ...@@ -45,7 +45,7 @@ class MetaGerSearch extends Controller
->with('r', $redirect); ->with('r', $redirect);
} }
public function quicktips(Request $request) public function quicktips(Request $request, MetaGer $metager)
{ {
$q = $request->input('q', ''); $q = $request->input('q', '');
...@@ -95,20 +95,20 @@ class MetaGerSearch extends Controller ...@@ -95,20 +95,20 @@ class MetaGerSearch extends Controller
$url = "http://api.openweathermap.org/data/2.5/weather?type=accurate&units=metric&lang=de&q=" . urlencode($q) . "&APPID=" . getenv("openweathermap"); $url = "http://api.openweathermap.org/data/2.5/weather?type=accurate&units=metric&lang=de&q=" . urlencode($q) . "&APPID=" . getenv("openweathermap");
} }
$result = json_decode($this->get($url), true); $result = json_decode($this->get($url), true);
$searchWords = explode(' ', $q); $searchWords = explode(' ', $q);
$within = false; $within = false;
foreach($searchWords as $word){ foreach ($searchWords as $word) {
if(stripos($result["name"], $word) !== false){ if (stripos($result["name"], $word) !== false) {
$within = true; $within = true;
} }
} }
if($within){ if ($within) {
$weather = []; $weather = [];
$weather["title"] = "Wetter in " . $result["name"]; $weather["title"] = "Wetter in " . $result["name"];
$weather["URL"] = "http://openweathermap.org/city/" . $result["id"]; $weather["URL"] = "http://openweathermap.org/city/" . $result["id"];
$summary = '<b class="detail-short">' . $result["main"]["temp"] . " °C, " . $result["weather"][0]["description"] . "</b>"; $summary = '<b class="detail-short">' . $result["main"]["temp"] . " °C, " . $result["weather"][0]["description"] . "</b>";
$details = '<table class="table table-condensed"><tr><td>Temperatur</td><td>' . $result["main"]["temp_min"] . " bis " . $result["main"]["temp_max"] . " °C</td></tr>"; $details = '<table class="table table-condensed"><tr><td>Temperatur</td><td>' . $result["main"]["temp_min"] . " bis " . $result["main"]["temp_max"] . " °C</td></tr>";
$details .= "<tr><td>Druck</td><td>" . $result["main"]["pressure"] . " hPa</td></tr>"; $details .= "<tr><td>Druck</td><td>" . $result["main"]["pressure"] . " hPa</td></tr>";
......
...@@ -877,12 +877,6 @@ class MetaGer ...@@ -877,12 +877,6 @@ class MetaGer
if ($this->lang !== "de" && $this->lang !== "en" && $this->lang !== "all") { if ($this->lang !== "de" && $this->lang !== "en" && $this->lang !== "all") {
$this->lang = "all"; $this->lang = "all";
} }
if ($this->lang !== 'all') {
# Warnung hinzufügen, dass die Ergebnisse gefiltert sind.
$this->warnings[] = trans('results.filter', ['langName' => LaravelLocalization::getSupportedLocales()[LaravelLocalization::getCurrentLocale()]['native'], 'link' => $this->getUnFilteredLink(), 'filter' => $this->lang]);
} else {
$this->warnings[] = trans('results.filter.default', ['langName' => LaravelLocalization::getSupportedLocales()[LaravelLocalization::getCurrentLocale()]['native']]);
}
$this->agent = new Agent(); $this->agent = new Agent();
$this->mobile = $this->agent->isMobile(); $this->mobile = $this->agent->isMobile();
...@@ -1236,8 +1230,9 @@ class MetaGer ...@@ -1236,8 +1230,9 @@ class MetaGer
public function getUnFilteredLink() public function getUnFilteredLink()
{ {
$requestData = $this->request->except(['lang']); $requestData = $this->request->except(['lang']);
$link = action('MetaGerSearch@search', $requestData); $requestData['lang'] = "all";
$link = action('MetaGerSearch@search', $requestData);
return $link; return $link;
} }
......
...@@ -4,6 +4,6 @@ return [ ...@@ -4,6 +4,6 @@ return [
'redirect' => '(mit redirect)', 'redirect' => '(mit redirect)',
'weiter' => 'Weitersuchen', 'weiter' => 'Weitersuchen',
'zurueck' => 'Zurück', 'zurueck' => 'Zurück',
'filter' => 'Die Suchergebnisse wurden gefiltert: <strong>[:filter]</strong>. <a href=":link">Filter abschalten.</a>', 'filter' => 'Die Suchergebnisse wurden gefiltert: <strong>[:filter]</strong>. <a href=":link" target="_blank">Filter abschalten.</a>',
'filter.default' => 'Sie erhalten die Benutzeroberfläche in <strong>:langName</strong>, aber Ergebnisse in <strong>ALLEN</strong> Sprachen. Für ausschließlich deutschsprachige Ergebnisse können Sie unter <a href="/settings" target="_blank">anpassen</a> die "Sprache auswählen".', 'filter.default' => 'Sie erhalten die Benutzeroberfläche in <strong>:langName</strong>, aber Ergebnisse in <strong>ALLEN</strong> Sprachen. Für ausschließlich deutschsprachige Ergebnisse können Sie unter <a href="/settings" target="_blank">anpassen</a> die "Sprache auswählen".',
]; ];
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
@if( $metager->showQuicktips() ) @if( $metager->showQuicktips() )
<div class="hidden-xs col-md-4" id="quicktips"> <div class="hidden-xs col-md-4" id="quicktips">
<iframe class="col-mod-4 hidden-xs hidden-sm" src="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), "/qt") }}?q={{ $metager->getQ() }}&sprueche={{ $metager->getSprueche() }}"></iframe> <iframe class="col-mod-4 hidden-xs hidden-sm" src="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), "/qt") }}?q={{ $metager->getQ() }}&sprueche={{ $metager->getSprueche() }}&lang={{ Request::input('lang', 'all') }}&unfilteredLink={{ base64_encode($metager->getUnfilteredLink()) }}"></iframe>
</div> </div>
@endif @endif
@endsection @endsection
...@@ -50,6 +50,23 @@ ...@@ -50,6 +50,23 @@
@endif @endif
</div> </div>
@endforeach @endforeach
<div class="quicktip">
<details>
<summary>
<div class="media">
<div class="media-body">
<div>
@if( Request::input('lang') === "all")
{!! trans('results.filter.default', ['langName' => LaravelLocalization::getSupportedLocales()[LaravelLocalization::getCurrentLocale()]['native']]) !!}
@else
{!! trans('results.filter', ['langName' => LaravelLocalization::getSupportedLocales()[LaravelLocalization::getCurrentLocale()]['native'], 'link' => base64_decode(Request::input('unfilteredLink','')), 'filter' => Request::input('lang')]) !!}
@endif
</div>
</div>
</div>
</summary>
</details>
</div>
<script src="/js/quicktips.js"> <script src="/js/quicktips.js">
</script> </script>
</body> </body>
......
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