function theme_weather in Weather 5.6
Same name and namespace in other branches
- 5 weather.module \theme_weather()
Custom theme function for the weather block output
1 theme call to theme_weather()
- weather_block in ./
weather.module - Generate HTML for the weather block
File
- ./
weather.module, line 300 - Display <acronym title="METeorological Aerodrome Report">METAR</acronym> weather data from anywhere in the world
Code
function theme_weather($config, $metar) {
if ($config['settings']['show_compact_block']) {
$content = '<p>';
if (isset($metar['temperature'])) {
$text = t('<strong>@name:</strong> !condition, !temperature');
}
else {
$text = t('<strong>@name:</strong> !condition');
}
$content .= t($text, array(
'@name' => $config['real_name'],
'!condition' => _weather_format_condition($metar),
'!temperature' => _weather_format_temperature($metar['temperature'], $config['units']),
));
$content .= '</p>';
return $content;
}
$content = '<p><strong>' . check_plain($config['real_name']) . '</strong></p>';
$image = _weather_get_image($metar);
$condition = _weather_format_condition($metar);
$content .= '<div style="text-align:center;"><img src="';
$content .= $image['filename'];
$content .= '" alt="' . $condition . '" ' . $image['size'];
$content .= ' title="' . $condition . '" /></div>';
$content .= '<ul><li>';
$content .= $condition;
$content .= '</li>';
if (isset($metar['temperature'])) {
$content .= '<li>';
$content .= t('Temperature: !temperature', array(
'!temperature' => _weather_format_temperature($metar['temperature'], $config['units']),
));
$content .= '</li>';
}
if (isset($metar['wind'])) {
$content .= '<li>';
$content .= t('Wind: !wind', array(
'!wind' => _weather_format_wind($metar['wind'], $config['units'], $config['settings']),
));
$content .= '</li>';
}
if (isset($metar['pressure'])) {
$content .= '<li>';
$content .= t('Pressure: !pressure', array(
'!pressure' => _weather_format_pressure($metar['pressure'], $config['units']),
));
$content .= '</li>';
}
if (isset($metar['temperature']) and isset($metar['dewpoint'])) {
$content .= '<li>';
$content .= t('Rel. Humidity: !rel_humidity', array(
'!rel_humidity' => _weather_format_relative_humidity($metar['temperature'], $metar['dewpoint']),
));
$content .= '</li>';
}
if (isset($metar['visibility']['kilometers'])) {
$content .= '<li>';
$content .= t('Visibility: !visibility', array(
'!visibility' => _weather_format_visibility($metar['visibility'], $config['units']),
));
$content .= '</li>';
}
if ($config['settings']['show_sunrise_sunset']) {
// Check if there is a sunrise or sunset
if ($metar['daytime']['no_sunrise']) {
$content .= '<li>';
$content .= t('No sunrise today');
$content .= '</li>';
}
else {
if ($metar['daytime']['no_sunset']) {
$content .= '<li>';
$content .= t('No sunset today');
$content .= '</li>';
}
else {
$text = gmdate('G:i T', $metar['daytime']['sunrise_on']);
$content .= '<li>';
$content .= t('Sunrise: !sunrise', array(
'!sunrise' => $text,
));
$content .= '</li>';
$text = gmdate('G:i T', $metar['daytime']['sunset_on']);
$content .= '<li>';
$content .= t('Sunset: !sunset', array(
'!sunset' => $text,
));
$content .= '</li>';
}
}
}
if (isset($metar['#raw']) and $config['settings']['show_unconverted_metar']) {
$content .= '<li>';
$content .= t('METAR data: !metar', array(
'!metar' => '<pre>' . wordwrap($metar['#raw'], 20) . '</pre>',
));
$content .= '</li>';
}
$content .= '</ul>';
// If this is displayed as location block, show information about
// which METAR station has been used for weather data
if (isset($config['distance'])) {
$content .= '<small>';
$content .= t('Location of this weather station:');
$content .= '<br />' . _weather_format_closest_station($config['distance'], $config['units'], $config['settings']);
$content .= '</small><br />';
}
if (isset($metar['reported_on'])) {
$content .= '<small>';
$content .= t("Reported on:");
$content .= '<br />' . format_date($metar['reported_on']);
$content .= '</small>';
}
return $content;
}