- $temp .= '°F';
- };
- $rhumid = $weather->humidity;
- $pressure = $weather->pressure;
- $wind = $weather->wind->speed->getDescription().', '.$weather->wind->speed . " " . $weather->wind->direction;
- $description = $weather->clouds->getDescription();
- $city = array(
- 'name'=>$weather->city->name,
- 'lon' =>$weather->city->lon,
- 'lat' =>$weather->city->lat
- );
- } catch(OWMException $e) {
- info ( 'OpenWeatherMap exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').');
- $ok = false;
- } catch(\Exception $e) {
- info ('General exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').');
- $ok = false;
- }
-
- if ($ok) {
- $t = get_markup_template("widget.tpl", "addon/curweather/" );
- $curweather = replace_macros ($t, array(
- '$title' => t("Current Weather"),
- '$city' => $city,
- '$description' => $description,
- '$temp' => $temp,
- '$relhumidity' => array('caption'=>t('Relative Humidity'), 'val'=>$rhumid),
- '$pressure' => array('caption'=>t('Pressure'), 'val'=>$pressure),
- '$wind' => array('caption'=>t('Wind'), 'val'=> $wind),
- '$databy' => t('Data by'),
- '$showonmap' => t('Show on map')
- ));
- } else {
- $t = get_markup_template('widget-error.tpl', 'addon/curweather/');
- $curweather = replace_macros( $t, array(
- '$problem' => t('There was a problem accessing the weather data. But have a look'),
- '$rpt' => $rpt,
- '$atOWM' => t('at OpenWeatherMap')
- ));
- }
-
- $fk_app->page['aside'] = $curweather.$fk_app->page['aside'];