Update of /cvsroot/php-blog/additional_plugins/serendipity_plugin_weather
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21650/serendipity_plugin_weather
Modified Files:
serendipity_plugin_weather.php
Log Message:
Fixed Windows linebreaks
Index: serendipity_plugin_weather.php
===================================================================
RCS file: /cvsroot/php-blog/additional_plugins/serendipity_plugin_weather/serendipity_plugin_weather.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- serendipity_plugin_weather.php 2 Jan 2005 18:41:04 -0000 1.10
+++ serendipity_plugin_weather.php 2 Jan 2005 20:16:34 -0000 1.11
@@ -1,475 +1,475 @@
-<?php
-
-/* $Id$*/
-
-switch ($serendipity['lang']) {
- case 'de':
- @define('PLUGIN_SIDEBAR_WEATHER_NAME', 'Wetter');
- @define('PLUGIN_SIDEBAR_WEATHER_DESC', 'Zeigt das aktuelle Wetter in der Seitenleiste.');
- @define('PLUGIN_SIDEBAR_WEATHER_TITLE', 'Überschrift');
- @define('PLUGIN_SIDEBAR_WEATHER_TITLE_BLAHBLAH', 'Überschrift der Wetter-Box');
- @define('PLUGIN_SIDEBAR_WEATHER_METAR', 'METAR Wetterquelle, z.B. EDDK');
- @define('PLUGIN_SIDEBAR_WEATHER_METAR_BLAHBLAH', 'METAR-Quellen sind unter http://weather.noaa.gov/ zu finden.');
- @define('PLUGIN_SIDEBAR_WEATHER_UNITS', 'Maßeinheiten');
- @define('PLUGIN_SIDEBAR_WEATHER_UNITS_BLAHBLAH', 'Wählen Sie das Maßsystem.');
- @define('PLUGIN_SIDEBAR_WEATHER_UNITS_NAME_METRIC', 'Metrisch');
- @define('PLUGIN_SIDEBAR_WEATHER_UNITS_NAME_IMPERIAL', 'FIXXME');
- @define('PLUGIN_SIDEBAR_WEATHER_TIMEZONE', 'Zeitzone');
- @define('PLUGIN_SIDEBAR_WEATHER_TIMEZONE_BLAHBLAH', 'Die Zeitzone sollte relativ zu GMT sein (also z.B. +10 oder -5) sein.');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_UPDATE', 'Zuletzt geändert:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_WINDDIRECTION', 'Windrichtung:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_VISIBILITY', 'Sichtweite:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_CLOUDS_AMOUNT', 'Wolken:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_CLOUDS_HEIGHT', 'Wolkenhöhe:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_TEMPERATURE', 'Temperatur:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_FELT_TEMPERATURE', 'Gefühlte Temperatur:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_HUMIDITY', 'rel. Luftfeuchtigkeit:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_PRESSURE', 'Luftdruck:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_RAIN', 'Regen:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_S', 'South'); //Translate
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_SE', 'Southeast'); //Translate
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_SW', 'Southwest'); //Translate
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_SSW', 'South/Southwest'); //Translate
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_SSE', 'South/Southeast'); //Translate
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_E', 'East'); //Translate
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_ESE', 'East/Southeast'); //Translate
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_ENE', 'East/Northeast'); //Translate
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_N', 'North'); //Translate
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_NW', 'Northwest'); //Translate
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_NE', 'Northeast'); //Translate
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_NNW', 'North/Northwest'); //Translate
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_NNE', 'North/Northeast'); //Translate
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_W', 'West'); //Translate
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_WNW', 'West/Northwest'); //Translate
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_WSW', 'West/Southwest'); //Translate
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_V', 'Variable'); //Translate
- break;
- case 'en':
- default:
- @define('PLUGIN_SIDEBAR_WEATHER_NAME', 'Weather');
- @define('PLUGIN_SIDEBAR_WEATHER_DESC', 'Display the current weather in the sidebar.');
- @define('PLUGIN_SIDEBAR_WEATHER_TITLE', 'Headline');
- @define('PLUGIN_SIDEBAR_WEATHER_TITLE_BLAHBLAH', 'Sidebar item headline');
- @define('PLUGIN_SIDEBAR_WEATHER_METAR', 'METAR weather source, for example EDDK');
- @define('PLUGIN_SIDEBAR_WEATHER_METAR_BLAHBLAH', 'Find your METAR weather source at http://weather.noaa.gov/');
- @define('PLUGIN_SIDEBAR_WEATHER_TIMEZONE', 'Your timezone');
- @define('PLUGIN_SIDEBAR_WEATHER_TIMEZONE_BLAHBLAH', 'Timezone should be relative to GMT (eg. +10 or -5)');
- @define('PLUGIN_SIDEBAR_WEATHER_UNITS','Measurement Units');
- @define('PLUGIN_SIDEBAR_WEATHER_UNITS_BLAHBLAH','Select the units of Measurement you want');
- @define('PLUGIN_SIDEBAR_WEATHER_UNITS_NAME_METRIC', 'Metric');
- @define('PLUGIN_SIDEBAR_WEATHER_UNITS_NAME_IMPERIAL', 'Imperial/US Standard');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_UPDATE', 'Last update:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_WINDDIRECTION', 'Wind direction:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_VISIBILITY', 'Visibility:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_CLOUDS_AMOUNT', 'Clouds amount:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_CLOUDS_HEIGHT', 'Clouds height:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_TEMPERATURE', 'Temperature:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_FELT_TEMPERATURE', 'Feels Like:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_HUMIDITY', 'Humidity:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_PRESSURE', 'Pressure:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_RAIN', 'Rain:');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_S', 'South');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_SE', 'Southeast');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_SW', 'Southwest');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_SSW', 'South/Southwest');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_SSE', 'South/Southeast');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_E', 'East');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_ESE', 'East/Southeast');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_ENE', 'East/Northeast');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_N', 'North');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_NW', 'Northwest');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_NE', 'Northeast');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_NNW', 'North/Northwest');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_NNE', 'North/Northeast');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_W', 'West');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_WNW', 'West/Northwest');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_WSW', 'West/Southwest');
- @define('PLUGIN_SIDEBAR_WEATHER_DATA_V', 'Variable');
- break;
- } // switch
-
-class serendipity_plugin_weather extends serendipity_plugin {
- /**
- * serendipity_plugin_weather::introspect()
- *
- * @param $propbag
- * @return
- */
- function introspect(&$propbag)
- {
- global $serendipity;
-
- $propbag->add('name', PLUGIN_SIDEBAR_WEATHER_NAME);
- $propbag->add('description', PLUGIN_SIDEBAR_WEATHER_DESC);
- $propbag->add('configuration', array('title',
- 'metar',
- 'timezone',
- 'units'));
- } // function
- /**
-
- * serendipity_plugin_weather::introspect_config_item()
- *
- * @param $name
- * @param $propbag
- * @return
- */
- function introspect_config_item($name, &$propbag)
- {
- switch ($name) {
- case 'title':
- $propbag->add('type', 'string');
- $propbag->add('name', PLUGIN_SIDEBAR_WEATHER_TITLE);
- $propbag->add('description', PLUGIN_SIDEBAR_WEATHER_TITLE_BLAHBLAH);
- break;
- case 'metar':
- $propbag->add('type', 'string');
- $propbag->add('name', PLUGIN_SIDEBAR_WEATHER_METAR);
- $propbag->add('description', PLUGIN_SIDEBAR_WEATHER_METAR_BLAHBLAH);
- break;
- case 'timezone':
- $propbag->add('type', 'string');
- $propbag->add('name', PLUGIN_SIDEBAR_WEATHER_TIMEZONE);
- $propbag->add('description', PLUGIN_SIDEBAR_WEATHER_TIMEZONE_BLAHBLAH);
- break;
- case 'units':
- $select = array();
- $select["metric"] = PLUGIN_SIDEBAR_WEATHER_UNITS_NAME_METRIC;
- $select["standard"] = PLUGIN_SIDEBAR_WEATHER_UNITS_NAME_IMPERIAL;
-
- $propbag->add('type', 'select');
- $propbag->add('name', PLUGIN_SIDEBAR_WEATHER_UNITS);
- $propbag->add('description', PLUGIN_SIDEBAR_WEATHER_UNITS_BLAHBLAH);
- $propbag->add('select_values', $select);
- break;
- default:
- return false;
- } // switch
- return true;
- } // function
- /**
- * serendipity_plugin_weather::generate_content()
- *
- * @param $title
- * @return
- */
- function generate_content(&$title)
- {
- global $serendipity;
-
- $title = $this->get_config('title');
- $metar_site = $this->get_config('metar','EDDK');
- $timezone = $this->get_config('timezone',0);
- $unitString = $this->get_config('units','metric');
-
- require_once('Services/Weather.php');
-
- $metar = &Services_Weather::service('METAR', array('debug' => 0));
- if (Services_Weather::isError($metar)) {
- die('Error: ' . $metar->getMessage());
- }
-
- // Set the unit format for the data
- $metar->setUnitsFormat($unitString);
-
- // Set the time/date format
- // Do we have the date/time format set somewhere in s9y? then we should take this here
- // $metar->setDateTimeFormat('d.m.Y', 'H:i');
- // $metar_data->setDateTimeFormat('j M Y', 'H:i');
-
- $status = $metar->setCache('file', array('cache_dir' => $serendipity['serendipityPath'].'/templates_c'));
- if (Services_Weather::isError($status)) {
- echo 'Error: ' . $status->getMessage();
- }
-
- switch($unitString)
- {
- case "metric":
- $units = array('wind' => 'km/h',
- 'vis' => 'km',
- 'height' => 'km',
- 'temp' => '°C',
- 'pres' => 'mb',
- 'rain' => 'mm');
- break;
- case "standard":
- $units = array('wind' => 'mph',
- 'vis' => 'mi',
- 'height' => 'mi',
- 'temp' => '°F',
- 'pres' => 'in',
- 'rain' => 'in');
- break;
- }
-
-
-
- $weather_data = $metar->getWeather($metar_site);
- if (Services_Weather::isError($weather_data)) {
- echo 'Error: ' . $weather_data->getMessage();
- }
-
- $location_data = $metar->getLocation($metar_site);
- if (Services_Weather::isError($location_data)) {
- echo 'Error: ' . $location_data->getMessage();
- }
-
- $forecast_data = $metar->getForecast($metar_site);
- if (Services_Weather::isError($forecast_data)) {
- echo 'Error: ' . $forecast_data->getMessage();
- }
-
- // Do all that icon-stuff
- // FIXXME: URL-Prefix
- $windDir = $weather_data["windDirection"];
- switch ($windDir) {
- case 'S':
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/sss.png';
- $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_S;
- break;
- case 'SSW':
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/ssw.png';
- $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_SSW;
- break;
- case 'SSE':
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/sse.png';
- $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_SSE;
- break;
- case 'SW':
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/sw.png';
- $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_SW;
- break;
- case 'WSW':
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/sww.png';
- $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_WSW;
- break;
- case 'E':
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/eee.png';
- $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_E;
- break;
- case 'ESE':
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/see.png';
- $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_ESE;
- break;
- case 'ENE':
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/nee.png';
- $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_ENE;
- break;
- case 'N':
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/nnn.png';
- $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_N;
- break;
- case 'NNW':
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/nnw.png';
- $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_NNW;
- break;
- case 'NNE':
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/nne.png';
- $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_NNE;
- break;
- case 'NW':
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/nw.png';
- $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_NW;
- break;
- case 'NE':
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/ne.png';
- $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_NE;
- break;
- case 'SE':
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/se.png';
- $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_SE;
- break;
- case 'W':
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/www.png';
- $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_W;
- break;
- case 'WNW':
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/nww.png';
- $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_WNW;
- break;
- case 'Variable':
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/vrb.gif';
- $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_V;
- break;
- default :
- $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/wind_nodata.png';
- $windDir = "No recorded data.";
- }
-
- // Turn the GMT time from the update into a local time
- $localTime = date('j M Y H:i', strtotime($weather_data['updateRaw']) + (3600*$timezone));
-
- // Get local hour to determing if it is night
- $hour = date('H' , strtotime($weather_data['updateRaw']) + (3600*$tz));
- if ($hour > 18 || $hour < 6) {
- $night = 'n_';
- } else {
- $night = '';
- }
-
- // Handle cloud data
- // We could be dealing with cloud at several levels, so find the heaviest
- // cover and go with that.
- $cloudData = $weather_data['clouds'];
- // See if we are dealing with an array of arrays or some information
- $cloudKeys = array_keys($cloudData);
- $testKey = $cloudKeys[0];
- if (!is_array($cloudData["$testKey"])) {
- // we have information
- $amount = $cloudData['amount'];
- } else {
- // we have information on several levels - get highest
- $key = count($cloudKeys)-1;
- $useArray = $cloudData[$key];
- $amount = $useArray['amount'];
- }
-
- switch ($amount) {
- case "Clear Below":
- case "clear sky":
- case "no significant cloud":
- case "clear below 12,000 ft":
- case "vertical visibility":
- $cloudLevel = "0cloud";
- break;
- case "few":
- case "scattered":
- $cloudLevel = "1cloud";
- break;
- case "Cumulonimbus":
- $cloudLevel = "2cloud";
- break;
- case "Towering Cumulus":
- case "broken":
- $cloudLevel = "3cloud";
- break;
- case "overcast":
- $cloudLevel = "4cloud";
- $night = "";
- break;
- default:
- $cloudLevel = "0cloud";
- }
-
- // Determine weather conditions (rain, snow etc);
- // We need some way to translate this
- $conditions = $weather_data["condition"];
-
- switch ($cloudLevel) {
- case "0cloud":
- if (strstr($conditions, "fog") !== FALSE) {
- $condUse = "_fog";
- } else {
- $condUse = "";
- }
- break;
- case "1cloud":
- if (strstr($conditions, "fog") !== FALSE) {
- $condUse = "_fog";
- } elseif (strstr($conditions, "rain") !== FALSE && strstr($conditions, "light") !== FALSE) {
- $condUse = "_lightrain";
- } elseif (strstr($conditions, "rain") !== FALSE && strstr($conditions, "heavy") !== FALSE) {
- $condUse = "_heavyrain";
- } elseif (strstr($conditions, "rain") !== FALSE) {
- $condUse = "_modrain";
- } else {
- $condUse = "_norain";
- }
- break;
- case "2cloud":
- if (strstr($conditions, "fog") !== FALSE) {
- $condUse = "_fog";
- } elseif (strstr($conditions, "rain") !== FALSE && strstr($conditions, "light") !== FALSE) {
- $condUse = "_lightrain";
- } elseif (strstr($conditions, "rain") !== FALSE && strstr($conditions, "heavy") !== FALSE) {
- $condUse = "_heavyrain";
- } elseif (strstr($conditions, "rain") !== FALSE) {
- $condUse = "_modrain";
- } elseif (strstr($conditions, "snow") !== FALSE) {
- $condUse = "_snow";
- } elseif (strstr($conditions, "thunderstorm") !== FALSE) {
- $condUse = "_thunders";
- } else {
- $condUse = "_norain";
- }
- break;
- case "3cloud":
- if (strstr($conditions, "fog") !== FALSE) {
- $condUse = "_fog";
- } elseif (strstr($conditions, "rain") !== FALSE && strstr($conditions, "light") !== FALSE) {
- $condUse = "_lightrain";
- } elseif (strstr($conditions, "rain") !== FALSE && strstr($conditions, "heavy") !== FALSE) {
- $condUse = "_heavyrain";
- } elseif (strstr($conditions, "rain") !== FALSE) {
- $condUse = "_modrain";
- } elseif (strstr($conditions, "snow") !== FALSE) {
- $condUse = "_snow";
- } elseif (strstr($conditions, "thunderstorm") !== FALSE) {
- $condUse = "_thunders";
- } elseif (strstr($conditions, "hail") !== FALSE) {
- $condUse = "_hail";
- } else {
- $condUse = "_norain";
- }
- break;
- case "4cloud":
- if (strstr($conditions, "fog") !== FALSE) {
- $condUse = "_fog";
- } elseif (strstr($conditions, "rain") !== FALSE && strstr($conditions, "light") !== FALSE) {
- $condUse = "_lightrain";
- } elseif (strstr($conditions, "rain") !== FALSE && strstr($conditions, "heavy") !== FALSE) {
- $condUse = "_heavyrain";
- } elseif (strstr($conditions, "rain") !== FALSE) {
- $condUse = "_modrain";
- } elseif (strstr($conditions, "snow") !== FALSE && strstr($conditions, "light") !== FALSE) {
- $condUse = "_lightsnow";
- } elseif (strstr($conditions, "snow") !== FALSE && strstr($conditions, "heavy") !== FALSE) {
- $condUse = "_heavysnow";
- } elseif (strstr($conditions, "snow") !== FALSE) {
- $condUse = "_snow";
- } elseif (strstr($conditions, "thunderstorm") !== FALSE) {
- $condUse = "_thunders";
- } elseif (strstr($conditions, "hail") !== FALSE && strstr($conditions, "light") !== FALSE) {
- $condUse = "_lighthail";
- } elseif (strstr($conditions, "hail") !== FALSE && strstr($conditions, "heavy") !== FALSE) {
- $condUse = "_heavyhail";
- } elseif (strstr($conditions, "hail") !== FALSE) {
- $condUse = "_hail";
- } else {
- $condUse = "_norain";
- }
- break;
- default:
- $condUse = "_norain";
- }
-
- // Construct icon name
- $conditionIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/' . $night . $cloudLevel . $condUse . '.png';
-
- $content = '';
-
- $content .= '<img src="' . $conditionIcon . '" alt="" /><br />'. $conditions . '<br />';
- // FIXXME: Translate the Winddirection
- $content .= '<dl><dt>'.PLUGIN_SIDEBAR_WEATHER_DATA_WINDDIRECTION.'</dt><dd><img src="' .
- $windDirIcon . '" alt="" /><dt>' .
- $windDir . ' at <dd>' . $weather_data["wind"] . ' ' .$units['wind'] . '</dd></dt>';
-
- $content .= '<dt>'.PLUGIN_SIDEBAR_WEATHER_DATA_TEMPERATURE.'</dt><dd>'.
- $weather_data["temperature"].' '. $units['temp'].'</dd>';
- $content .= '<dt>'.PLUGIN_SIDEBAR_WEATHER_DATA_FELT_TEMPERATURE.'</dt><dd>'.
- $weather_data["feltTemperature"].' '. $units['temp'] .'</dd>';
- $content .= '<dt>'.PLUGIN_SIDEBAR_WEATHER_DATA_HUMIDITY.'</dt><dd>' .
- $weather_data["humidity"] .' '. '%</dd>';
- $content .= '<dt>'.PLUGIN_SIDEBAR_WEATHER_DATA_PRESSURE.'</dt><dd>' .
- $weather_data['pressure'] .' '. $units['pres'].'</dd>';
- $content .= '<dt>'.PLUGIN_SIDEBAR_WEATHER_DATA_VISIBILITY.'</dt><dd>' .
- $weather_data["visibility"] .' '. $units['vis'] . '</dd>';
- $content .= '<dt>'.PLUGIN_SIDEBAR_WEATHER_DATA_UPDATE.'</dt><dd>' .
- $localTime . '</dd></dl>';
-
- echo $content;
- } // function
-} // class
-
-?>
-
+<?php
+
+/* $Id$*/
+
+switch ($serendipity['lang']) {
+ case 'de':
+ @define('PLUGIN_SIDEBAR_WEATHER_NAME', 'Wetter');
+ @define('PLUGIN_SIDEBAR_WEATHER_DESC', 'Zeigt das aktuelle Wetter in der Seitenleiste.');
+ @define('PLUGIN_SIDEBAR_WEATHER_TITLE', 'Überschrift');
+ @define('PLUGIN_SIDEBAR_WEATHER_TITLE_BLAHBLAH', 'Überschrift der Wetter-Box');
+ @define('PLUGIN_SIDEBAR_WEATHER_METAR', 'METAR Wetterquelle, z.B. EDDK');
+ @define('PLUGIN_SIDEBAR_WEATHER_METAR_BLAHBLAH', 'METAR-Quellen sind unter http://weather.noaa.gov/ zu finden.');
+ @define('PLUGIN_SIDEBAR_WEATHER_UNITS', 'Maßeinheiten');
+ @define('PLUGIN_SIDEBAR_WEATHER_UNITS_BLAHBLAH', 'Wählen Sie das Maßsystem.');
+ @define('PLUGIN_SIDEBAR_WEATHER_UNITS_NAME_METRIC', 'Metrisch');
+ @define('PLUGIN_SIDEBAR_WEATHER_UNITS_NAME_IMPERIAL', 'FIXXME');
+ @define('PLUGIN_SIDEBAR_WEATHER_TIMEZONE', 'Zeitzone');
+ @define('PLUGIN_SIDEBAR_WEATHER_TIMEZONE_BLAHBLAH', 'Die Zeitzone sollte relativ zu GMT sein (also z.B. +10 oder -5) sein.');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_UPDATE', 'Zuletzt geändert:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_WINDDIRECTION', 'Windrichtung:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_VISIBILITY', 'Sichtweite:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_CLOUDS_AMOUNT', 'Wolken:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_CLOUDS_HEIGHT', 'Wolkenhöhe:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_TEMPERATURE', 'Temperatur:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_FELT_TEMPERATURE', 'Gefühlte Temperatur:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_HUMIDITY', 'rel. Luftfeuchtigkeit:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_PRESSURE', 'Luftdruck:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_RAIN', 'Regen:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_S', 'South'); //Translate
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_SE', 'Southeast'); //Translate
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_SW', 'Southwest'); //Translate
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_SSW', 'South/Southwest'); //Translate
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_SSE', 'South/Southeast'); //Translate
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_E', 'East'); //Translate
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_ESE', 'East/Southeast'); //Translate
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_ENE', 'East/Northeast'); //Translate
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_N', 'North'); //Translate
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_NW', 'Northwest'); //Translate
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_NE', 'Northeast'); //Translate
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_NNW', 'North/Northwest'); //Translate
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_NNE', 'North/Northeast'); //Translate
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_W', 'West'); //Translate
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_WNW', 'West/Northwest'); //Translate
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_WSW', 'West/Southwest'); //Translate
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_V', 'Variable'); //Translate
+ break;
+ case 'en':
+ default:
+ @define('PLUGIN_SIDEBAR_WEATHER_NAME', 'Weather');
+ @define('PLUGIN_SIDEBAR_WEATHER_DESC', 'Display the current weather in the sidebar.');
+ @define('PLUGIN_SIDEBAR_WEATHER_TITLE', 'Headline');
+ @define('PLUGIN_SIDEBAR_WEATHER_TITLE_BLAHBLAH', 'Sidebar item headline');
+ @define('PLUGIN_SIDEBAR_WEATHER_METAR', 'METAR weather source, for example EDDK');
+ @define('PLUGIN_SIDEBAR_WEATHER_METAR_BLAHBLAH', 'Find your METAR weather source at http://weather.noaa.gov/');
+ @define('PLUGIN_SIDEBAR_WEATHER_TIMEZONE', 'Your timezone');
+ @define('PLUGIN_SIDEBAR_WEATHER_TIMEZONE_BLAHBLAH', 'Timezone should be relative to GMT (eg. +10 or -5)');
+ @define('PLUGIN_SIDEBAR_WEATHER_UNITS','Measurement Units');
+ @define('PLUGIN_SIDEBAR_WEATHER_UNITS_BLAHBLAH','Select the units of Measurement you want');
+ @define('PLUGIN_SIDEBAR_WEATHER_UNITS_NAME_METRIC', 'Metric');
+ @define('PLUGIN_SIDEBAR_WEATHER_UNITS_NAME_IMPERIAL', 'Imperial/US Standard');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_UPDATE', 'Last update:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_WINDDIRECTION', 'Wind direction:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_VISIBILITY', 'Visibility:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_CLOUDS_AMOUNT', 'Clouds amount:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_CLOUDS_HEIGHT', 'Clouds height:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_TEMPERATURE', 'Temperature:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_FELT_TEMPERATURE', 'Feels Like:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_HUMIDITY', 'Humidity:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_PRESSURE', 'Pressure:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_RAIN', 'Rain:');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_S', 'South');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_SE', 'Southeast');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_SW', 'Southwest');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_SSW', 'South/Southwest');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_SSE', 'South/Southeast');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_E', 'East');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_ESE', 'East/Southeast');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_ENE', 'East/Northeast');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_N', 'North');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_NW', 'Northwest');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_NE', 'Northeast');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_NNW', 'North/Northwest');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_NNE', 'North/Northeast');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_W', 'West');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_WNW', 'West/Northwest');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_WSW', 'West/Southwest');
+ @define('PLUGIN_SIDEBAR_WEATHER_DATA_V', 'Variable');
+ break;
+ } // switch
+
+class serendipity_plugin_weather extends serendipity_plugin {
+ /**
+ * serendipity_plugin_weather::introspect()
+ *
+ * @param $propbag
+ * @return
+ */
+ function introspect(&$propbag)
+ {
+ global $serendipity;
+
+ $propbag->add('name', PLUGIN_SIDEBAR_WEATHER_NAME);
+ $propbag->add('description', PLUGIN_SIDEBAR_WEATHER_DESC);
+ $propbag->add('configuration', array('title',
+ 'metar',
+ 'timezone',
+ 'units'));
+ } // function
+ /**
+
+ * serendipity_plugin_weather::introspect_config_item()
+ *
+ * @param $name
+ * @param $propbag
+ * @return
+ */
+ function introspect_config_item($name, &$propbag)
+ {
+ switch ($name) {
+ case 'title':
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_SIDEBAR_WEATHER_TITLE);
+ $propbag->add('description', PLUGIN_SIDEBAR_WEATHER_TITLE_BLAHBLAH);
+ break;
+ case 'metar':
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_SIDEBAR_WEATHER_METAR);
+ $propbag->add('description', PLUGIN_SIDEBAR_WEATHER_METAR_BLAHBLAH);
+ break;
+ case 'timezone':
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_SIDEBAR_WEATHER_TIMEZONE);
+ $propbag->add('description', PLUGIN_SIDEBAR_WEATHER_TIMEZONE_BLAHBLAH);
+ break;
+ case 'units':
+ $select = array();
+ $select["metric"] = PLUGIN_SIDEBAR_WEATHER_UNITS_NAME_METRIC;
+ $select["standard"] = PLUGIN_SIDEBAR_WEATHER_UNITS_NAME_IMPERIAL;
+
+ $propbag->add('type', 'select');
+ $propbag->add('name', PLUGIN_SIDEBAR_WEATHER_UNITS);
+ $propbag->add('description', PLUGIN_SIDEBAR_WEATHER_UNITS_BLAHBLAH);
+ $propbag->add('select_values', $select);
+ break;
+ default:
+ return false;
+ } // switch
+ return true;
+ } // function
+ /**
+ * serendipity_plugin_weather::generate_content()
+ *
+ * @param $title
+ * @return
+ */
+ function generate_content(&$title)
+ {
+ global $serendipity;
+
+ $title = $this->get_config('title');
+ $metar_site = $this->get_config('metar','EDDK');
+ $timezone = $this->get_config('timezone',0);
+ $unitString = $this->get_config('units','metric');
+
+ require_once('Services/Weather.php');
+
+ $metar = &Services_Weather::service('METAR', array('debug' => 0));
+ if (Services_Weather::isError($metar)) {
+ die('Error: ' . $metar->getMessage());
+ }
+
+ // Set the unit format for the data
+ $metar->setUnitsFormat($unitString);
+
+ // Set the time/date format
+ // Do we have the date/time format set somewhere in s9y? then we should take this here
+ // $metar->setDateTimeFormat('d.m.Y', 'H:i');
+ // $metar_data->setDateTimeFormat('j M Y', 'H:i');
+
+ $status = $metar->setCache('file', array('cache_dir' => $serendipity['serendipityPath'].'/templates_c'));
+ if (Services_Weather::isError($status)) {
+ echo 'Error: ' . $status->getMessage();
+ }
+
+ switch($unitString)
+ {
+ case "metric":
+ $units = array('wind' => 'km/h',
+ 'vis' => 'km',
+ 'height' => 'km',
+ 'temp' => '°C',
+ 'pres' => 'mb',
+ 'rain' => 'mm');
+ break;
+ case "standard":
+ $units = array('wind' => 'mph',
+ 'vis' => 'mi',
+ 'height' => 'mi',
+ 'temp' => '°F',
+ 'pres' => 'in',
+ 'rain' => 'in');
+ break;
+ }
+
+
+
+ $weather_data = $metar->getWeather($metar_site);
+ if (Services_Weather::isError($weather_data)) {
+ echo 'Error: ' . $weather_data->getMessage();
+ }
+
+ $location_data = $metar->getLocation($metar_site);
+ if (Services_Weather::isError($location_data)) {
+ echo 'Error: ' . $location_data->getMessage();
+ }
+
+ $forecast_data = $metar->getForecast($metar_site);
+ if (Services_Weather::isError($forecast_data)) {
+ echo 'Error: ' . $forecast_data->getMessage();
+ }
+
+ // Do all that icon-stuff
+ // FIXXME: URL-Prefix
+ $windDir = $weather_data["windDirection"];
+ switch ($windDir) {
+ case 'S':
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/sss.png';
+ $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_S;
+ break;
+ case 'SSW':
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/ssw.png';
+ $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_SSW;
+ break;
+ case 'SSE':
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/sse.png';
+ $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_SSE;
+ break;
+ case 'SW':
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/sw.png';
+ $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_SW;
+ break;
+ case 'WSW':
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/sww.png';
+ $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_WSW;
+ break;
+ case 'E':
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/eee.png';
+ $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_E;
+ break;
+ case 'ESE':
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/see.png';
+ $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_ESE;
+ break;
+ case 'ENE':
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/nee.png';
+ $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_ENE;
+ break;
+ case 'N':
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/nnn.png';
+ $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_N;
+ break;
+ case 'NNW':
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/nnw.png';
+ $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_NNW;
+ break;
+ case 'NNE':
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/nne.png';
+ $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_NNE;
+ break;
+ case 'NW':
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/nw.png';
+ $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_NW;
+ break;
+ case 'NE':
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/ne.png';
+ $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_NE;
+ break;
+ case 'SE':
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/se.png';
+ $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_SE;
+ break;
+ case 'W':
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/www.png';
+ $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_W;
+ break;
+ case 'WNW':
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/nww.png';
+ $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_WNW;
+ break;
+ case 'Variable':
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/vrb.gif';
+ $windDir = PLUGIN_SIDEBAR_WEATHER_DATA_V;
+ break;
+ default :
+ $windDirIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/wind_nodata.png';
+ $windDir = "No recorded data.";
+ }
+
+ // Turn the GMT time from the update into a local time
+ $localTime = date('j M Y H:i', strtotime($weather_data['updateRaw']) + (3600*$timezone));
+
+ // Get local hour to determing if it is night
+ $hour = date('H' , strtotime($weather_data['updateRaw']) + (3600*$tz));
+ if ($hour > 18 || $hour < 6) {
+ $night = 'n_';
+ } else {
+ $night = '';
+ }
+
+ // Handle cloud data
+ // We could be dealing with cloud at several levels, so find the heaviest
+ // cover and go with that.
+ $cloudData = $weather_data['clouds'];
+ // See if we are dealing with an array of arrays or some information
+ $cloudKeys = array_keys($cloudData);
+ $testKey = $cloudKeys[0];
+ if (!is_array($cloudData["$testKey"])) {
+ // we have information
+ $amount = $cloudData['amount'];
+ } else {
+ // we have information on several levels - get highest
+ $key = count($cloudKeys)-1;
+ $useArray = $cloudData[$key];
+ $amount = $useArray['amount'];
+ }
+
+ switch ($amount) {
+ case "Clear Below":
+ case "clear sky":
+ case "no significant cloud":
+ case "clear below 12,000 ft":
+ case "vertical visibility":
+ $cloudLevel = "0cloud";
+ break;
+ case "few":
+ case "scattered":
+ $cloudLevel = "1cloud";
+ break;
+ case "Cumulonimbus":
+ $cloudLevel = "2cloud";
+ break;
+ case "Towering Cumulus":
+ case "broken":
+ $cloudLevel = "3cloud";
+ break;
+ case "overcast":
+ $cloudLevel = "4cloud";
+ $night = "";
+ break;
+ default:
+ $cloudLevel = "0cloud";
+ }
+
+ // Determine weather conditions (rain, snow etc);
+ // We need some way to translate this
+ $conditions = $weather_data["condition"];
+
+ switch ($cloudLevel) {
+ case "0cloud":
+ if (strstr($conditions, "fog") !== FALSE) {
+ $condUse = "_fog";
+ } else {
+ $condUse = "";
+ }
+ break;
+ case "1cloud":
+ if (strstr($conditions, "fog") !== FALSE) {
+ $condUse = "_fog";
+ } elseif (strstr($conditions, "rain") !== FALSE && strstr($conditions, "light") !== FALSE) {
+ $condUse = "_lightrain";
+ } elseif (strstr($conditions, "rain") !== FALSE && strstr($conditions, "heavy") !== FALSE) {
+ $condUse = "_heavyrain";
+ } elseif (strstr($conditions, "rain") !== FALSE) {
+ $condUse = "_modrain";
+ } else {
+ $condUse = "_norain";
+ }
+ break;
+ case "2cloud":
+ if (strstr($conditions, "fog") !== FALSE) {
+ $condUse = "_fog";
+ } elseif (strstr($conditions, "rain") !== FALSE && strstr($conditions, "light") !== FALSE) {
+ $condUse = "_lightrain";
+ } elseif (strstr($conditions, "rain") !== FALSE && strstr($conditions, "heavy") !== FALSE) {
+ $condUse = "_heavyrain";
+ } elseif (strstr($conditions, "rain") !== FALSE) {
+ $condUse = "_modrain";
+ } elseif (strstr($conditions, "snow") !== FALSE) {
+ $condUse = "_snow";
+ } elseif (strstr($conditions, "thunderstorm") !== FALSE) {
+ $condUse = "_thunders";
+ } else {
+ $condUse = "_norain";
+ }
+ break;
+ case "3cloud":
+ if (strstr($conditions, "fog") !== FALSE) {
+ $condUse = "_fog";
+ } elseif (strstr($conditions, "rain") !== FALSE && strstr($conditions, "light") !== FALSE) {
+ $condUse = "_lightrain";
+ } elseif (strstr($conditions, "rain") !== FALSE && strstr($conditions, "heavy") !== FALSE) {
+ $condUse = "_heavyrain";
+ } elseif (strstr($conditions, "rain") !== FALSE) {
+ $condUse = "_modrain";
+ } elseif (strstr($conditions, "snow") !== FALSE) {
+ $condUse = "_snow";
+ } elseif (strstr($conditions, "thunderstorm") !== FALSE) {
+ $condUse = "_thunders";
+ } elseif (strstr($conditions, "hail") !== FALSE) {
+ $condUse = "_hail";
+ } else {
+ $condUse = "_norain";
+ }
+ break;
+ case "4cloud":
+ if (strstr($conditions, "fog") !== FALSE) {
+ $condUse = "_fog";
+ } elseif (strstr($conditions, "rain") !== FALSE && strstr($conditions, "light") !== FALSE) {
+ $condUse = "_lightrain";
+ } elseif (strstr($conditions, "rain") !== FALSE && strstr($conditions, "heavy") !== FALSE) {
+ $condUse = "_heavyrain";
+ } elseif (strstr($conditions, "rain") !== FALSE) {
+ $condUse = "_modrain";
+ } elseif (strstr($conditions, "snow") !== FALSE && strstr($conditions, "light") !== FALSE) {
+ $condUse = "_lightsnow";
+ } elseif (strstr($conditions, "snow") !== FALSE && strstr($conditions, "heavy") !== FALSE) {
+ $condUse = "_heavysnow";
+ } elseif (strstr($conditions, "snow") !== FALSE) {
+ $condUse = "_snow";
+ } elseif (strstr($conditions, "thunderstorm") !== FALSE) {
+ $condUse = "_thunders";
+ } elseif (strstr($conditions, "hail") !== FALSE && strstr($conditions, "light") !== FALSE) {
+ $condUse = "_lighthail";
+ } elseif (strstr($conditions, "hail") !== FALSE && strstr($conditions, "heavy") !== FALSE) {
+ $condUse = "_heavyhail";
+ } elseif (strstr($conditions, "hail") !== FALSE) {
+ $condUse = "_hail";
+ } else {
+ $condUse = "_norain";
+ }
+ break;
+ default:
+ $condUse = "_norain";
+ }
+
+ // Construct icon name
+ $conditionIcon = $serendipity['serendipityHTTPPath'] . 'pixel/icons/serendipity_weather_plugin/' . $night . $cloudLevel . $condUse . '.png';
+
+ $content = '';
+
+ $content .= '<img src="' . $conditionIcon . '" alt="" /><br />'. $conditions . '<br />';
+ // FIXXME: Translate the Winddirection
+ $content .= '<dl><dt>'.PLUGIN_SIDEBAR_WEATHER_DATA_WINDDIRECTION.'</dt><dd><img src="' .
+ $windDirIcon . '" alt="" /><dt>' .
+ $windDir . ' at <dd>' . $weather_data["wind"] . ' ' .$units['wind'] . '</dd></dt>';
+
+ $content .= '<dt>'.PLUGIN_SIDEBAR_WEATHER_DATA_TEMPERATURE.'</dt><dd>'.
+ $weather_data["temperature"].' '. $units['temp'].'</dd>';
+ $content .= '<dt>'.PLUGIN_SIDEBAR_WEATHER_DATA_FELT_TEMPERATURE.'</dt><dd>'.
+ $weather_data["feltTemperature"].' '. $units['temp'] .'</dd>';
+ $content .= '<dt>'.PLUGIN_SIDEBAR_WEATHER_DATA_HUMIDITY.'</dt><dd>' .
+ $weather_data["humidity"] .' '. '%</dd>';
+ $content .= '<dt>'.PLUGIN_SIDEBAR_WEATHER_DATA_PRESSURE.'</dt><dd>' .
+ $weather_data['pressure'] .' '. $units['pres'].'</dd>';
+ $content .= '<dt>'.PLUGIN_SIDEBAR_WEATHER_DATA_VISIBILITY.'</dt><dd>' .
+ $weather_data["visibility"] .' '. $units['vis'] . '</dd>';
+ $content .= '<dt>'.PLUGIN_SIDEBAR_WEATHER_DATA_UPDATE.'</dt><dd>' .
+ $localTime . '</dd></dl>';
+
+ echo $content;
+ } // function
+} // class
+
+?>
+
|