[curweather] Only shown notice about unavailable weather once per session.

This commit is contained in:
Andreas Neustifter 2018-07-20 17:32:13 +02:00
parent 3050aef871
commit f539d055ea
2 changed files with 103 additions and 102 deletions

View file

@ -34,7 +34,10 @@ function getWeather( $loc, $units='metric', $lang='en', $appid='', $cachetime=0)
try {
$res = new SimpleXMLElement(Network::fetchUrl($url));
} catch (Exception $e) {
if (!$_SESSION['curweather_notice_shown']) {
info(L10n::t('Error fetching weather data.\nError was: '.$e->getMessage()));
$_SESSION['curweather_notice_shown'] = true;
}
return false;
}
if ((string)$res->temperature['unit']==='metric') {
@ -98,7 +101,6 @@ function curweather_network_mod_init(&$fk_app,&$b) {
// linked from lat/log of the reply of OWMp
$rpt = PConfig::get(local_user(), 'curweather', 'curweather_loc');
// set the language to the browsers language and use metric units
$lang = $_SESSION['language'];
$units = PConfig::get( local_user(), 'curweather', 'curweather_units');
@ -139,10 +141,8 @@ function curweather_network_mod_init(&$fk_app,&$b) {
}
$fk_app->page['aside'] = $curweather.$fk_app->page['aside'];
}
function curweather_addon_settings_post($a,$post) {
if(! local_user() || (! x($_POST,'curweather-settings-submit')))
return;
@ -153,7 +153,6 @@ function curweather_addon_settings_post($a,$post) {
info(L10n::t('Current Weather settings updated.') . EOL);
}
function curweather_addon_settings(&$a,&$s) {
if(! local_user())
@ -186,6 +185,7 @@ function curweather_addon_settings(&$a,&$s) {
return;
}
// Config stuff for the admin panel to let the admin of the node set a APPID
// for accessing the API of openweathermap
function curweather_addon_admin_post (&$a) {
@ -197,6 +197,7 @@ function curweather_addon_admin_post (&$a) {
info(L10n::t('Curweather settings saved.'.EOL));
}
}
function curweather_addon_admin (&$a, &$o) {
if(! is_site_admin())
return;

View file

@ -1 +1 @@
<div>{{$problem}} <a href="http://openweathermap.org/find?q={{$rpt}}">{{$atOWM}}</a>.</div>
<div class="widget small">{{$problem}} <a href="http://openweathermap.org/find?q={{$rpt}}">{{$atOWM}}</a>.</div>