mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-19 23:07:03 +00:00
Fix even more whitespace.
As requested by @MrPetovan.
This commit is contained in:
parent
f539d055ea
commit
f36b8e24cf
1 changed files with 56 additions and 46 deletions
|
@ -32,7 +32,7 @@ function getWeather( $loc, $units='metric', $lang='en', $appid='', $cachetime=0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$res = new SimpleXMLElement(Network::fetchUrl($url));
|
$res = new SimpleXMLElement(Network::fetchUrl($url));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
if (!$_SESSION['curweather_notice_shown']) {
|
if (!$_SESSION['curweather_notice_shown']) {
|
||||||
info(L10n::t('Error fetching weather data.\nError was: '.$e->getMessage()));
|
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) {
|
function curweather_addon_settings_post($a,$post) {
|
||||||
if(! local_user() || (! x($_POST,'curweather-settings-submit')))
|
if(! local_user() || (! x($_POST,'curweather-settings-submit')))
|
||||||
return;
|
return;
|
||||||
PConfig::set(local_user(),'curweather','curweather_loc',trim($_POST['curweather_loc']));
|
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_enable',intval($_POST['curweather_enable']));
|
||||||
PConfig::set(local_user(),'curweather','curweather_units',trim($_POST['curweather_units']));
|
PConfig::set(local_user(),'curweather','curweather_units',trim($_POST['curweather_units']));
|
||||||
|
|
||||||
info(L10n::t('Current Weather settings updated.') . EOL);
|
info(L10n::t('Current Weather settings updated.') . EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
function curweather_addon_settings(&$a,&$s) {
|
function curweather_addon_settings(&$a,&$s) {
|
||||||
|
|
||||||
if(! local_user())
|
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. <em>Berlin,DE</em> or <em>14476,DE</em>.') ],
|
|
||||||
'$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;
|
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. <em>Berlin,DE</em> or <em>14476,DE</em>.') ],
|
||||||
|
'$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
|
// Config stuff for the admin panel to let the admin of the node set a APPID
|
||||||
// for accessing the API of openweathermap
|
// for accessing the API of openweathermap
|
||||||
function curweather_addon_admin_post (&$a) {
|
function curweather_addon_admin_post (&$a) {
|
||||||
if(! is_site_admin())
|
if(! is_site_admin())
|
||||||
return;
|
return;
|
||||||
if ($_POST['curweather-submit']) {
|
if ($_POST['curweather-submit']) {
|
||||||
Config::set('curweather','appid',trim($_POST['appid']));
|
Config::set('curweather','appid',trim($_POST['appid']));
|
||||||
Config::set('curweather','cachetime',trim($_POST['cachetime']));
|
Config::set('curweather','cachetime',trim($_POST['cachetime']));
|
||||||
info(L10n::t('Curweather settings saved.'.EOL));
|
info(L10n::t('Curweather settings saved.'.EOL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function curweather_addon_admin (&$a, &$o) {
|
function curweather_addon_admin (&$a, &$o) {
|
||||||
if(! is_site_admin())
|
if(! is_site_admin())
|
||||||
return;
|
return;
|
||||||
$appid = Config::get('curweather','appid');
|
$appid = Config::get('curweather','appid');
|
||||||
$cachetime = Config::get('curweather','cachetime');
|
$cachetime = Config::get('curweather','cachetime');
|
||||||
$t = get_markup_template("admin.tpl", "addon/curweather/" );
|
$t = get_markup_template("admin.tpl", "addon/curweather/" );
|
||||||
$o = replace_macros ($t, [
|
$o = replace_macros ($t, [
|
||||||
'$submit' => L10n::t('Save Settings'),
|
'$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')]
|
'$appid' => ['appid', L10n::t('Your APPID'), $appid, L10n::t('Your API key provided by OpenWeatherMap')]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue