Skip to content
Snippets Groups Projects
Commit 71db419d authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Wetter wird nur noch angezeigt, wenn der Ortsname exakt als Ergebnis vorkommt.

parent f30e2eb5
No related branches found
No related tags found
1 merge request!1365Resolve "Filter Options for MetaGer"
...@@ -96,28 +96,38 @@ class MetaGerSearch extends Controller ...@@ -96,28 +96,38 @@ class MetaGerSearch extends Controller
} }
$result = json_decode($this->get($url), true); $result = json_decode($this->get($url), true);
$weather = [];
$weather["title"] = "Wetter in " . $result["name"]; $searchWords = explode(' ', $q);
$weather["URL"] = "http://openweathermap.org/city/" . $result["id"]; $within = false;
foreach($q as $word){
$summary = '<b class="detail-short">' . $result["main"]["temp"] . " °C, " . $result["weather"][0]["description"] . "</b>"; if(stripos($word, $result["name"]) !== false){
$details = '<table class="table table-condensed"><tr><td>Temperatur</td><td>' . $result["main"]["temp_min"] . " bis " . $result["main"]["temp_max"] . " °C</td></tr>"; $within = true;
$details .= "<tr><td>Druck</td><td>" . $result["main"]["pressure"] . " hPa</td></tr>"; }
$details .= "<tr><td>Luftfeuchtigkeit</td><td>" . $result["main"]["humidity"] . " %</td></tr>"; }
$details .= "<tr><td>Wind</td><td>" . $result["wind"]["speed"] . " m/s, " . $result["wind"]["deg"] . "°</td></tr>"; if($within){
$details .= "<tr><td>Bewölkung</td><td>" . $result["clouds"]["all"] . " %</td></tr>"; $weather = [];
if (isset($result->rain)) { $weather["title"] = "Wetter in " . $result["name"];
$details .= " | Regen letzte drei Stunden: " . $result["rain"]["3h"] . " h"; $weather["URL"] = "http://openweathermap.org/city/" . $result["id"];
$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 .= "<tr><td>Druck</td><td>" . $result["main"]["pressure"] . " hPa</td></tr>";
$details .= "<tr><td>Luftfeuchtigkeit</td><td>" . $result["main"]["humidity"] . " %</td></tr>";
$details .= "<tr><td>Wind</td><td>" . $result["wind"]["speed"] . " m/s, " . $result["wind"]["deg"] . "°</td></tr>";
$details .= "<tr><td>Bewölkung</td><td>" . $result["clouds"]["all"] . " %</td></tr>";
if (isset($result->rain)) {
$details .= " | Regen letzte drei Stunden: " . $result["rain"]["3h"] . " h";
}
$details .= "</table>";
$weather["summary"] = $summary;
$weather["details"] = $details;
$weather["gefVon"] = "von <a href = \"https://openweathermap.org\" target=\"_blank\" rel=\"noopener\">Openweathermap</a>";
$requestData = [];
$requestData["url"] = "http://openweathermap.org/img/w/";
$weather["image"] = action('Pictureproxy@get', $requestData) . $result["weather"][0]["icon"] . ".png";
$weather["image-alt"] = $result["weather"][0]["main"];
$mquicktips[] = $weather;
} }
$details .= "</table>";
$weather["summary"] = $summary;
$weather["details"] = $details;
$weather["gefVon"] = "von <a href = \"https://openweathermap.org\" target=\"_blank\" rel=\"noopener\">Openweathermap</a>";
$requestData = [];
$requestData["url"] = "http://openweathermap.org/img/w/";
$weather["image"] = action('Pictureproxy@get', $requestData) . $result["weather"][0]["icon"] . ".png";
$weather["image-alt"] = $result["weather"][0]["main"];
$mquicktips[] = $weather;
} catch (\ErrorException $e) { } catch (\ErrorException $e) {
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment