Index: modules/system/system.css =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.css,v retrieving revision 1.22 diff -u -p -r1.22 system.css --- modules/system/system.css 6 Feb 2007 08:35:13 -0000 1.22 +++ modules/system/system.css 1 Mar 2007 21:10:57 -0000 @@ -397,3 +397,21 @@ tr.selected td { thead div.sticky-header { background: #fff; } + +/* +** Date and time settings page +*/ +div.date-container { + overflow: auto; +} + +div.date-container > div { + float: left; +} + +div.date-container #short-custom-div, +div.date-container #medium-custom-div, +div.date-container #long-custom-div { + margin-left: 15px; + width: 50%; +} Index: modules/system/system.js =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.js,v retrieving revision 1.1 diff -u -p -r1.1 system.js --- modules/system/system.js 13 Feb 2007 07:41:51 -0000 1.1 +++ modules/system/system.js 1 Mar 2007 21:10:58 -0000 @@ -22,3 +22,46 @@ Drupal.cleanURLsSettingsCheck = function } }}); } + +/** + * Show/hide custom format sections on the date-time settings page. + */ +Drupal.dateTimeAutoAttach = function() { + $("#edit-date-format-short").change(function() { + if ($(this).val() == "custom") { + $("#short-custom-div").show(); + } + else { + $("#short-custom-div").hide(); + } + }); + + $("#edit-date-format-medium").change(function() { + if ($(this).val() == "custom") { + $("#medium-custom-div").show(); + } + else { + $("#medium-custom-div").hide(); + } + }); + + $("#edit-date-format-long").change(function() { + if ($(this).val() == "custom") { + $("#long-custom-div").show(); + } + else { + $("#long-custom-div").hide(); + } + }); + + // Hide the labels to simplify the UI. + $("#short-custom-div .form-item label").html(" "); + $("#medium-custom-div .form-item label").html(" "); + $("#long-custom-div .form-item label").html(" "); + + // Trigger the event handler to show the form input if necessary. + $("#edit-date-format-short").trigger("change"); + $("#edit-date-format-medium").trigger("change"); + $("#edit-date-format-long").trigger("change"); +} + Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.452 diff -u -p -r1.452 system.module --- modules/system/system.module 27 Feb 2007 12:29:22 -0000 1.452 +++ modules/system/system.module 1 Mar 2007 21:11:01 -0000 @@ -774,6 +774,14 @@ function system_rss_feeds_settings() { } function system_date_time_settings() { + drupal_add_js(drupal_get_path('module', 'system') .'/system.js', 'module'); + drupal_add_js(' +// Global Killswitch +if (Drupal.jsEnabled) { + $(document).ready(function() { + Drupal.dateTimeAutoAttach(); + }); +}', 'inline'); // Date settings: $zones = _system_zonelist(); @@ -800,6 +808,8 @@ function system_date_time_settings() { $datelongchoices[$f] = format_date(time(), 'custom', $f); } + $datelongchoices['custom'] = $datemediumchoices['custom'] = $dateshortchoices['custom'] = t('Custom format'); + $form['date_default_timezone'] = array( '#type' => 'select', '#title' => t('Default time zone'), @@ -816,30 +826,68 @@ function system_date_time_settings() { '#description' => t('Enable or disable user-configurable time zones. When enabled, users can set their own time zone and dates will be updated accordingly.') ); + $date_format_short = variable_get('date_format_short', $dateshort[1]); $form['date_format_short'] = array( + '#prefix' => '
', + '#suffix' => '
', '#type' => 'select', '#title' => t('Short date format'), - '#default_value' => variable_get('date_format_short', $dateshort[1]), + '#default_value' => (isset($dateshortchoices[$date_format_short])? $date_format_short : 'custom'), '#options' => $dateshortchoices, '#description' => t('The short format of date display.') ); + $default_short_custom = variable_get('date_format_short_custom', (isset($dateshortchoices[$date_format_short])? $date_format_short : '')); + $form['date_format_short_custom'] = array( + '#prefix' => '
', + '#suffix' => '
', + '#type' => 'textfield', + '#title' => t('Custom short date format'), + '#default_value' => $default_short_custom, + '#description' => t('A user-defined short date format. See the PHP manual for available options. This format is currently set to display as %date.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(time(), 'custom', $default_short_custom))), + ); + + $date_format_medium = variable_get('date_format_medium', $datemedium[1]); $form['date_format_medium'] = array( + '#prefix' => '
', + '#suffix' => '
', '#type' => 'select', '#title' => t('Medium date format'), - '#default_value' => variable_get('date_format_medium', $datemedium[1]), + '#default_value' => (isset($datemediumchoices[$date_format_medium])? $date_format_medium : 'custom'), '#options' => $datemediumchoices, - '#description' => t('The medium sized date display.') + '#description' => t('The medium sized date display.'), + ); + $default_medium_custom = variable_get('date_format_medium_custom', (isset($datemediumchoices[$date_format_medium])? $date_format_medium : '')); + $form['date_format_medium_custom'] = array( + '#prefix' => '
', + '#suffix' => '
', + '#type' => 'textfield', + '#title' => t('Custom medium date format'), + '#default_value' => $default_medium_custom, + '#description' => t('A user-defined medium date format. See the PHP manual for available options. This format is currently set to display as %date.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(time(), 'custom', $default_medium_custom))), ); + $date_format_long = variable_get('date_format_long', $datelong[0]); $form['date_format_long'] = array( + '#prefix' => '
', + '#suffix' => '
', '#type' => 'select', '#title' => t('Long date format'), - '#default_value' => variable_get('date_format_long', $datelong[0]), + '#default_value' => (isset($datelongchoices[$date_format_long])? $date_format_long : 'custom'), '#options' => $datelongchoices, '#description' => t('Longer date format used for detailed display.') ); + $default_long_custom = variable_get('date_format_long_custom', (isset($datelongchoices[$date_format_long])? $date_format_long : '')); + $form['date_format_long_custom'] = array( + '#prefix' => '
', + '#suffix' => '
', + '#type' => 'textfield', + '#title' => t('Custom long date format'), + '#default_value' => $default_long_custom, + '#description' => t('A user-defined long date format. See the PHP manual for available options. This format is currently set to display as %date.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(time(), 'custom', $default_long_custom))), + ); + $form['date_first_day'] = array( '#type' => 'select', '#title' => t('First day of week'), @@ -851,6 +899,19 @@ function system_date_time_settings() { return system_settings_form($form); } +function system_date_time_settings_submit($form_id, $form_values) { + if ($form_values['date_format_short'] == 'custom') { + $form_values['date_format_short'] = $form_values['date_format_short_custom']; + } + if ($form_values['date_format_medium'] == 'custom') { + $form_values['date_format_medium'] = $form_values['date_format_medium_custom']; + } + if ($form_values['date_format_long'] == 'custom') { + $form_values['date_format_long'] = $form_values['date_format_long_custom']; + } + return system_settings_form_submit($form_id, $form_values); +} + function system_site_maintenance_settings() { $form['site_offline'] = array(