function _weather_format_condition in Weather 5
Same name and namespace in other branches
- 5.6 weather.module \_weather_format_condition()
- 6.5 weather.module \_weather_format_condition()
Format the weather condition and phenomena (rain, drizzle, ...)
1 call to _weather_format_condition()
- theme_weather in ./
weather.module - Custom theme function for the weather block output
File
- ./
weather.module, line 646 - Display <acronym title="METeorological Aerodrome Report">METAR</acronym> weather data from anywhere in the world
Code
function _weather_format_condition($metar) {
if (!isset($metar) or !isset($metar['condition_text'])) {
return t('No data');
}
// sky conditions
switch ($metar['condition_text']) {
case 'clear':
$result[] = t('Clear sky');
break;
case 'few':
$result[] = t('Few clouds');
break;
case 'scattered':
$result[] = t('Scattered clouds');
break;
case 'broken':
$result[] = t('Broken clouds');
break;
case 'overcast':
$result[] = t('Overcast');
break;
case 'no-significant-clouds':
$result[] = t('No significant clouds');
break;
}
// weather phenomena
$rain = $metar['phenomena']['rain'];
if ($rain) {
if ($rain['#light']) {
if ($rain['#showers']) {
$result[] = t('light rain showers');
}
else {
if ($rain['#freezing']) {
$result[] = t('light freezing rain');
}
else {
$result[] = t('light rain');
}
}
}
else {
if ($rain['#heavy']) {
if ($rain['#showers']) {
$result[] = t('heavy rain showers');
}
else {
if ($rain['#freezing']) {
$result[] = t('heavy freezing rain');
}
else {
$result[] = t('heavy rain');
}
}
}
else {
if ($rain['#showers']) {
$result[] = t('rain showers');
}
else {
if ($rain['#freezing']) {
$result[] = t('freezing rain');
}
else {
$result[] = t('rain');
}
}
}
}
}
return join(", ", $result);
}