From 9b2b4aae8c259d90b13c5843e75076090f7e79bc Mon Sep 17 00:00:00 2001 From: Jacek Kowalski <Jacek@jacekk.info> Date: Wed, 29 Aug 2012 12:42:14 +0000 Subject: [PATCH] 1. Poprawka błędnej nazwy pola klasy DownloadHelper, 2. Zmiany struktur oraz sposobu generowania HTML w pliku ./modules/30_pogoda/api_yrno.php, 3. Uwzględnienie w/w zmian w module pogoda. --- modules/30_pogoda/api_yrno.php | 2 +- modules/30_pogoda/handler.php | 10 +++++++--- class/DownloadHelper.php | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/class/DownloadHelper.php b/class/DownloadHelper.php index 25f4c71..9059c13 100644 --- a/class/DownloadHelper.php +++ b/class/DownloadHelper.php @@ -3,7 +3,7 @@ protected $url; protected $curl; protected $headers = array(); - protected $data = NULL; + protected $return = NULL; protected $cacheDir = './cache/'; protected $cacheFile; diff --git a/modules/30_pogoda/api_yrno.php b/modules/30_pogoda/api_yrno.php index 56b95b2..70e3b5a 100644 --- a/modules/30_pogoda/api_yrno.php +++ b/modules/30_pogoda/api_yrno.php @@ -181,7 +181,7 @@ unset($wind['day']); } - return array($temp, $wind); + return array('temp' => $temp, 'wind' => $wind); } function getDaypartIcon($timestamp) { diff --git a/modules/30_pogoda/handler.php b/modules/30_pogoda/handler.php index 6ffc55a..3a71211 100644 --- a/modules/30_pogoda/handler.php +++ b/modules/30_pogoda/handler.php @@ -71,7 +71,7 @@ return new BotMsg('Nie udało się pobrać danych o pogodzie - spróbuj ponownie za około 10 minut.'); } - $out->a('<p>Pogoda dla '.htmlspecialchars($loc->name).', '.htmlspecialchars($loc->countryName).'.</p>'."\n\n"); + $out->a('<p>Pogoda dla '.htmlspecialchars($loc['name']).', '.htmlspecialchars($loc['countryName']).'.</p>'."\n\n"); $icon = $api->symbols[$api->getCurrentIcon()]; $weather = $api->getCurrentWeather(); @@ -98,6 +98,10 @@ return $out; } + function getHTMLforRange($data) { + return htmlspecialchars($data['from'].($data['from'] != $data['to'] ? '-'.$data['to'] : '')); + } + function getHTMLforWeather($name, $icons, $weather) { $html = '<p><b>'.$name.'</b><br />'."\n"; foreach($icons as $icon) { @@ -106,8 +110,8 @@ } } $html .= '<br />'."\n" - . 'Temp.: '.$weather['temp']['from'].($weather['temp']['from'] != $weather['temp']['to'] ? '-'.$weather['temp']['to'] : '').'°C<br />'."\n" - . 'Wiatr: '.$weather['wind']['from'].($weather['wind']['from'] != $weather['wind']['to'] ? '-'.$weather['wind']['to'] : '').' km/h</p>'."\n\n"; + . 'Temp.: '.$this->getHTMLforRange($weather['temp']['day']).'°C (w nocy: '.$this->getHTMLforRange($weather['temp']['night']).'°C)<br />'."\n" + . 'Wiatr: '.$this->getHTMLforRange($weather['wind']['day']).' km/h (w nocy: '.$this->getHTMLforRange($weather['wind']['night']).' km/h)</p>'."\n\n"; return $html; } -- Gitblit v1.9.1