function weather_block in Weather 5
Same name and namespace in other branches
- 5.6 weather.module \weather_block()
- 6.5 weather.module \weather_block()
Generate HTML for the weather block
@returns block HTML
Parameters
op operation from the URL:
delta offset:
File
- ./
weather.module, line 103 - Display <acronym title="METeorological Aerodrome Report">METAR</acronym> weather data from anywhere in the world
Code
function weather_block($op = 'list', $delta = 0) {
global $user;
if ($op == 'list') {
$block[0]['info'] = t('Weather: system-wide');
$block[1]['info'] = t('Weather: custom user');
return $block;
}
else {
if ($op == 'view') {
if ($delta == 0 and user_access('access content')) {
// show the system weather block
$block['subject'] = t('Current weather');
$block['content'] = '';
$configs_in_use = _weather_get_configs_in_use(0);
if (count($configs_in_use) == 0) {
$configs_in_use = array(
'cid' => 1,
);
}
foreach ($configs_in_use as $index) {
$config = _weather_get_config(0, $index['cid']);
$metar = weather_get_metar($config['icao']);
$block['content'] .= theme('weather', $config, $metar);
}
return $block;
}
else {
if ($delta == 1 and user_access('administer custom weather block')) {
// show the user's custom weather block
$block['subject'] = t('Current weather');
$block['content'] = '';
$configs_in_use = _weather_get_configs_in_use($user->uid);
if (count($configs_in_use) == 0) {
$configs_in_use = array(
'cid' => 1,
);
}
foreach ($configs_in_use as $index) {
$config = _weather_get_config($user->uid, $index['cid']);
$metar = weather_get_metar($config['icao']);
$block['content'] .= theme('weather', $config, $metar);
}
return $block;
}
}
}
}
}