summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2007-05-14 16:22:26 +0000
committerDries Buytaert <dries@buytaert.net>2007-05-14 16:22:26 +0000
commit8ba14fa492cc4b56f48b810eccbd54c3562bc3f2 (patch)
tree27f5cabe1aa1d4b95dc8c82298aa7d2ed2156250
parentf07760b3384da803cbd4762ed22109f74edb292c (diff)
downloadbrdo-8ba14fa492cc4b56f48b810eccbd54c3562bc3f2.tar.gz
brdo-8ba14fa492cc4b56f48b810eccbd54c3562bc3f2.tar.bz2
- Patch #138706 by hunmonk: fixed PostgreSQL caching problem.
-rw-r--r--CHANGELOG.txt1
-rw-r--r--modules/system/admin.css28
-rw-r--r--modules/system/system.install4
-rw-r--r--modules/system/system.js22
-rw-r--r--modules/system/system.module120
5 files changed, 154 insertions, 21 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 876f45322..c5f78ee51 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -26,6 +26,7 @@ Drupal 6.0, xxxx-xx-xx (development version)
* Added sticky table headers.
* Check for clean URL support automatically with JavaScript.
* Removed default/settings.php. Instead the installer will create it from default.settings.php.
+ * Made it possible to configure your own date formats.
- Theme system:
* Added .info files to themes and made it easier to specify regions and features.
* Added theme registry: modules can directly provide .tpl.php files for their themes without having to create theme_ functions.
diff --git a/modules/system/admin.css b/modules/system/admin.css
index e45f4e958..8ffd625ba 100644
--- a/modules/system/admin.css
+++ b/modules/system/admin.css
@@ -109,4 +109,30 @@ table.screenshot {
}
.theme-info p {
margin-top: 0;
-} \ No newline at end of file
+}
+
+
+/**
+ * Date and time settings page
+ */
+div.date-container {
+ overflow: auto;
+}
+
+div.date-container > div {
+ float: left;
+}
+
+html.js div.custom-container {
+ display: none;
+}
+
+html.js div.custom-container .form-item label {
+ visibility: hidden;
+}
+
+div.custom-container {
+ margin-left: 15px;
+ width: 50%;
+}
+
diff --git a/modules/system/system.install b/modules/system/system.install
index 2578bb8b8..cc5c5b593 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -750,7 +750,7 @@ function system_install() {
expire int NOT NULL default '0',
created int NOT NULL default '0',
headers text,
- serialized int(1) NOT NULL default '0',
+ serialized smallint NOT NULL default '0',
PRIMARY KEY (cid)
)");
db_query("CREATE INDEX {cache}_expire_idx ON {cache} (expire)");
@@ -3919,7 +3919,7 @@ function system_update_6015() {
expire int NOT NULL default '0',
created int NOT NULL default '0',
headers text,
- serialized int(1) NOT NULL default '0',
+ serialized smallint NOT NULL default '0',
PRIMARY KEY (cid)
)");
$ret[] = update_sql("CREATE INDEX {cache_form}_expire_idx ON {cache_form} (expire)");
diff --git a/modules/system/system.js b/modules/system/system.js
index 0c88c9f06..93f101f12 100644
--- a/modules/system/system.js
+++ b/modules/system/system.js
@@ -56,3 +56,25 @@ Drupal.installDefaultTimezone = function() {
var offset = new Date().getTimezoneOffset() * -60;
$("#edit-date-default-timezone").val(offset);
}
+
+/**
+ * Show/hide custom format sections on the date-time settings page.
+ */
+Drupal.dateTimeAutoAttach = function() {
+ // Show/hide custom format depending on the select's value.
+ $("select.date-format").change(function() {
+ $(this).parents("div.date-container").children("div.custom-container")[$(this).val() == "custom" ? "show" : "hide"]();
+ });
+
+ // Attach keyup handler to custom format inputs.
+ $("input.custom-format").keyup(function() {
+ var input = $(this);
+ var url = Drupal.settings.dateTime.lookup +(Drupal.settings.dateTime.lookup.match(/\?q=/) ? "&format=" : "?format=") + Drupal.encodeURIComponent(input.val());
+ $.getJSON(url, function(data) {
+ $("div.description span", input.parent()).html(data);
+ });
+ });
+
+ // Trigger the event handler to show the form input if necessary.
+ $("select.date-format").trigger("change");
+}
diff --git a/modules/system/system.module b/modules/system/system.module
index bca53c764..fc884d076 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -284,6 +284,11 @@ function system_menu() {
'page callback' => 'drupal_get_form',
'page arguments' => array('system_date_time_settings'),
);
+ $items['admin/settings/date-time/lookup'] = array(
+ 'title' => t('Date and time lookup'),
+ 'type' => MENU_CALLBACK,
+ 'page callback' => 'system_date_time_lookup',
+ );
$items['admin/settings/site-maintenance'] = array(
'title' => 'Site maintenance',
'description' => 'Take the site off-line for maintenance or bring it back online.',
@@ -824,32 +829,41 @@ function system_rss_feeds_settings() {
}
function system_date_time_settings() {
+ drupal_add_js(drupal_get_path('module', 'system') .'/system.js', 'module');
+ drupal_add_js(array('dateTime' => array('lookup' => url('admin/settings/date-time/lookup'))), 'setting');
+ drupal_add_js('
+// Global Killswitch
+if (Drupal.jsEnabled) {
+ $(document).ready(Drupal.dateTimeAutoAttach);
+}', 'inline');
// Date settings:
$zones = _system_zonelist();
// Date settings: possible date formats
- $dateshort = array('Y-m-d H:i', 'm/d/Y - H:i', 'd/m/Y - H:i', 'Y/m/d - H:i',
+ $date_short = array('Y-m-d H:i', 'm/d/Y - H:i', 'd/m/Y - H:i', 'Y/m/d - H:i',
'd.m.Y - H:i', 'm/d/Y - g:ia', 'd/m/Y - g:ia', 'Y/m/d - g:ia',
'M j Y - H:i', 'j M Y - H:i', 'Y M j - H:i',
'M j Y - g:ia', 'j M Y - g:ia', 'Y M j - g:ia');
- $datemedium = array('D, Y-m-d H:i', 'D, m/d/Y - H:i', 'D, d/m/Y - H:i',
+ $date_medium = array('D, Y-m-d H:i', 'D, m/d/Y - H:i', 'D, d/m/Y - H:i',
'D, Y/m/d - H:i', 'F j, Y - H:i', 'j F, Y - H:i', 'Y, F j - H:i',
'D, m/d/Y - g:ia', 'D, d/m/Y - g:ia', 'D, Y/m/d - g:ia',
'F j, Y - g:ia', 'j F Y - g:ia', 'Y, F j - g:ia', 'j. F Y - G:i');
- $datelong = array('l, F j, Y - H:i', 'l, j F, Y - H:i', 'l, Y, F j - H:i',
+ $date_long = array('l, F j, Y - H:i', 'l, j F, Y - H:i', 'l, Y, F j - H:i',
'l, F j, Y - g:ia', 'l, j F Y - g:ia', 'l, Y, F j - g:ia', 'l, j. F Y - G:i');
// Date settings: construct choices for user
- foreach ($dateshort as $f) {
- $dateshortchoices[$f] = format_date(time(), 'custom', $f);
+ foreach ($date_short as $f) {
+ $date_short_choices[$f] = format_date(time(), 'custom', $f);
}
- foreach ($datemedium as $f) {
- $datemediumchoices[$f] = format_date(time(), 'custom', $f);
+ foreach ($date_medium as $f) {
+ $date_medium_choices[$f] = format_date(time(), 'custom', $f);
}
- foreach ($datelong as $f) {
- $datelongchoices[$f] = format_date(time(), 'custom', $f);
+ foreach ($date_long as $f) {
+ $date_long_choices[$f] = format_date(time(), 'custom', $f);
}
+ $date_long_choices['custom'] = $date_medium_choices['custom'] = $date_short_choices['custom'] = t('Custom format');
+
$form['date_default_timezone'] = array(
'#type' => 'select',
'#title' => t('Default time zone'),
@@ -866,30 +880,75 @@ 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', $date_short[1]);
$form['date_format_short'] = array(
+ '#prefix' => '<div class="date-container"><div>',
+ '#suffix' => '</div>',
'#type' => 'select',
'#title' => t('Short date format'),
- '#default_value' => variable_get('date_format_short', $dateshort[1]),
- '#options' => $dateshortchoices,
- '#description' => t('The short format of date display.')
+ '#attributes' => array('class' => 'date-format'),
+ '#default_value' => (isset($date_short_choices[$date_format_short]) ? $date_format_short : 'custom'),
+ '#options' => $date_short_choices,
+ '#description' => t('The short format of date display.'),
);
+ $default_short_custom = variable_get('date_format_short_custom', (isset($date_short_choices[$date_format_short]) ? $date_format_short : ''));
+ $form['date_format_short_custom'] = array(
+ '#prefix' => '<div class="custom-container">',
+ '#suffix' => '</div></div>',
+ '#type' => 'textfield',
+ '#title' => t('Custom short date format'),
+ '#attributes' => array('class' => 'custom-format'),
+ '#default_value' => $default_short_custom,
+ '#description' => t('A user-defined short date format. See the <a href="@url">PHP manual</a> for available options. This format is currently set to display as <span>%date</span>.', 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', $date_medium[1]);
$form['date_format_medium'] = array(
+ '#prefix' => '<div class="date-container"><div>',
+ '#suffix' => '</div>',
'#type' => 'select',
'#title' => t('Medium date format'),
- '#default_value' => variable_get('date_format_medium', $datemedium[1]),
- '#options' => $datemediumchoices,
- '#description' => t('The medium sized date display.')
+ '#attributes' => array('class' => 'date-format'),
+ '#default_value' => (isset($date_medium_choices[$date_format_medium]) ? $date_format_medium : 'custom'),
+ '#options' => $date_medium_choices,
+ '#description' => t('The medium sized date display.'),
+ );
+
+ $default_medium_custom = variable_get('date_format_medium_custom', (isset($date_medium_choices[$date_format_medium]) ? $date_format_medium : ''));
+ $form['date_format_medium_custom'] = array(
+ '#prefix' => '<div class="custom-container">',
+ '#suffix' => '</div></div>',
+ '#type' => 'textfield',
+ '#title' => t('Custom medium date format'),
+ '#attributes' => array('class' => 'custom-format'),
+ '#default_value' => $default_medium_custom,
+ '#description' => t('A user-defined medium date format. See the <a href="@url">PHP manual</a> for available options. This format is currently set to display as <span>%date</span>.', 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', $date_long[0]);
$form['date_format_long'] = array(
+ '#prefix' => '<div class="date-container"><div>',
+ '#suffix' => '</div>',
'#type' => 'select',
'#title' => t('Long date format'),
- '#default_value' => variable_get('date_format_long', $datelong[0]),
- '#options' => $datelongchoices,
+ '#attributes' => array('class' => 'date-format'),
+ '#default_value' => (isset($date_long_choices[$date_format_long]) ? $date_format_long : 'custom'),
+ '#options' => $date_long_choices,
'#description' => t('Longer date format used for detailed display.')
);
+ $default_long_custom = variable_get('date_format_long_custom', (isset($date_long_choices[$date_format_long]) ? $date_format_long : ''));
+ $form['date_format_long_custom'] = array(
+ '#prefix' => '<div class="custom-container">',
+ '#suffix' => '</div></div>',
+ '#type' => 'textfield',
+ '#title' => t('Custom long date format'),
+ '#attributes' => array('class' => 'custom-format'),
+ '#default_value' => $default_long_custom,
+ '#description' => t('A user-defined long date format. See the <a href="@url">PHP manual</a> for available options. This format is currently set to display as <span>%date</span>.', 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'),
@@ -897,8 +956,33 @@ function system_date_time_settings() {
'#options' => array(0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'), 3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday')),
'#description' => t('The first day of the week for calendar views.')
);
+ $form = system_settings_form($form);
+ // We will call system_settings_form_submit() manually, so remove it for now.
+ unset($form['#submit']['system_settings_form_submit']);
+ $form['#submit']['system_date_time_settings_submit'] = array();
+ return $form;
+}
- 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);
+}
+
+/**
+ * Return the date for a given format string via Ajax.
+ */
+function system_date_time_lookup() {
+ $result = format_date(time(), 'custom', $_GET['format']);
+ echo drupal_to_js($result);
+ exit;
}
function system_site_maintenance_settings() {