function date_timezone_site_form in Date 5.2
Same name and namespace in other branches
- 6.2 date_timezone/date_timezone.module \date_timezone_site_form()
- 6 date_timezone/date_timezone.module \date_timezone_site_form()
Override form for the site timezone settings form. Display a list of timezone names instead of offsets and hide the offset value.
File
- date_timezone/
date_timezone.module, line 52 - This module will make the alter the user and site timezone forms to select a timezone name instead of a timezone offset.
Code
function date_timezone_site_form(&$form) {
drupal_add_js(drupal_get_path('module', 'date_timezone') . '/date_timezone.js');
$timezone = variable_get('date_default_timezone_name', NULL);
$form['date_default_timezone'] = array(
'#type' => 'select',
'#title' => t('Default time zone'),
'#default_value' => $timezone,
'#options' => date_timezone_names(FALSE, TRUE),
// Force an update before setting a site default.
'#description' => t('Select the default site time zone. If in doubt, choose the timezone that is closest to your location which has the same rules for daylight saving time.'),
'#weight' => -10,
'#validate' => array(
'date_timezone_update_site' => array(),
),
'#offset' => variable_get('date_default_timezone', 0),
);
// Add the JavaScript callback to automatically set the timezone.
if (empty($timezone)) {
drupal_add_js('
// Global Killswitch
if (Drupal.jsEnabled) {
$(document).ready(function() {
Drupal.setDefaultTimezone();
});
}', 'inline');
}
return $form;
}