';
-
- /* provide a submit button */
+ // load template and replace the macros
+ $t = Renderer::getMarkupTemplate("settings.tpl", "addon/curweather/" );
+
+ $s = Renderer::replaceMacros($t, [
+ '$submit' => DI::l10n()->t('Save Settings'),
+ '$header' => DI::l10n()->t('Current Weather').' '.DI::l10n()->t('Settings'),
+ '$noappidtext' => $noappidtext,
+ '$info' => DI::l10n()->t('Enter either the name of your location or the zip code.'),
+ '$curweather_loc' => [ 'curweather_loc', DI::l10n()->t('Your Location'), $curweather_loc, DI::l10n()->t('Identifier of your location (name or zip code), e.g. Berlin,DE or 14476,DE.') ],
+ '$curweather_units' => [ 'curweather_units', DI::l10n()->t('Units'), $curweather_units, DI::l10n()->t('select if the temperature should be displayed in °C or °F'), ['metric'=>'°C', 'imperial'=>'°F']],
+ '$enabled' => [ 'curweather_enable', DI::l10n()->t('Show weather data'), $enable, '']
+ ]);
+
+ return;
+}
- $s .= '
';
+// 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(App $a)
+{
+ if (!is_site_admin()) {
+ return;
+ }
+ if (!empty($_POST['curweather-submit'])) {
+ DI::config()->set('curweather', 'appid', trim($_POST['appid']));
+ DI::config()->set('curweather', 'cachetime', trim($_POST['cachetime']));
+ }
}
-
+function curweather_addon_admin(App $a, &$o)
+{
+ if (!is_site_admin()) {
+ return;
+ }
+
+ $appid = DI::config()->get('curweather', 'appid');
+ $cachetime = DI::config()->get('curweather', 'cachetime');
+
+ $t = Renderer::getMarkupTemplate("admin.tpl", "addon/curweather/" );
+
+ $o = Renderer::replaceMacros($t, [
+ '$submit' => DI::l10n()->t('Save Settings'),
+ '$cachetime' => [
+ 'cachetime',
+ DI::l10n()->t('Caching Interval'),
+ $cachetime,
+ DI::l10n()->t('For how long should the weather data be cached? Choose according your OpenWeatherMap account type.'), [
+ '0' => DI::l10n()->t('no cache'),
+ '300' => '5 ' . DI::l10n()->t('minutes'),
+ '900' => '15 ' . DI::l10n()->t('minutes'),
+ '1800' => '30 ' . DI::l10n()->t('minutes'),
+ '3600' => '60 ' . DI::l10n()->t('minutes')
+ ]
+ ],
+ '$appid' => ['appid', DI::l10n()->t('Your APPID'), $appid, DI::l10n()->t('Your API key provided by OpenWeatherMap')]
+ ]);
+}