Index: modules/system/system.js =================================================================== RCS file: modules/system/system.js diff -N modules/system/system.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/system/system.js 17 Jan 2007 00:43:40 -0000 @@ -0,0 +1,34 @@ +// $Id$ + +/** + * 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(); + } + }); + $("#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.441 diff -u -p -r1.441 system.module --- modules/system/system.module 15 Jan 2007 12:03:50 -0000 1.441 +++ modules/system/system.module 17 Jan 2007 00:43:40 -0000 @@ -778,6 +778,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(); @@ -804,6 +812,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'), @@ -820,30 +830,60 @@ 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( '#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.') ); + $form['date_format_short_custom'] = array( + '#prefix' => '
', + '#suffix' => '
', + '#type' => 'textfield', + '#title' => t('Custom short date format'), + '#default_value' => variable_get('date_format_short_custom', ''), + '#description' => t('A user-defined short date format.') . (variable_get('date_format_short_custom', '') === ''? '' : t(' This format is currently set to display as %date.', array('%date' => date(variable_get('date_format_short_custom', ''))))), + ); + + $date_format_medium = variable_get('date_format_medium', $datemedium[1]); $form['date_format_medium'] = array( '#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.') ); + $form['date_format_medium_custom'] = array( + '#prefix' => '
', + '#suffix' => '
', + '#type' => 'textfield', + '#title' => t('Custom medium date format'), + '#default_value' => variable_get('date_format_medium_custom', ''), + '#description' => t('A user-defined medium date format.') . (variable_get('date_format_medium_custom', '') === ''? '' : t(' This format is currently set to display as %date.', array('%date' => date(variable_get('date_format_medium_custom', ''))))), + ); + + $date_format_long = variable_get('date_format_long', $datelong[0]); $form['date_format_long'] = array( '#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.') ); + $form['date_format_long_custom'] = array( + '#prefix' => '
', + '#suffix' => '
', + '#type' => 'textfield', + '#title' => t('Custom long date format'), + '#default_value' => variable_get('date_format_long_custom', ''), + '#description' => t('A user-defined long date format.') . (variable_get('date_format_long_custom', '') === ''? '' : t(' This format is currently set to display as %date.', array('%date' => date(variable_get('date_format_long_custom', ''))))), + ); + $form['date_first_day'] = array( '#type' => 'select', '#title' => t('First day of week'), @@ -855,6 +895,18 @@ function system_date_time_settings() { return system_settings_form($form); } +function system_date_time_settings_validate($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']; + } +} + function system_site_maintenance_settings() { $form['site_offline'] = array(