Added feature #16393: Date ranges for ExtJS date pickers (Thanks to Stefano Cecere)
authorSusanne Moog <typo3@susannemoog.de>
Wed, 17 Nov 2010 19:46:10 +0000 (19:46 +0000)
committerSusanne Moog <typo3@susannemoog.de>
Wed, 17 Nov 2010 19:46:10 +0000 (19:46 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9469 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_tceforms.php
t3lib/js/extjs/tceforms.js

index 4d324a1..daf951e 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -56,6 +56,7 @@
        * Fixed bug #16107: listNum = 0 not working anymore due to stdWrap changes (Thanks to Jo Hasenau)
        * Added feature #16282: Optimize stdWrap usage for TypoScript content element IMAGE (Thanks to Jo Hasenau)
        * Added feature #16430: Optimize stdWrap usage for TypoScript content element GIFBUILDER (Thanks to Jo Hasenau)
+       * Added feature #16393: Date ranges for ExtJS date pickers (Thanks to Stefano Cecere)
 
 2010-11-17  Oliver Hader  <oliver@typo3.org>
 
index 09d5608..5bbcfd4 100644 (file)
@@ -1094,21 +1094,21 @@ class t3lib_TCEforms    {
                $cssClasses    = array($classAndStyleAttributes['class']);
                $cssStyle      = $classAndStyleAttributes['style'];
 
-                       // css class and id will show the kind of field
-               if (in_array('date', $evalList)) {
-                       $inputId = uniqid('tceforms-datefield-');
-                       $cssClasses[] = 'tceforms-textfield tceforms-datefield';
-                       $fieldAppendix = t3lib_iconWorks::getSpriteIcon(
-                               'actions-edit-pick-date',
-                               array(
-                                       'style' => 'cursor:pointer;',
-                                       'id' => 'picker-' . $inputId
-                               )
-                       );
-
-               } elseif (in_array('datetime', $evalList)) {
-                       $inputId = uniqid('tceforms-datetimefield-');
-                       $cssClasses[] = 'tceforms-textfield tceforms-datetimefield';
+               if(in_array('date', $evalList) || in_array('datetime', $evalList)) {
+                       if(in_array('datetime', $evalList)) {
+                               $class = 'datetime';
+                       } else {
+                               $class = 'date';
+                       }
+                       $dateRange = '';
+                       if (isset($config['range']['lower'])) {
+                               $dateRange .= ' lower-' . intval($config['range']['lower']);
+                       }
+                       if (isset($config['range']['upper'])) {
+                               $dateRange .= ' upper-' . intval($config['range']['upper']);
+                       }
+                       $inputId = uniqid('tceforms-' . $class . 'field-');
+                       $cssClasses[] = 'tceforms-textfield tceforms-' . $class . 'field' . $dateRange;
                        $fieldAppendix = t3lib_iconWorks::getSpriteIcon(
                                'actions-edit-pick-date',
                                array(
@@ -1116,7 +1116,6 @@ class t3lib_TCEforms      {
                                        'id' => 'picker-' . $inputId
                                )
                        );
-
                } elseif (in_array('timesec', $evalList)) {
                        $inputId = uniqid('tceforms-timesecfield-');
                        $cssClasses[] = 'tceforms-textfield tceforms-timesecfield';
index b917c41..4037875 100644 (file)
@@ -38,17 +38,25 @@ TYPO3.TCEFORMS = {
        },
 
        convertDateFieldsToDatePicker: function() {
-               var dateFields = Ext.select("input[id^=tceforms-date]");
+               var dateFields = Ext.select("input[id^=tceforms-date]"), minDate, maxDate, lowerMatch, upperMatch;
                dateFields.each(function(element) {
                        var index = element.dom.id.match(/tceforms-datefield-/) ? 0 : 1;
                        var format = TYPO3.settings.datePickerUSmode ? TYPO3.settings.dateFormatUS : TYPO3.settings.dateFormat;
 
                        var datepicker = element.next('span');
 
+                       // check for daterange
+                       var lowerMatch = element.dom.className.match(/lower-(\d+)\b/);
+                       minDate = Ext.isArray(lowerMatch) ? new Date(lowerMatch[1] * 1000) : null;
+                       var upperMatch = element.dom.className.match(/upper-(\d+)\b/);
+                       maxDate = Ext.isArray(upperMatch) ? new Date(upperMatch[1] * 1000) : null;
+
                        var menu = new Ext.menu.DateMenu({
                                id:                     'p' + element.dom.id,
                                format:         format[index],
                                value:          Date.parseDate(element.dom.value, format[index]),
+                               minDate:        minDate,
+                               maxDate:        maxDate,
                                handler:        function(picker, date){
                                        var relElement = Ext.getDom(picker.ownerCt.id.substring(1));
                                        relElement.value = date.format(format[index]);