1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20:
21: class Horde_Service_Weather_Period_WeatherUnderground extends Horde_Service_Weather_Period_Base
22: {
23:
24: 25: 26: 27: 28: 29: 30: 31: 32:
33: protected $_map = array(
34: 'conditions' => 'conditions',
35: 'icon_url' => 'icon_url',
36: 'precipitation_percent' => 'pop',
37: 'period' => 'period',
38: 'humidity' => 'maxhumidity',
39: );
40:
41: 42: 43: 44: 45: 46: 47: 48:
49: public function __get($property)
50: {
51: switch ($property) {
52: case 'is_pm':
53:
54: return false;
55: case 'hour':
56:
57: return false;
58: case 'date':
59: $date = new Horde_Date(array(
60: 'year' => $this->_properties['date']->year,
61: 'month' => $this->_properties['date']->month,
62: 'mday' => $this->_properties['date']->day));
63: $date->hour = $this->_properties['date']->hour;
64: $date->min = $this->_properties['date']->min;
65: $date->setTimezone($this->_properties['date']->tz_long);
66:
67: return $date;
68:
69: case 'high':
70: if ($this->_forecast->weather->units == Horde_Service_Weather::UNITS_STANDARD) {
71: return $this->_properties['high']->fahrenheit !== '' ?
72: $this->_properties['high']->fahrenheit :
73: Horde_Service_Weather_Translation::t('N/A');
74: }
75: return $this->_properties['high']->celsius;
76:
77: case 'low':
78: if ($this->_forecast->weather->units == Horde_Service_Weather::UNITS_STANDARD) {
79: return $this->_properties['low']->fahrenheit !== '' ?
80: $this->_properties['low']->fahrenheit :
81: Horde_Service_Weather_Translation::t('N/A');
82: }
83: return $this->_properties['low']->celsius;
84:
85: case 'icon':
86: return $this->_forecast->weather->iconMap[$this->_properties['icon']];
87:
88: case 'wind_direction':
89: return Horde_Service_Weather_Translation::t($this->_properties['avewind']->dir);
90:
91: case 'wind_degrees':
92: return $this->_properties['avewind']->degrees;
93:
94: case 'wind_speed':
95: if ($this->_forecast->weather->units == Horde_Service_Weather::UNITS_STANDARD) {
96: return $this->_properties['avewind']->mph;
97: }
98: return $this->_properties['avewind']->kph;
99:
100: case 'wind_gust':
101: if ($this->_forecast->weather->units == Horde_Service_Weather::UNITS_STANDARD) {
102: return $this->_properties['maxwind']->mph;
103: }
104: return $this->_properties['maxwind']->kph;
105:
106: case 'rain_total':
107: if ($this->_forecast->weather->units == Horde_Service_Weather::UNITS_STANDARD) {
108: return $this->_properties['qpf_allday']->in;
109: }
110: return $this->_properties['qpf_allday']->mm;
111:
112: case 'snow_total':
113: if ($this->_forecast->weather->units == Horde_Service_Weather::UNITS_STANDARD) {
114: return $this->_properties['snow_allday']->in;
115: }
116: return $this->_properties['snow_allday']->cm;
117:
118: default:
119: if (!empty($this->_map[$property])) {
120: return Horde_Service_Weather_Translation::t($this->_properties[$this->_map[$property]]);
121: }
122:
123: throw new Horde_Service_Weather_Exception_InvalidProperty('This provider does not support the "' . $property . '" property');
124: }
125: }
126:
127: }