[Kolab-devel] [issue3844] New user preference to specify order of date input fields

issues at kolab.org issues at kolab.org
Thu Sep 10 09:49:50 CEST 2009


New submission from Sönke Schwardt-Krummrich <schwardt at univention.de>:

Currently in kronolith the order of date input fields is hardcoded to
year-month-day. Some parts of the world usually use a different order.
The attached patch adds a user preference to specify input field order.

----------
files: t_kronolith_HK_UV_dateInputFieldOrder.diff
keyword: web client
messages: 21577
nosy: schwardt
priority: feature
status: unread
title: New user preference to specify order of date input fields

______________________________________
Kolab issue tracker <issues at kolab.org>
<https://issues.kolab.org/issue3844>
______________________________________
-------------- next part --------------
Patch by schwardt at univention.de (Wed Sep 9 14:43:43 2009 +0200):

horde/kronolith: added preference to specify order of date input fields

Currently in kronolith the order of date input fields is hardcoded to
year-month-day. Some states usually use a different order. This patch
adds a per user preference option to specify input field order.


--- a/horde-webmail/config/prefs.php
+++ b/horde-webmail/config/prefs.php
@@ -105,7 +105,7 @@ $prefGroups['language'] = array(
     'column' => _("Your Information"),
     'label' => _("Locale and Time"),
     'desc' => _("Set your preferred language, timezone and date options."),
-    'members' => array('language', 'timezone', 'twentyFour', 'date_format', 'first_week_day')
+    'members' => array('language', 'timezone', 'twentyFour', 'date_format', 'date_input_format', 'first_week_day')
 );
 
 $prefGroups['categories'] = array(
@@ -346,6 +346,21 @@ $_prefs['date_format'] = array(
     'desc' => _("Choose how to display dates:"),
 );
 
+// date input format
+$_prefs['date_input_format'] = array(
+    'value' => 'year-month-day',
+    'locked' => false,
+    'shared' => true,
+    'type' => 'enum',
+    'enum' => array(
+        'day-month-year' => strftime('%d %b %Y'),
+        'month-day-year' => strftime('%b %d %Y'),
+        'year-day-month' => strftime('%Y %d %b'),
+        'year-month-day' => strftime('%Y %b %d'),
+    ),
+    'desc' => _("Choose order how to enter dates:"),
+);
+
 // what day should be displayed as the first day of the week?
 $_prefs['first_week_day'] = array(
     'value' => '0',
--- a/horde-webmail/config/prefs.php.dist
+++ b/horde-webmail/config/prefs.php.dist
@@ -105,7 +105,7 @@ $prefGroups['language'] = array(
     'column' => _("Your Information"),
     'label' => _("Locale and Time"),
     'desc' => _("Set your preferred language, timezone and date options."),
-    'members' => array('language', 'timezone', 'twentyFour', 'date_format', 'first_week_day')
+    'members' => array('language', 'timezone', 'twentyFour', 'date_format', 'date_input_format', 'first_week_day')
 );
 
 $prefGroups['categories'] = array(
@@ -344,6 +344,21 @@ $_prefs['date_format'] = array(
     'desc' => _("Choose how to display dates:"),
 );
 
+// date input format
+$_prefs['date_input_format'] = array(
+    'value' => 'year-month-day',
+    'locked' => false,
+    'shared' => true,
+    'type' => 'enum',
+    'enum' => array(
+        'day-month-year' => strftime('%d %b %Y'),
+        'month-day-year' => strftime('%b %d %Y'),
+        'year-day-month' => strftime('%Y %d %b'),
+        'year-month-day' => strftime('%Y %b %d'),
+    ),
+    'desc' => _("Choose order how to enter dates:"),
+);
+
 // what day should be displayed as the first day of the week?
 $_prefs['first_week_day'] = array(
     'value' => '0',
--- a/horde-webmail/kronolith/templates/edit/edit_timespan.inc
+++ b/horde-webmail/kronolith/templates/edit/edit_timespan.inc
@@ -22,11 +22,16 @@
  </td>
  <td colspan="2" class="rightAlign"><?php echo _("On") ?> </td>
  <td>
-  <?php echo $event->html('start[year]') ?>
-  -
-  <?php echo $event->html('start[month]') ?>
-  -
-  <?php echo $event->html('start[day]') ?>
+ <?php
+     $dateorder = $GLOBALS['prefs']->getValue('date_input_format');
+     $dateorder = $dateorder != "" ? $dateorder : "year-month-day";
+     $dateorder = explode("-", $dateorder );
+     $datefields = array();
+     foreach ($dateorder as $fld) {
+	   $datefields[] = $event->html('start['.$fld.']');
+	 }
+     echo implode("-", $datefields);
+ ?>
 <?php if ($GLOBALS['browser']->hasFeature('dom')): ?>
   <span id="start_wday"></span>
   <script type="text/javascript">
@@ -82,11 +87,16 @@
   <?php echo Horde::label('end_year', _("On")) ?> 
  </td>
  <td>
-  <?php echo $event->html('end[year]') ?>
-  -
-  <?php echo $event->html('end[month]') ?>
-  -
-  <?php echo $event->html('end[day]') ?>
+ <?php
+     $dateorder = $GLOBALS['prefs']->getValue('date_input_format');
+     $dateorder = $dateorder != "" ? $dateorder : "year-month-day";
+     $dateorder = explode("-", $dateorder );
+     $datefields = array();
+     foreach ($dateorder as $fld) {
+	   $datefields[] = $event->html('end['.$fld.']');
+	 }
+     echo implode("-", $datefields);
+ ?>
 <?php if ($GLOBALS['browser']->hasFeature('dom')): ?>
   <span id="end_wday"></span>
   <script type="text/javascript">


More information about the devel mailing list