function weather_main_page in Weather 5.6
Show an overview of configured locations and the default location, if on the admin pages
1 string reference to 'weather_main_page'
- weather_menu in ./
weather.module - Implementation of hook_menu().
File
- ./
weather.module, line 478 - Display <acronym title="METeorological Aerodrome Report">METAR</acronym> weather data from anywhere in the world
Code
function weather_main_page($uid) {
$header = array(
array(
'data' => t('Real name'),
'field' => 'real_name',
),
t('Weight'),
array(
'data' => t('Operations'),
'colspan' => 2,
),
);
if ($uid == WEATHER_SYSTEM_BLOCK) {
$path = 'admin/settings/weather/';
}
else {
$path = 'user/' . $uid . '/weather/';
}
$rows = array();
$sort_order = 'weight ' . tablesort_get_sort($header) . ', ';
$sql = "SELECT * FROM {weather_config}\n WHERE uid=%d" . tablesort_sql($header, $sort_order);
$result = db_query($sql, $uid);
while ($row = db_fetch_array($result)) {
$rows[] = array(
$row['real_name'],
$row['weight'],
l(t('edit'), $path . 'edit/' . $row['cid']),
l(t('delete'), $path . 'delete/' . $row['cid']),
);
}
if (count($rows) == 0) {
$rows[] = array(
array(
'data' => '<em>' . t('There are currently no locations.') . '</em>',
'colspan' => 4,
),
);
}
$output = theme('table', $header, $rows);
if (isset($form['pager']['#value'])) {
$output .= drupal_render($form['pager']);
}
$free_cid = _weather_get_free_config($uid);
$output .= '<p>' . l(t('Create new location'), $path . 'edit/' . $free_cid) . '</p>';
if ($uid == WEATHER_SYSTEM_BLOCK) {
$output .= '<p>' . l(t('Configure the default location'), $path . 'default') . '</p>';
$output .= drupal_get_form('weather_main_page_form');
}
return $output;
}