-function curweather_network_mod_init(&$fk_app,&$b) {
-
- if(! intval(PConfig::get(local_user(),'curweather','curweather_enable')))
- return;
-
- $fk_app->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $fk_app->get_baseurl() . '/addon/curweather/curweather.css' . '" media="all" />' . "\r\n";
-
- // $rpt value is needed for location
- // $lang will be taken from the browser session to honour user settings
- // TODO $lang does not work if the default settings are used
- // and not all response strings are translated
- // $units can be set in the settings by the user
- // $appid is configured by the admin in the admin panel
- // those parameters will be used to get: cloud status, temperature, preassure
- // and relative humidity for display, also the relevent area of the map is
- // 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');
- $appid = Config::get('curweather','appid');
- $cachetime = intval(Config::get('curweather','cachetime'));
- if ($units==="")
- $units = 'metric';
- $ok = true;
-
- $res = getWeather($rpt, $units, $lang, $appid, $cachetime);
- if ($res===false)
- $ok = false;
-
- if ($ok) {
- $t = get_markup_template("widget.tpl", "addon/curweather/" );
- $curweather = replace_macros ($t, [
- '$title' => L10n::t("Current Weather"),
- '$icon' => proxy_url('http://openweathermap.org/img/w/'.$res['icon'].'.png'),
- '$city' => $res['city'],
- '$lon' => $res['lon'],
- '$lat' => $res['lat'],
- '$description' => $res['descripion'],
- '$temp' => $res['temperature'],
- '$relhumidity' => ['caption'=>L10n::t('Relative Humidity'), 'val'=>$res['humidity']],
- '$pressure' => ['caption'=>L10n::t('Pressure'), 'val'=>$res['pressure']],
- '$wind' => ['caption'=>L10n::t('Wind'), 'val'=> $res['wind']],
- '$lastupdate' => L10n::t('Last Updated').': '.$res['update'].'UTC',
- '$databy' => L10n::t('Data by'),
- '$showonmap' => L10n::t('Show on map')
- ]);
- } else {
- $t = get_markup_template('widget-error.tpl', 'addon/curweather/');
- $curweather = replace_macros( $t, [
- '$problem' => L10n::t('There was a problem accessing the weather data. But have a look'),
- '$rpt' => $rpt,
- '$atOWM' => L10n::t('at OpenWeatherMap')
- ]);
- }
-
- $fk_app->page['aside'] = $curweather.$fk_app->page['aside'];
+function curweather_network_mod_init(App $a, &$b)
+{
+ if (!intval(DI::pConfig()->get(local_user(), 'curweather', 'curweather_enable'))) {
+ return;
+ }
+
+ DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/curweather/curweather.css' . '" media="all" />' . "\r\n";
+
+ // $rpt value is needed for location
+ // $lang will be taken from the browser session to honour user settings
+ // TODO $lang does not work if the default settings are used
+ // and not all response strings are translated
+ // $units can be set in the settings by the user
+ // $appid is configured by the admin in the admin panel
+ // those parameters will be used to get: cloud status, temperature, preassure
+ // and relative humidity for display, also the relevent area of the map is
+ // linked from lat/log of the reply of OWMp
+ $rpt = DI::pConfig()->get(local_user(), 'curweather', 'curweather_loc');
+
+ // Set the language to the browsers language or default and use metric units
+ $lang = Session::get('language', DI::config()->get('system', 'language'));
+ $units = DI::pConfig()->get( local_user(), 'curweather', 'curweather_units');
+ $appid = DI::config()->get('curweather', 'appid');
+ $cachetime = intval(DI::config()->get('curweather', 'cachetime'));
+
+ if ($units === "") {
+ $units = 'metric';
+ }
+
+ $ok = true;
+
+ $res = getWeather($rpt, $units, $lang, $appid, $cachetime);
+
+ if ($res === false) {
+ $ok = false;
+ }
+
+ if ($ok) {
+ $t = Renderer::getMarkupTemplate("widget.tpl", "addon/curweather/" );
+ $curweather = Renderer::replaceMacros($t, [
+ '$title' => DI::l10n()->t("Current Weather"),
+ '$icon' => ProxyUtils::proxifyUrl('http://openweathermap.org/img/w/'.$res['icon'].'.png'),
+ '$city' => $res['city'],
+ '$lon' => $res['lon'],
+ '$lat' => $res['lat'],
+ '$description' => $res['descripion'],
+ '$temp' => $res['temperature'],
+ '$relhumidity' => ['caption'=>DI::l10n()->t('Relative Humidity'), 'val'=>$res['humidity']],
+ '$pressure' => ['caption'=>DI::l10n()->t('Pressure'), 'val'=>$res['pressure']],
+ '$wind' => ['caption'=>DI::l10n()->t('Wind'), 'val'=> $res['wind']],
+ '$lastupdate' => DI::l10n()->t('Last Updated').': '.$res['update'].'UTC',
+ '$databy' => DI::l10n()->t('Data by'),
+ '$showonmap' => DI::l10n()->t('Show on map')
+ ]);
+ } else {
+ $t = Renderer::getMarkupTemplate('widget-error.tpl', 'addon/curweather/');
+ $curweather = Renderer::replaceMacros( $t, [
+ '$problem' => DI::l10n()->t('There was a problem accessing the weather data. But have a look'),
+ '$rpt' => $rpt,
+ '$atOWM' => DI::l10n()->t('at OpenWeatherMap')
+ ]);
+ }
+
+ DI::page()['aside'] = $curweather . DI::page()['aside'];