path = (isset($conf['path']) ? $conf['path'] : '/ig/images/weather/'); // /fileadmin/templates/img/wetter-icons/ $this->imageExtension = ((isset($conf['png']) && $conf['png'] == 1) ? 'png' : 'gif'); $poi = ((isset($conf['poi']) && $conf['poi'] != '') ? $conf['poi'] : 'Berlin'); $url = "http://www.google.com/ig/api?weather=". $poi ."&hl=de"; $site = file_get_contents($url); $xml = iconv("iso-8859-1", "utf-8", $site); $this->xml = new SimpleXMLElement($xml); return $this->getWeatherData(); } private function getWeatherData() { $days = array('Heute', 'Morgen', 'Übermorgen'); $out = ''; for ($dayNr=0; $dayNr<3; $dayNr++) { $weather = $this->getForecast($dayNr); $weather['dayName'] = $days[$dayNr]; $out .= $this->getHtml($weather); } return $out; } private function getForecast($dayNr) { $weather = array(); $weather['condition'] = $this->xml->weather->forecast_conditions[$dayNr]->condition['data']; $weather['day'] = $this->xml->weather->forecast_conditions[$dayNr]->day_of_week['data']; $weather['low'] = $this->xml->weather->forecast_conditions[$dayNr]->low['data']; $weather['high'] = $this->xml->weather->forecast_conditions[$dayNr]->high['data']; $weather['icon'] = $this->xml->weather->forecast_conditions[$dayNr]->icon['data']; if ($this->path != '') { $weather['icon'] = substr(str_replace('/ig/images/weather/', $this->path, $weather['icon']), 0 , -3) . $this->imageExtension; } else { $weather['icon'] = 'http://www.google.com' . $weather['icon']; } return $weather; } private function getHtml($weather) { return '' . $weather['dayName']. 'Wetter Icon ' . $weather['condition'] . '' . $weather['high'] . ' °C '; } } ?>