From f36b8e24cfef13ad99c14fc60ffb3ae81b743e48 Mon Sep 17 00:00:00 2001 From: Andreas Neustifter Date: Fri, 20 Jul 2018 21:42:48 +0200 Subject: [PATCH] Fix even more whitespace. As requested by @MrPetovan. --- curweather/curweather.php | 102 +++++++++++++++++++++----------------- 1 file changed, 56 insertions(+), 46 deletions(-) diff --git a/curweather/curweather.php b/curweather/curweather.php index e587a2f5..6e03dd40 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -32,7 +32,7 @@ function getWeather( $loc, $units='metric', $lang='en', $appid='', $cachetime=0) } } try { - $res = new SimpleXMLElement(Network::fetchUrl($url)); + $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())); @@ -144,69 +144,79 @@ function curweather_network_mod_init(&$fk_app,&$b) { } function curweather_addon_settings_post($a,$post) { - if(! local_user() || (! x($_POST,'curweather-settings-submit'))) - return; - PConfig::set(local_user(),'curweather','curweather_loc',trim($_POST['curweather_loc'])); - PConfig::set(local_user(),'curweather','curweather_enable',intval($_POST['curweather_enable'])); - PConfig::set(local_user(),'curweather','curweather_units',trim($_POST['curweather_units'])); - - info(L10n::t('Current Weather settings updated.') . EOL); + if(! local_user() || (! x($_POST,'curweather-settings-submit'))) + return; + PConfig::set(local_user(),'curweather','curweather_loc',trim($_POST['curweather_loc'])); + PConfig::set(local_user(),'curweather','curweather_enable',intval($_POST['curweather_enable'])); + PConfig::set(local_user(),'curweather','curweather_units',trim($_POST['curweather_units'])); + + info(L10n::t('Current Weather settings updated.') . EOL); } function curweather_addon_settings(&$a,&$s) { - if(! local_user()) - return; - - /* Get the current state of our config variable */ - - $curweather_loc = PConfig::get(local_user(), 'curweather', 'curweather_loc'); - $curweather_units = PConfig::get(local_user(), 'curweather', 'curweather_units'); - $appid = Config::get('curweather','appid'); - if ($appid=="") { - $noappidtext = L10n::t('No APPID found, please contact your admin to obtain one.'); - } else { - $noappidtext = ''; - } - $enable = intval(PConfig::get(local_user(),'curweather','curweather_enable')); - $enable_checked = (($enable) ? ' checked="checked" ' : ''); - - // load template and replace the macros - $t = get_markup_template("settings.tpl", "addon/curweather/" ); - $s = replace_macros ($t, [ - '$submit' => L10n::t('Save Settings'), - '$header' => L10n::t('Current Weather').' '.L10n::t('Settings'), - '$noappidtext' => $noappidtext, - '$info' => L10n::t('Enter either the name of your location or the zip code.'), - '$curweather_loc' => [ 'curweather_loc', L10n::t('Your Location'), $curweather_loc, L10n::t('Identifier of your location (name or zip code), e.g. Berlin,DE or 14476,DE.') ], - '$curweather_units' => [ 'curweather_units', L10n::t('Units'), $curweather_units, L10n::t('select if the temperature should be displayed in °C or °F'), ['metric'=>'°C', 'imperial'=>'°F']], - '$enabled' => [ 'curweather_enable', L10n::t('Show weather data'), $enable, ''] - ]); + if(! local_user()) return; - + + /* Get the current state of our config variable */ + + $curweather_loc = PConfig::get(local_user(), 'curweather', 'curweather_loc'); + $curweather_units = PConfig::get(local_user(), 'curweather', 'curweather_units'); + $appid = Config::get('curweather','appid'); + if ($appid=="") { + $noappidtext = L10n::t('No APPID found, please contact your admin to obtain one.'); + } else { + $noappidtext = ''; + } + $enable = intval(PConfig::get(local_user(),'curweather','curweather_enable')); + $enable_checked = (($enable) ? ' checked="checked" ' : ''); + + // load template and replace the macros + $t = get_markup_template("settings.tpl", "addon/curweather/" ); + $s = replace_macros ($t, [ + '$submit' => L10n::t('Save Settings'), + '$header' => L10n::t('Current Weather').' '.L10n::t('Settings'), + '$noappidtext' => $noappidtext, + '$info' => L10n::t('Enter either the name of your location or the zip code.'), + '$curweather_loc' => [ 'curweather_loc', L10n::t('Your Location'), $curweather_loc, L10n::t('Identifier of your location (name or zip code), e.g. Berlin,DE or 14476,DE.') ], + '$curweather_units' => [ 'curweather_units', L10n::t('Units'), $curweather_units, L10n::t('select if the temperature should be displayed in °C or °F'), ['metric'=>'°C', 'imperial'=>'°F']], + '$enabled' => [ 'curweather_enable', L10n::t('Show weather data'), $enable, ''] + ]); + 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) { - if(! is_site_admin()) - return; - if ($_POST['curweather-submit']) { - Config::set('curweather','appid',trim($_POST['appid'])); - Config::set('curweather','cachetime',trim($_POST['cachetime'])); - info(L10n::t('Curweather settings saved.'.EOL)); - } + if(! is_site_admin()) + return; + if ($_POST['curweather-submit']) { + Config::set('curweather','appid',trim($_POST['appid'])); + Config::set('curweather','cachetime',trim($_POST['cachetime'])); + info(L10n::t('Curweather settings saved.'.EOL)); + } } function curweather_addon_admin (&$a, &$o) { if(! is_site_admin()) - return; + return; $appid = Config::get('curweather','appid'); $cachetime = Config::get('curweather','cachetime'); $t = get_markup_template("admin.tpl", "addon/curweather/" ); - $o = replace_macros ($t, [ + $o = replace_macros ($t, [ '$submit' => L10n::t('Save Settings'), - '$cachetime' => ['cachetime', L10n::t('Caching Interval'), $cachetime, L10n::t('For how long should the weather data be cached? Choose according your OpenWeatherMap account type.'), ['0'=>L10n::t('no cache'), '300'=>'5 '.L10n::t('minutes'), '900'=>'15 '.L10n::t('minutes'), '1800'=>'30 '.L10n::t('minutes'), '3600'=>'60 '.L10n::t('minutes')]], + '$cachetime' => [ + 'cachetime', + L10n::t('Caching Interval'), + $cachetime, + L10n::t('For how long should the weather data be cached? Choose according your OpenWeatherMap account type.'), [ + '0'=>L10n::t('no cache'), + '300'=>'5 '.L10n::t('minutes'), + '900'=>'15 '.L10n::t('minutes'), + '1800'=>'30 '.L10n::t('minutes'), + '3600'=>'60 '.L10n::t('minutes') + ] + ], '$appid' => ['appid', L10n::t('Your APPID'), $appid, L10n::t('Your API key provided by OpenWeatherMap')] ]); }