Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
cd79a1e8
Commit
cd79a1e8
authored
Nov 30, 2016
by
Dominik Hebeler
Browse files
Wetter wird nur noch angezeigt, wenn der Ortsname exakt als Ergebnis vorkommt.
parent
188b1db7
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/MetaGerSearch.php
View file @
cd79a1e8
...
...
@@ -96,28 +96,38 @@ class MetaGerSearch extends Controller
}
$result
=
json_decode
(
$this
->
get
(
$url
),
true
);
$weather
=
[];
$weather
[
"title"
]
=
"Wetter in "
.
$result
[
"name"
];
$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"
;
$searchWords
=
explode
(
' '
,
$q
);
$within
=
false
;
foreach
(
$q
as
$word
){
if
(
stripos
(
$word
,
$result
[
"name"
])
!==
false
){
$within
=
true
;
}
}
if
(
$within
){
$weather
=
[];
$weather
[
"title"
]
=
"Wetter in "
.
$result
[
"name"
];
$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
)
{
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment