function _weather_get_image in Weather 5
Same name and namespace in other branches
- 5.6 weather.module \_weather_get_image()
- 6.5 weather.module \_weather_get_image()
1 call to _weather_get_image()
- theme_weather in ./
weather.module - Custom theme function for the weather block output
File
- ./
weather.module, line 182 - Display <acronym title="METeorological Aerodrome Report">METAR</acronym> weather data from anywhere in the world
Code
function _weather_get_image($metar) {
// is there any data available?
if (!isset($metar['condition_text'])) {
$name = 'nodata';
}
else {
// handle special case: NSC, we just use few for the display
if ($metar['condition_text'] == 'no-significant-clouds') {
$metar['condition_text'] = 'few';
}
// calculate the sunrise and sunset times for day/night images
$day_night = _weather_sunrise_sunset($metar);
$name = $day_night . '-' . $metar['condition_text'];
// handle rain images
if (isset($metar['phenomena']['rain'])) {
$rain = $metar['phenomena']['rain'];
}
else {
if (isset($metar['phenomena']['drizzle'])) {
$rain = $metar['phenomena']['drizzle'];
}
}
if (isset($rain)) {
if ($rain['#light']) {
$name .= '-light-rain';
}
else {
if ($rain['#heavy']) {
$name .= '-heavy-rain';
}
else {
$name .= '-moderate-rain';
}
}
}
}
// set up final return array
$image['filename'] .= base_path() . drupal_get_path('module', 'weather') . '/images/' . $name . '.png';
$image['alt_text'] = $name;
return $image;
}