| 1 |
<?php
|
| 2 |
// $Id: wunderground.module,v 1.9 2008/11/09 00:22:23 ppicazo Exp $
|
| 3 |
|
| 4 |
|
| 5 |
/**
|
| 6 |
* Display help and module information
|
| 7 |
* @param path which path of the site we're displaying help
|
| 8 |
* @param arg array that holds the current path as would be returned from arg() function
|
| 9 |
* @return help text for the path
|
| 10 |
*/
|
| 11 |
function wunderground_help($path, $arg) {
|
| 12 |
$output = '';
|
| 13 |
switch ($path) {
|
| 14 |
case "admin/help#wunderground":
|
| 15 |
$output = '<p>'. t("Displays weather information from Weather Underground weather stations (Personal or Airport Stations.") .'</p>';
|
| 16 |
break;
|
| 17 |
}
|
| 18 |
return $output;
|
| 19 |
} // function wunderground_help
|
| 20 |
|
| 21 |
|
| 22 |
/**
|
| 23 |
* Valid permissions for this module
|
| 24 |
* @return array An array of valid permissions for the wunderground module
|
| 25 |
*/
|
| 26 |
function wunderground_perm() {
|
| 27 |
return array('access wunderground content', 'access administration pages');
|
| 28 |
} // function wunderground_perm()
|
| 29 |
|
| 30 |
|
| 31 |
/**
|
| 32 |
* Generate HTML for the wunderground block
|
| 33 |
* @param op the operation from the URL
|
| 34 |
* @param delta offset
|
| 35 |
* @returns block HTML
|
| 36 |
*/
|
| 37 |
function wunderground_block($op = 'list', $delta = 0) {
|
| 38 |
// listing of blocks, such as on the admin/block page
|
| 39 |
if ($op == "list") {
|
| 40 |
$block[0]["info"] = t('Wunderground!');
|
| 41 |
return $block;
|
| 42 |
}
|
| 43 |
else if ($op == 'view') {
|
| 44 |
// our block content
|
| 45 |
// content variable that will be returned for display
|
| 46 |
$block_content = '';
|
| 47 |
|
| 48 |
// get the station identifier from the module's settings
|
| 49 |
$station_id = variable_get('wunderground_stationid', "KCALIVER14");
|
| 50 |
|
| 51 |
// get the station country string from the module's settings
|
| 52 |
$station_country_string = trim(variable_get('wunderground_country', ""));
|
| 53 |
if (strlen($station_country_string) > 0) {
|
| 54 |
$station_country_string = ", " . $station_country_string;
|
| 55 |
}
|
| 56 |
|
| 57 |
// append the station identifier to the end of the xml feed URLs
|
| 58 |
if(strlen($station_id) <= 4) {
|
| 59 |
$station_feed_url = "http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=$station_id";
|
| 60 |
}
|
| 61 |
else {
|
| 62 |
$station_feed_url = "http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=$station_id";
|
| 63 |
}
|
| 64 |
|
| 65 |
// weather data stored as simpleXML object in this variable
|
| 66 |
$w_xml = '';
|
| 67 |
|
| 68 |
// check to see if our cache exists
|
| 69 |
// if it doesn't exist or has expired we will update the cache
|
| 70 |
// if the cache is usable it is already stored in a variable and we skip the cache update
|
| 71 |
if ((!$xml_cache = cache_get('wunderground')) || ($xml_cache->expire < time())) {
|
| 72 |
|
| 73 |
// fetch the XML from Weather Underground
|
| 74 |
$response = drupal_http_request($station_feed_url);
|
| 75 |
|
| 76 |
// if there was an error handle it
|
| 77 |
if ($response->code != 200) {
|
| 78 |
if (variable_get('wunderground_error_handling', 0)) {
|
| 79 |
$block_content = "Weather Not Available";
|
| 80 |
}
|
| 81 |
else {
|
| 82 |
return;
|
| 83 |
}
|
| 84 |
}
|
| 85 |
|
| 86 |
// store the xml text in a variable
|
| 87 |
$xml = $response->data;
|
| 88 |
$xml = str_replace("%</relative_humidity>", "</relative_humidity>", $xml); // needed when using airport data
|
| 89 |
|
| 90 |
// get the caching interval (in minutes) from the module's settings
|
| 91 |
$interval = variable_get('wunderground_cachetime', 1);
|
| 92 |
|
| 93 |
// update the cache with the new data
|
| 94 |
cache_set('wunderground', $xml, 'cache', time() + ($interval*60));
|
| 95 |
|
| 96 |
// use xml text to make a simpleXML object
|
| 97 |
$w_xml = simplexml_load_string($xml);
|
| 98 |
}
|
| 99 |
else {
|
| 100 |
|
| 101 |
// use the cached xml text to make a simpleXML object
|
| 102 |
$w_xml = simplexml_load_string($xml_cache->data);
|
| 103 |
}
|
| 104 |
|
| 105 |
// if there is no station identifier in the xml, which happens when errors occur or no
|
| 106 |
// station with that ID exists, handle the error
|
| 107 |
if ($w_xml->station_id == '') {
|
| 108 |
if (variable_get('wunderground_error_handling', 0)) {
|
| 109 |
$block_content = "Weather Not Available";
|
| 110 |
}
|
| 111 |
else {
|
| 112 |
return;
|
| 113 |
}
|
| 114 |
}
|
| 115 |
|
| 116 |
// in some cases the xml feed from weather underground will report erroneous information
|
| 117 |
// this occurs at least in the case when only partial weather data is sent from
|
| 118 |
// a davis weather station (ie no temperature, but pressure). even on the
|
| 119 |
// weather underground page shows the extreme values. requires more research.
|
| 120 |
if ($w_xml->temp_f == -3276.8) {
|
| 121 |
if (variable_get('wunderground_error_handling', 0)) {
|
| 122 |
$block_content = "Weather Information Invalid";
|
| 123 |
}
|
| 124 |
else {
|
| 125 |
return;
|
| 126 |
}
|
| 127 |
}
|
| 128 |
else {
|
| 129 |
|
| 130 |
// generate the table and place static (not handled in unit conversion javascript) variables
|
| 131 |
|
| 132 |
$block_content .= "<table style=\"Font-Size:10px\">";
|
| 133 |
|
| 134 |
$display_fields = variable_get('wunderground_display_fields', array('location', 'updated', 'temp', 'pressure', 'dewpoint', 'humidity', 'wind', 'gusts'));
|
| 135 |
|
| 136 |
// when using checkboxes we have to cast the variable as a string?
|
| 137 |
if ((string)$display_fields['location'] == 'location') {
|
| 138 |
if(strlen($station_id) <= 4) {
|
| 139 |
$block_content .= "<tr><td valign=\"top\">Location:</td><td>". $w_xml->observation_location->city .", ". $w_xml->observation_location->state . $station_country_string . "</td></tr>";
|
| 140 |
}
|
| 141 |
else {
|
| 142 |
$block_content .= "<tr><td valign=\"top\">Location:</td><td>". $w_xml->location->city .", ". $w_xml->location->state . $station_country_string . "</td></tr>";
|
| 143 |
}
|
| 144 |
}
|
| 145 |
|
| 146 |
$default_timezone = date_default_timezone_get();
|
| 147 |
$timezones_list = wunderground_get_timezones();
|
| 148 |
date_default_timezone_set($timezones_list[variable_get('wunderground_timezone', date_default_timezone_get())]);
|
| 149 |
|
| 150 |
if ((string)$display_fields['updated'] == 'updated') {
|
| 151 |
$block_content .= "<tr><td>Updated:</td><td>". date("d M H:i T", strtotime("$w_xml->observation_time_rfc822")) ."</td></tr>";
|
| 152 |
}
|
| 153 |
|
| 154 |
date_default_timezone_set($default_timezone);
|
| 155 |
|
| 156 |
$humidity = ($w_xml->relative_humidity ? $w_xml->relative_humidity : 'null');
|
| 157 |
$precip = ($w_xml->precip_today_in ? $w_xml->precip_today_in : 'null');
|
| 158 |
$tempf = ($w_xml->temp_f ? $w_xml->temp_f : 'null');
|
| 159 |
$pressurein = ($w_xml->pressure_in ? $w_xml->pressure_in : 'null');
|
| 160 |
$dewpointf = ($w_xml->dewpoint_f ? $w_xml->dewpoint_f : 'null');
|
| 161 |
$windmph = ($w_xml->wind_mph ? $w_xml->wind_mph : 'null');
|
| 162 |
$winddir = ($w_xml->wind_dir ? $w_xml->wind_dir : 'null');
|
| 163 |
$gustmph = (strlen($w_xml->wind_gust_mph) ? $w_xml->wind_gust_mph : 'null');
|
| 164 |
|
| 165 |
if ((string)$display_fields['temp'] == 'temp' && $tempf != 'null') {
|
| 166 |
$block_content .= "<tr><td>Temp:</td><td id=\"temp\"></td></tr>";
|
| 167 |
}
|
| 168 |
if ((string)$display_fields['pressure'] == 'pressure' && $pressurein != 'null') {
|
| 169 |
$block_content .= "<tr><td>Pressure:</td><td id=\"pressure\"></td></tr>";
|
| 170 |
}
|
| 171 |
if ((string)$display_fields['dewpoint'] == 'dewpoint' && $dewpointf != 'null') {
|
| 172 |
$block_content .= "<tr><td>Dewpoint:</td><td id=\"dewpoint\"></td></tr>";
|
| 173 |
}
|
| 174 |
if ((string)$display_fields['humidity'] == 'humidity' && $humidity != 'null') {
|
| 175 |
$block_content .= "<tr><td>Humidity:</td><td>". $humidity ."%</td></tr>";
|
| 176 |
}
|
| 177 |
if ((string)$display_fields['wind'] == 'wind' && $windmph != 'null') {
|
| 178 |
$block_content .= "<tr><td>Wind:</td><td id=\"wind\"></td></tr>";
|
| 179 |
}
|
| 180 |
if ((string)$display_fields['gusts'] == 'gusts' && $gustmph != 'null') {
|
| 181 |
$block_content .= "<tr><td>Gusts:</td><td id=\"gusts\"></td></tr>";
|
| 182 |
}
|
| 183 |
if ((string)$display_fields['precip'] == 'precip' && $precip > 0 && $precip != 'null') {
|
| 184 |
$block_content .= "<tr><td>Precipitation:</td><td id=\"precip\"></td></tr>";
|
| 185 |
}
|
| 186 |
$block_content .= "</table>";
|
| 187 |
|
| 188 |
$block_content .= "<span style=\"Font-Size:10px\"><a href=\"#\" onclick=\"wunderground_English();\">English</a></span> | ";
|
| 189 |
$block_content .= "<span style=\"Font-Size:10px\"><a href=\"#\" onclick=\"wunderground_Metric();\">Metric</a></span>";
|
| 190 |
|
| 191 |
// check module settings to see if the details link should be displayed
|
| 192 |
$misc_options = variable_get('wunderground_misc_options', array('details_link'));
|
| 193 |
|
| 194 |
// when using checkboxes we have to cast the variable as a string?
|
| 195 |
if ((string)$misc_options['details_link'] == 'details_link') {
|
| 196 |
$block_content .= " | <span style=\"Font-Size:10px\"><a href=\"" . url("wunderground") . "\">Details...</a></span>";
|
| 197 |
}
|
| 198 |
|
| 199 |
}
|
| 200 |
|
| 201 |
// get the default units to display from the module's settings
|
| 202 |
if (variable_get('wunderground_units', 0)) { // value of zero is metric
|
| 203 |
$units = "Metric";
|
| 204 |
}
|
| 205 |
else {
|
| 206 |
$units = "English";
|
| 207 |
}
|
| 208 |
|
| 209 |
// add the javascript with the weather variables
|
| 210 |
$block_content .= "<script type=\"text/javascript\">";
|
| 211 |
$block_content .= "var temp_f = ". $tempf .";";
|
| 212 |
$block_content .= "var pressure_in = ". $pressurein .";";
|
| 213 |
$block_content .= "var dewpoint_f = ". $dewpointf .";";
|
| 214 |
$block_content .= "var wind_mph = ". $windmph .";";
|
| 215 |
$block_content .= "var wind_gust_mph = ". $gustmph .";";
|
| 216 |
$block_content .= "var wind_dir = '". $winddir ."';";
|
| 217 |
$block_content .= "var precip_in = '". $precip ."';";
|
| 218 |
$block_content .= "var units = '". $units ."';";
|
| 219 |
$block_content .= "</script>";
|
| 220 |
|
| 221 |
// add the static wunderground javascript file
|
| 222 |
drupal_add_js(drupal_get_path('module', 'wunderground') .'/wunderground.js', 'module', 'footer');
|
| 223 |
|
| 224 |
// set up the block
|
| 225 |
$block['subject'] = variable_get('wunderground_block_subject', 'My Weather');
|
| 226 |
$block['content'] = $block_content;
|
| 227 |
return $block;
|
| 228 |
|
| 229 |
}
|
| 230 |
} // end function wunderground_block
|
| 231 |
|
| 232 |
/**
|
| 233 |
* Generate HTML for the wunderground page
|
| 234 |
* @returns block HTML
|
| 235 |
*/
|
| 236 |
function wunderground_all() {
|
| 237 |
$page_content = '';
|
| 238 |
|
| 239 |
$station_id = variable_get('wunderground_stationid', "KCALIVER14");
|
| 240 |
|
| 241 |
$page_content .= "<br><div align=\"center\"><object width=\"600\" height=\"400\"><param name=\"movie\" value=\"http://www.wunderground.com/swf/Rapid_Fire.swf?units=both&station=$station_id\"></param><embed src=\"http://www.wunderground.com/swf/Rapid_Fire.swf?units=both&station=$station_id\" type=\"application/x-shockwave-flash\" width=\"600\" height=\"400\"></embed></object><br><br><a href=\"http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=$station_id\">Station: $station_id on Weather Underground</a></div>";
|
| 242 |
|
| 243 |
return $page_content;
|
| 244 |
}
|
| 245 |
|
| 246 |
|
| 247 |
function wunderground_get_timezones() {
|
| 248 |
|
| 249 |
if (function_exists(timezone_identifiers_list)) {
|
| 250 |
$zones_list = timezone_identifiers_list();
|
| 251 |
}
|
| 252 |
elseif (function_exists(date_default_timezone_get)) {
|
| 253 |
$zones_list = array(
|
| 254 |
date_default_timezone_get(),
|
| 255 |
"Africa/Abidjan",
|
| 256 |
"Africa/Accra",
|
| 257 |
"Africa/Addis_Ababa",
|
| 258 |
"Africa/Algiers",
|
| 259 |
"Africa/Asmara",
|
| 260 |
"Africa/Asmera",
|
| 261 |
"Africa/Bamako",
|
| 262 |
"Africa/Bangui",
|
| 263 |
"Africa/Banjul",
|
| 264 |
"Africa/Bissau",
|
| 265 |
"Africa/Blantyre",
|
| 266 |
"Africa/Brazzaville",
|
| 267 |
"Africa/Bujumbura",
|
| 268 |
"Africa/Cairo",
|
| 269 |
"Africa/Casablanca",
|
| 270 |
"Africa/Ceuta",
|
| 271 |
"Africa/Conakry",
|
| 272 |
"Africa/Dakar",
|
| 273 |
"Africa/Dar_es_Salaam",
|
| 274 |
"Africa/Djibouti",
|
| 275 |
"Africa/Douala",
|
| 276 |
"Africa/El_Aaiun",
|
| 277 |
"Africa/Freetown",
|
| 278 |
"Africa/Gaborone",
|
| 279 |
"Africa/Harare",
|
| 280 |
"Africa/Johannesburg",
|
| 281 |
"Africa/Kampala",
|
| 282 |
"Africa/Khartoum",
|
| 283 |
"Africa/Kigali",
|
| 284 |
"Africa/Kinshasa",
|
| 285 |
"Africa/Lagos",
|
| 286 |
"Africa/Libreville",
|
| 287 |
"Africa/Lome",
|
| 288 |
"Africa/Luanda",
|
| 289 |
"Africa/Lubumbashi",
|
| 290 |
"Africa/Lusaka",
|
| 291 |
"Africa/Malabo",
|
| 292 |
"Africa/Maputo",
|
| 293 |
"Africa/Maseru",
|
| 294 |
"Africa/Mbabane",
|
| 295 |
"Africa/Mogadishu",
|
| 296 |
"Africa/Monrovia",
|
| 297 |
"Africa/Nairobi",
|
| 298 |
"Africa/Ndjamena",
|
| 299 |
"Africa/Niamey",
|
| 300 |
"Africa/Nouakchott",
|
| 301 |
"Africa/Ouagadougou",
|
| 302 |
"Africa/Porto-Novo",
|
| 303 |
"Africa/Sao_Tome",
|
| 304 |
"Africa/Timbuktu",
|
| 305 |
"Africa/Tripoli",
|
| 306 |
"Africa/Tunis",
|
| 307 |
"Africa/Windhoek",
|
| 308 |
"America/Adak",
|
| 309 |
"America/Anchorage",
|
| 310 |
"America/Anguilla",
|
| 311 |
"America/Antigua",
|
| 312 |
"America/Araguaina",
|
| 313 |
"America/Argentina/Buenos_Aires",
|
| 314 |
"America/Argentina/Catamarca",
|
| 315 |
"America/Argentina/ComodRivadavia",
|
| 316 |
"America/Argentina/Cordoba",
|
| 317 |
"America/Argentina/Jujuy",
|
| 318 |
"America/Argentina/La_Rioja",
|
| 319 |
"America/Argentina/Mendoza",
|
| 320 |
"America/Argentina/Rio_Gallegos",
|
| 321 |
"America/Argentina/Salta",
|
| 322 |
"America/Argentina/San_Juan",
|
| 323 |
"America/Argentina/San_Luis",
|
| 324 |
"America/Argentina/Tucuman",
|
| 325 |
"America/Argentina/Ushuaia",
|
| 326 |
"America/Aruba",
|
| 327 |
"America/Asuncion",
|
| 328 |
"America/Atikokan",
|
| 329 |
"America/Atka",
|
| 330 |
"America/Bahia",
|
| 331 |
"America/Barbados",
|
| 332 |
"America/Belem",
|
| 333 |
"America/Belize",
|
| 334 |
"America/Blanc-Sablon",
|
| 335 |
"America/Boa_Vista",
|
| 336 |
"America/Bogota",
|
| 337 |
"America/Boise",
|
| 338 |
"America/Buenos_Aires",
|
| 339 |
"America/Cambridge_Bay",
|
| 340 |
"America/Campo_Grande",
|
| 341 |
"America/Cancun",
|
| 342 |
"America/Caracas",
|
| 343 |
"America/Catamarca",
|
| 344 |
"America/Cayenne",
|
| 345 |
"America/Cayman",
|
| 346 |
"America/Chicago",
|
| 347 |
"America/Chihuahua",
|
| 348 |
"America/Coral_Harbour",
|
| 349 |
"America/Cordoba",
|
| 350 |
"America/Costa_Rica",
|
| 351 |
"America/Cuiaba",
|
| 352 |
"America/Curacao",
|
| 353 |
"America/Danmarkshavn",
|
| 354 |
"America/Dawson",
|
| 355 |
"America/Dawson_Creek",
|
| 356 |
"America/Denver",
|
| 357 |
"America/Detroit",
|
| 358 |
"America/Dominica",
|
| 359 |
"America/Edmonton",
|
| 360 |
"America/Eirunepe",
|
| 361 |
"America/El_Salvador",
|
| 362 |
"America/Ensenada",
|
| 363 |
"America/Fort_Wayne",
|
| 364 |
"America/Fortaleza",
|
| 365 |
"America/Glace_Bay",
|
| 366 |
"America/Godthab",
|
| 367 |
"America/Goose_Bay",
|
| 368 |
"America/Grand_Turk",
|
| 369 |
"America/Grenada",
|
| 370 |
"America/Guadeloupe",
|
| 371 |
"America/Guatemala",
|
| 372 |
"America/Guayaquil",
|
| 373 |
"America/Guyana",
|
| 374 |
"America/Halifax",
|
| 375 |
"America/Havana",
|
| 376 |
"America/Hermosillo",
|
| 377 |
"America/Indiana/Indianapolis",
|
| 378 |
"America/Indiana/Knox",
|
| 379 |
"America/Indiana/Marengo",
|
| 380 |
"America/Indiana/Petersburg",
|
| 381 |
"America/Indiana/Tell_City",
|
| 382 |
"America/Indiana/Vevay",
|
| 383 |
"America/Indiana/Vincennes",
|
| 384 |
"America/Indiana/Winamac",
|
| 385 |
"America/Indianapolis",
|
| 386 |
"America/Inuvik",
|
| 387 |
"America/Iqaluit",
|
| 388 |
"America/Jamaica",
|
| 389 |
"America/Jujuy",
|
| 390 |
"America/Juneau",
|
| 391 |
"America/Kentucky/Louisville",
|
| 392 |
"America/Kentucky/Monticello",
|
| 393 |
"America/Knox_IN",
|
| 394 |
"America/La_Paz",
|
| 395 |
"America/Lima",
|
| 396 |
"America/Los_Angeles",
|
| 397 |
"America/Louisville",
|
| 398 |
"America/Maceio",
|
| 399 |
"America/Managua",
|
| 400 |
"America/Manaus",
|
| 401 |
"America/Marigot",
|
| 402 |
"America/Martinique",
|
| 403 |
"America/Mazatlan",
|
| 404 |
"America/Mendoza",
|
| 405 |
"America/Menominee",
|
| 406 |
"America/Merida",
|
| 407 |
"America/Mexico_City",
|
| 408 |
"America/Miquelon",
|
| 409 |
"America/Moncton",
|
| 410 |
"America/Monterrey",
|
| 411 |
"America/Montevideo",
|
| 412 |
"America/Montreal",
|
| 413 |
"America/Montserrat",
|
| 414 |
"America/Nassau",
|
| 415 |
"America/New_York",
|
| 416 |
"America/Nipigon",
|
| 417 |
"America/Nome",
|
| 418 |
"America/Noronha",
|
| 419 |
"America/North_Dakota/Center",
|
| 420 |
"America/North_Dakota/New_Salem",
|
| 421 |
"America/Panama",
|
| 422 |
"America/Pangnirtung",
|
| 423 |
"America/Paramaribo",
|
| 424 |
"America/Phoenix",
|
| 425 |
"America/Port-au-Prince",
|
| 426 |
"America/Port_of_Spain",
|
| 427 |
"America/Porto_Acre",
|
| 428 |
"America/Porto_Velho",
|
| 429 |
"America/Puerto_Rico",
|
| 430 |
"America/Rainy_River",
|
| 431 |
"America/Rankin_Inlet",
|
| 432 |
"America/Recife",
|
| 433 |
"America/Regina",
|
| 434 |
"America/Resolute",
|
| 435 |
"America/Rio_Branco",
|
| 436 |
"America/Rosario",
|
| 437 |
"America/Santarem",
|
| 438 |
"America/Santiago",
|
| 439 |
"America/Santo_Domingo",
|
| 440 |
"America/Sao_Paulo",
|
| 441 |
"America/Scoresbysund",
|
| 442 |
"America/Shiprock",
|
| 443 |
"America/St_Barthelemy",
|
| 444 |
"America/St_Johns",
|
| 445 |
"America/St_Kitts",
|
| 446 |
"America/St_Lucia",
|
| 447 |
"America/St_Thomas",
|
| 448 |
"America/St_Vincent",
|
| 449 |
"America/Swift_Current",
|
| 450 |
"America/Tegucigalpa",
|
| 451 |
"America/Thule",
|
| 452 |
"America/Thunder_Bay",
|
| 453 |
"America/Tijuana",
|
| 454 |
"America/Toronto",
|
| 455 |
"America/Tortola",
|
| 456 |
"America/Vancouver",
|
| 457 |
"America/Virgin",
|
| 458 |
"America/Whitehorse",
|
| 459 |
"America/Winnipeg",
|
| 460 |
"America/Yakutat",
|
| 461 |
"America/Yellowknife",
|
| 462 |
"Antarctica/Casey",
|
| 463 |
"Antarctica/Davis",
|
| 464 |
"Antarctica/DumontDUrville",
|
| 465 |
"Antarctica/Mawson",
|
| 466 |
"Antarctica/McMurdo",
|
| 467 |
"Antarctica/Palmer",
|
| 468 |
"Antarctica/Rothera",
|
| 469 |
"Antarctica/South_Pole",
|
| 470 |
"Antarctica/Syowa",
|
| 471 |
"Antarctica/Vostok",
|
| 472 |
"Arctic/Longyearbyen",
|
| 473 |
"Asia/Aden",
|
| 474 |
"Asia/Almaty",
|
| 475 |
"Asia/Amman",
|
| 476 |
"Asia/Anadyr",
|
| 477 |
"Asia/Aqtau",
|
| 478 |
"Asia/Aqtobe",
|
| 479 |
"Asia/Ashgabat",
|
| 480 |
"Asia/Ashkhabad",
|
| 481 |
"Asia/Baghdad",
|
| 482 |
"Asia/Bahrain",
|
| 483 |
"Asia/Baku",
|
| 484 |
"Asia/Bangkok",
|
| 485 |
"Asia/Beirut",
|
| 486 |
"Asia/Bishkek",
|
| 487 |
"Asia/Brunei",
|
| 488 |
"Asia/Calcutta",
|
| 489 |
"Asia/Choibalsan",
|
| 490 |
"Asia/Chongqing",
|
| 491 |
"Asia/Chungking",
|
| 492 |
"Asia/Colombo",
|
| 493 |
"Asia/Dacca",
|
| 494 |
"Asia/Damascus",
|
| 495 |
"Asia/Dhaka",
|
| 496 |
"Asia/Dili",
|
| 497 |
"Asia/Dubai",
|
| 498 |
"Asia/Dushanbe",
|
| 499 |
"Asia/Gaza",
|
| 500 |
"Asia/Harbin",
|
| 501 |
"Asia/Ho_Chi_Minh",
|
| 502 |
"Asia/Hong_Kong",
|
| 503 |
"Asia/Hovd",
|
| 504 |
"Asia/Irkutsk",
|
| 505 |
"Asia/Istanbul",
|
| 506 |
"Asia/Jakarta",
|
| 507 |
"Asia/Jayapura",
|
| 508 |
"Asia/Jerusalem",
|
| 509 |
"Asia/Kabul",
|
| 510 |
"Asia/Kamchatka",
|
| 511 |
"Asia/Karachi",
|
| 512 |
"Asia/Kashgar",
|
| 513 |
"Asia/Kathmandu",
|
| 514 |
"Asia/Katmandu",
|
| 515 |
"Asia/Kolkata",
|
| 516 |
"Asia/Krasnoyarsk",
|
| 517 |
"Asia/Kuala_Lumpur",
|
| 518 |
"Asia/Kuching",
|
| 519 |
"Asia/Kuwait",
|
| 520 |
"Asia/Macao",
|
| 521 |
"Asia/Macau",
|
| 522 |
"Asia/Magadan",
|
| 523 |
"Asia/Makassar",
|
| 524 |
"Asia/Manila",
|
| 525 |
"Asia/Muscat",
|
| 526 |
"Asia/Nicosia",
|
| 527 |
"Asia/Novosibirsk",
|
| 528 |
"Asia/Omsk",
|
| 529 |
"Asia/Oral",
|
| 530 |
"Asia/Phnom_Penh",
|
| 531 |
"Asia/Pontianak",
|
| 532 |
"Asia/Pyongyang",
|
| 533 |
"Asia/Qatar",
|
| 534 |
"Asia/Qyzylorda",
|
| 535 |
"Asia/Rangoon",
|
| 536 |
"Asia/Riyadh",
|
| 537 |
"Asia/Saigon",
|
| 538 |
"Asia/Sakhalin",
|
| 539 |
"Asia/Samarkand",
|
| 540 |
"Asia/Seoul",
|
| 541 |
"Asia/Shanghai",
|
| 542 |
"Asia/Singapore",
|
| 543 |
"Asia/Taipei",
|
| 544 |
"Asia/Tashkent",
|
| 545 |
"Asia/Tbilisi",
|
| 546 |
"Asia/Tehran",
|
| 547 |
"Asia/Tel_Aviv",
|
| 548 |
"Asia/Thimbu",
|
| 549 |
"Asia/Thimphu",
|
| 550 |
"Asia/Tokyo",
|
| 551 |
"Asia/Ujung_Pandang",
|
| 552 |
"Asia/Ulaanbaatar",
|
| 553 |
"Asia/Ulan_Bator",
|
| 554 |
"Asia/Urumqi",
|
| 555 |
"Asia/Vientiane",
|
| 556 |
"Asia/Vladivostok",
|
| 557 |
"Asia/Yakutsk",
|
| 558 |
"Asia/Yekaterinburg",
|
| 559 |
"Asia/Yerevan",
|
| 560 |
"Atlantic/Azores",
|
| 561 |
"Atlantic/Bermuda",
|
| 562 |
"Atlantic/Canary",
|
| 563 |
"Atlantic/Cape_Verde",
|
| 564 |
"Atlantic/Faeroe",
|
| 565 |
"Atlantic/Faroe",
|
| 566 |
"Atlantic/Jan_Mayen",
|
| 567 |
"Atlantic/Madeira",
|
| 568 |
"Atlantic/Reykjavik",
|
| 569 |
"Atlantic/South_Georgia",
|
| 570 |
"Atlantic/St_Helena",
|
| 571 |
"Atlantic/Stanley",
|
| 572 |
"Australia/ACT",
|
| 573 |
"Australia/Adelaide",
|
| 574 |
"Australia/Brisbane",
|
| 575 |
"Australia/Broken_Hill",
|
| 576 |
"Australia/Canberra",
|
| 577 |
"Australia/Currie",
|
| 578 |
"Australia/Darwin",
|
| 579 |
"Australia/Eucla",
|
| 580 |
"Australia/Hobart",
|
| 581 |
"Australia/LHI",
|
| 582 |
"Australia/Lindeman",
|
| 583 |
"Australia/Lord_Howe",
|
| 584 |
"Australia/Melbourne",
|
| 585 |
"Australia/North",
|
| 586 |
"Australia/NSW",
|
| 587 |
"Australia/Perth",
|
| 588 |
"Australia/Queensland",
|
| 589 |
"Australia/South",
|
| 590 |
"Australia/Sydney",
|
| 591 |
"Australia/Tasmania",
|
| 592 |
"Australia/Victoria",
|
| 593 |
"Australia/West",
|
| 594 |
"Australia/Yancowinna",
|
| 595 |
"Brazil/Acre",
|
| 596 |
"Brazil/DeNoronha",
|
| 597 |
"Brazil/East",
|
| 598 |
"Brazil/West",
|
| 599 |
"Canada/Atlantic",
|
| 600 |
"Canada/Central",
|
| 601 |
"Canada/East-Saskatchewan",
|
| 602 |
"Canada/Eastern",
|
| 603 |
"Canada/Mountain",
|
| 604 |
"Canada/Newfoundland",
|
| 605 |
"Canada/Pacific",
|
| 606 |
"Canada/Saskatchewan",
|
| 607 |
"Canada/Yukon",
|
| 608 |
"CET",
|
| 609 |
"Chile/Continental",
|
| 610 |
"Chile/EasterIsland",
|
| 611 |
"CST6CDT",
|
| 612 |
"Cuba",
|
| 613 |
"EET",
|
| 614 |
"Egypt",
|
| 615 |
"Eire",
|
| 616 |
"EST",
|
| 617 |
"EST5EDT",
|
| 618 |
"Etc/GMT",
|
| 619 |
"Etc/GMT+0",
|
| 620 |
"Etc/GMT+1",
|
| 621 |
"Etc/GMT+10",
|
| 622 |
"Etc/GMT+11",
|
| 623 |
"Etc/GMT+12",
|
| 624 |
"Etc/GMT+2",
|
| 625 |
"Etc/GMT+3",
|
| 626 |
"Etc/GMT+4",
|
| 627 |
"Etc/GMT+5",
|
| 628 |
"Etc/GMT+6",
|
| 629 |
"Etc/GMT+7",
|
| 630 |
"Etc/GMT+8",
|
| 631 |
"Etc/GMT+9",
|
| 632 |
"Etc/GMT-0",
|
| 633 |
"Etc/GMT-1",
|
| 634 |
"Etc/GMT-10",
|
| 635 |
"Etc/GMT-11",
|
| 636 |
"Etc/GMT-12",
|
| 637 |
"Etc/GMT-13",
|
| 638 |
"Etc/GMT-14",
|
| 639 |
"Etc/GMT-2",
|
| 640 |
"Etc/GMT-3",
|
| 641 |
"Etc/GMT-4",
|
| 642 |
"Etc/GMT-5",
|
| 643 |
"Etc/GMT-6",
|
| 644 |
"Etc/GMT-7",
|
| 645 |
"Etc/GMT-8",
|
| 646 |
"Etc/GMT-9",
|
| 647 |
"Etc/GMT0",
|
| 648 |
"Etc/Greenwich",
|
| 649 |
"Etc/UCT",
|
| 650 |
"Etc/Universal",
|
| 651 |
"Etc/UTC",
|
| 652 |
"Etc/Zulu",
|
| 653 |
"Europe/Amsterdam",
|
| 654 |
"Europe/Andorra",
|
| 655 |
"Europe/Athens",
|
| 656 |
"Europe/Belfast",
|
| 657 |
"Europe/Belgrade",
|
| 658 |
"Europe/Berlin",
|
| 659 |
"Europe/Bratislava",
|
| 660 |
"Europe/Brussels",
|
| 661 |
"Europe/Bucharest",
|
| 662 |
"Europe/Budapest",
|
| 663 |
"Europe/Chisinau",
|
| 664 |
"Europe/Copenhagen",
|
| 665 |
"Europe/Dublin",
|
| 666 |
"Europe/Gibraltar",
|
| 667 |
"Europe/Guernsey",
|
| 668 |
"Europe/Helsinki",
|
| 669 |
"Europe/Isle_of_Man",
|
| 670 |
"Europe/Istanbul",
|
| 671 |
"Europe/Jersey",
|
| 672 |
"Europe/Kaliningrad",
|
| 673 |
"Europe/Kiev",
|
| 674 |
"Europe/Lisbon",
|
| 675 |
"Europe/Ljubljana",
|
| 676 |
"Europe/London",
|
| 677 |
"Europe/Luxembourg",
|
| 678 |
"Europe/Madrid",
|
| 679 |
"Europe/Malta",
|
| 680 |
"Europe/Mariehamn",
|
| 681 |
"Europe/Minsk",
|
| 682 |
"Europe/Monaco",
|
| 683 |
"Europe/Moscow",
|
| 684 |
"Europe/Nicosia",
|
| 685 |
"Europe/Oslo",
|
| 686 |
"Europe/Paris",
|
| 687 |
"Europe/Podgorica",
|
| 688 |
"Europe/Prague",
|
| 689 |
"Europe/Riga",
|
| 690 |
"Europe/Rome",
|
| 691 |
"Europe/Samara",
|
| 692 |
"Europe/San_Marino",
|
| 693 |
"Europe/Sarajevo",
|
| 694 |
"Europe/Simferopol",
|
| 695 |
"Europe/Skopje",
|
| 696 |
"Europe/Sofia",
|
| 697 |
"Europe/Stockholm",
|
| 698 |
"Europe/Tallinn",
|
| 699 |
"Europe/Tirane",
|
| 700 |
"Europe/Tiraspol",
|
| 701 |
"Europe/Uzhgorod",
|
| 702 |
"Europe/Vaduz",
|
| 703 |
"Europe/Vatican",
|
| 704 |
"Europe/Vienna",
|
| 705 |
"Europe/Vilnius",
|
| 706 |
"Europe/Volgograd",
|
| 707 |
"Europe/Warsaw",
|
| 708 |
"Europe/Zagreb",
|
| 709 |
"Europe/Zaporozhye",
|
| 710 |
"Europe/Zurich",
|
| 711 |
"Factory",
|
| 712 |
"GB",
|
| 713 |
"GB-Eire",
|
| 714 |
"GMT",
|
| 715 |
"GMT+0",
|
| 716 |
"GMT-0",
|
| 717 |
"GMT0",
|
| 718 |
"Greenwich",
|
| 719 |
"Hongkong",
|
| 720 |
"HST",
|
| 721 |
"Iceland",
|
| 722 |
"Indian/Antananarivo",
|
| 723 |
"Indian/Chagos",
|
| 724 |
"Indian/Christmas",
|
| 725 |
"Indian/Cocos",
|
| 726 |
"Indian/Comoro",
|
| 727 |
"Indian/Kerguelen",
|
| 728 |
"Indian/Mahe",
|
| 729 |
"Indian/Maldives",
|
| 730 |
"Indian/Mauritius",
|
| 731 |
"Indian/Mayotte",
|
| 732 |
"Indian/Reunion",
|
| 733 |
"Iran",
|
| 734 |
"Israel",
|
| 735 |
"Jamaica",
|
| 736 |
"Japan",
|
| 737 |
"Kwajalein",
|
| 738 |
"Libya",
|
| 739 |
"MET",
|
| 740 |
"Mexico/BajaNorte",
|
| 741 |
"Mexico/BajaSur",
|
| 742 |
"Mexico/General",
|
| 743 |
"MST",
|
| 744 |
"MST7MDT",
|
| 745 |
"Navajo",
|
| 746 |
"NZ",
|
| 747 |
"NZ-CHAT",
|
| 748 |
"Pacific/Apia",
|
| 749 |
"Pacific/Auckland",
|
| 750 |
"Pacific/Chatham",
|
| 751 |
"Pacific/Easter",
|
| 752 |
"Pacific/Efate",
|
| 753 |
"Pacific/Enderbury",
|
| 754 |
"Pacific/Fakaofo",
|
| 755 |
"Pacific/Fiji",
|
| 756 |
"Pacific/Funafuti",
|
| 757 |
"Pacific/Galapagos",
|
| 758 |
"Pacific/Gambier",
|
| 759 |
"Pacific/Guadalcanal",
|
| 760 |
"Pacific/Guam",
|
| 761 |
"Pacific/Honolulu",
|
| 762 |
"Pacific/Johnston",
|
| 763 |
"Pacific/Kiritimati",
|
| 764 |
"Pacific/Kosrae",
|
| 765 |
"Pacific/Kwajalein",
|
| 766 |
"Pacific/Majuro",
|
| 767 |
"Pacific/Marquesas",
|
| 768 |
"Pacific/Midway",
|
| 769 |
"Pacific/Nauru",
|
| 770 |
"Pacific/Niue",
|
| 771 |
"Pacific/Norfolk",
|
| 772 |
"Pacific/Noumea",
|
| 773 |
"Pacific/Pago_Pago",
|
| 774 |
"Pacific/Palau",
|
| 775 |
"Pacific/Pitcairn",
|
| 776 |
"Pacific/Ponape",
|
| 777 |
"Pacific/Port_Moresby",
|
| 778 |
"Pacific/Rarotonga",
|
| 779 |
"Pacific/Saipan",
|
| 780 |
"Pacific/Samoa",
|
| 781 |
"Pacific/Tahiti",
|
| 782 |
"Pacific/Tarawa",
|
| 783 |
"Pacific/Tongatapu",
|
| 784 |
"Pacific/Truk",
|
| 785 |
"Pacific/Wake",
|
| 786 |
"Pacific/Wallis",
|
| 787 |
"Pacific/Yap",
|
| 788 |
"Poland",
|
| 789 |
"Portugal",
|
| 790 |
"PRC",
|
| 791 |
"PST8PDT",
|
| 792 |
"ROC",
|
| 793 |
"ROK",
|
| 794 |
"Singapore",
|
| 795 |
"Turkey",
|
| 796 |
"UCT",
|
| 797 |
"Universal",
|
| 798 |
"US/Alaska",
|
| 799 |
"US/Aleutian",
|
| 800 |
"US/Arizona",
|
| 801 |
"US/Central",
|
| 802 |
"US/East-Indiana",
|
| 803 |
"US/Eastern",
|
| 804 |
"US/Hawaii",
|
| 805 |
"US/Indiana-Starke",
|
| 806 |
"US/Michigan",
|
| 807 |
"US/Mountain",
|
| 808 |
"US/Pacific",
|
| 809 |
"US/Pacific-New",
|
| 810 |
"US/Samoa",
|
| 811 |
"UTC",
|
| 812 |
"W-SU",
|
| 813 |
"WET",
|
| 814 |
"Zulu"
|
| 815 |
);
|
| 816 |
}
|
| 817 |
return $zones_list;
|
| 818 |
}
|
| 819 |
|
| 820 |
|
| 821 |
/**
|
| 822 |
* Generate wunderground settings form
|
| 823 |
* @returns form
|
| 824 |
*/
|
| 825 |
function wunderground_admin() {
|
| 826 |
|
| 827 |
$form['wunderground_stationid'] = array(
|
| 828 |
'#type' => 'textfield',
|
| 829 |
'#title' => t('Weather Underground Station ID'),
|
| 830 |
'#default_value' => variable_get('wunderground_stationid', 'KCALIVER14'),
|
| 831 |
'#size' => 12,
|
| 832 |
'#maxlength' => 12,
|
| 833 |
'#description' => t("Station ID (PWS ID or Airport ID) to fetch the current weather for."),
|
| 834 |
'#required' => TRUE,
|
| 835 |
);
|
| 836 |
|
| 837 |
$form['wunderground_country'] = array(
|
| 838 |
'#type' => 'textfield',
|
| 839 |
'#title' => t('Weather Underground Country String'),
|
| 840 |
'#default_value' => variable_get('wunderground_country', ''),
|
| 841 |
'#size' => 12,
|
| 842 |
'#maxlength' => 12,
|
| 843 |
'#description' => t("Weather underground feed does not give the country of a weather statsion, add your stations's country code (or short string) here. (optional)"),
|
| 844 |
'#required' => FALSE,
|
| 845 |
);
|
| 846 |
|
| 847 |
$form['wunderground_block_subject'] = array(
|
| 848 |
'#type' => 'textfield',
|
| 849 |
'#title' => t('Weather Underground Block Subject'),
|
| 850 |
'#default_value' => variable_get('wunderground_block_subject', 'My Weather'),
|
| 851 |
'#size' => 25,
|
| 852 |
'#maxlength' => 25,
|
| 853 |
'#description' => t("Used as the title for the Weather Underground block."),
|
| 854 |
'#required' => TRUE,
|
| 855 |
);
|
| 856 |
|
| 857 |
$form['wunderground_timezone'] = array(
|
| 858 |
'#type' => 'select',
|
| 859 |
'#title' => t('Timezone'),
|
| 860 |
'#default_value' => variable_get('wunderground_timezone', date_default_timezone_get()),
|
| 861 |
'#options' => wunderground_get_timezones(),
|
| 862 |
'#description' => t("Timezone to use for time display.")
|
| 863 |
);
|
| 864 |
|
| 865 |
|
| 866 |
$form['wunderground_display_fields'] = array(
|
| 867 |
'#type' => 'checkboxes',
|
| 868 |
'#title' => t('Display Fields'),
|
| 869 |
'#default_value' => variable_get('wunderground_display_fields', array('location', 'updated', 'temp', 'pressure', 'dewpoint', 'humidity', 'wind', 'gusts', 'precip')),
|
| 870 |
'#options' => array(
|
| 871 |
'location' => t('Location (city, state)'),
|
| 872 |
'updated' => t('Last Weather Update Time'),
|
| 873 |
'temp' => t('Temperature'),
|
| 874 |
'pressure' => t('Barometric Pressure'),
|
| 875 |
'dewpoint' => t('Dewpoint'),
|
| 876 |
'humidity' => t('Relative Humidity'),
|
| 877 |
'wind' => t('Wind Speed and Direction'),
|
| 878 |
'gusts' => t('Wind Gusts information'),
|
| 879 |
'precip' => t('Precipitation information'),
|
| 880 |
),
|
| 881 |
);
|
| 882 |
|
| 883 |
$form['wunderground_misc_options'] = array(
|
| 884 |
'#type' => 'checkboxes',
|
| 885 |
'#title' => t('Misc options'),
|
| 886 |
'#default_value' => variable_get('wunderground_misc_options', array('details_link')),
|
| 887 |
'#options' => array(
|
| 888 |
'details_link' => t('Show \'Details...\' link in module block.')
|
| 889 |
),
|
| 890 |
);
|
| 891 |
|
| 892 |
$form['wunderground_units'] = array(
|
| 893 |
'#type' => 'radios',
|
| 894 |
'#title' => t('Default Units'),
|
| 895 |
'#default_value' => variable_get('wunderground_units', 0),
|
| 896 |
'#options' => array(t('English'), t('Metric')),
|
| 897 |
);
|
| 898 |
|
| 899 |
$form['wunderground_cachetime'] = array(
|
| 900 |
'#type' => 'select',
|
| 901 |
'#title' => t('Cache Time'),
|
| 902 |
'#default_value' => variable_get('wunderground_cachetime', 1),
|
| 903 |
'#options' => array(0, 1, 2, 4, 5, 10, 15, 30, 60),
|
| 904 |
'#description' => t("Minutes between XML retrieval.")
|
| 905 |
);
|
| 906 |
|
| 907 |
$form['wunderground_error_handling'] = array(
|
| 908 |
'#type' => 'radios',
|
| 909 |
'#title' => t('Error Handling'),
|
| 910 |
'#default_value' => variable_get('wunderground_error_handling', 0),
|
| 911 |
'#options' => array(t('Do not display block'), t('Display block with error message')),
|
| 912 |
'#description' => t("When weather station XML feed is unavailble or invalid."),
|
| 913 |
);
|
| 914 |
|
| 915 |
return system_settings_form($form);
|
| 916 |
}
|
| 917 |
|
| 918 |
/**
|
| 919 |
* Generate the menu items for wunderground
|
| 920 |
* @returns menu items
|
| 921 |
*/
|
| 922 |
function wunderground_menu() {
|
| 923 |
|
| 924 |
$items = array();
|
| 925 |
|
| 926 |
$items['admin/settings/wunderground'] = array(
|
| 927 |
'title' => 'Weather Underground',
|
| 928 |
'description' => 'Station Information',
|
| 929 |
'page callback' => 'drupal_get_form',
|
| 930 |
'page arguments' => array('wunderground_admin'),
|
| 931 |
'access arguments' => array('access administration pages'),
|
| 932 |
'type' => MENU_NORMAL_ITEM,
|
| 933 |
);
|
| 934 |
|
| 935 |
//this is added for this current tutorial.
|
| 936 |
$items['wunderground'] = array(
|
| 937 |
'title' => 'My Weather',
|
| 938 |
'page callback' => 'wunderground_all',
|
| 939 |
'access arguments' => array('access wunderground content'),
|
| 940 |
'type' => MENU_NORMAL_ITEM,
|
| 941 |
);
|
| 942 |
|
| 943 |
return $items;
|
| 944 |
}
|