Project

General

Profile

Bug #20829 » datepicker_v8.diff

Administrator Admin, 2009-08-10 23:31

View differences:

t3lib/class.t3lib_tceforms.php (working copy)
$size = t3lib_div::intInRange($config['size']?$config['size']:30,5,$this->maxInputWidth);
$evalList = t3lib_div::trimExplode(',',$config['eval'],1);
$fieldAppendix = '';
// cssclass and id will show the kind of field
if (in_array('date', $evalList)) {
if (in_array('date', $evalList)) {
$inputId = uniqid('tceforms-datefield-');
$cssClass = 'tceforms-textfield tceforms-datefield';
$cssClass = 'tceforms-textfield tceforms-datefield';
$fieldAppendix = '<img' . t3lib_iconWorks::skinImg(
$this->backPath, 'gfx/datepicker.gif', '', 0)
. ' style="cursor:pointer; vertical-align:middle;" alt=""'
. ' id="picker-' . $inputId . '" />';
} elseif (in_array('datetime', $evalList)) {
$inputId = uniqid('tceforms-datetimefield-');
$cssClass = 'tceforms-textfield tceforms-datetimefield';
$fieldAppendix = '<img' . t3lib_iconWorks::skinImg(
$this->backPath, 'gfx/datepicker.gif', '', 0)
. ' style="cursor:pointer; vertical-align:middle;" alt=""'
. ' id="picker-' . $inputId . '" />';
} elseif (in_array('timesec', $evalList)) {
$inputId = uniqid('tceforms-timesecfield-');
$cssClass = 'tceforms-textfield tceforms-timesecfield';
$cssClass = 'tceforms-textfield tceforms-timesecfield';
} elseif (in_array('year', $evalList)) {
$inputId = uniqid('tceforms-yearfield-');
$cssClass = 'tceforms-textfield tceforms-yearfield';
$cssClass = 'tceforms-textfield tceforms-yearfield';
} elseif (in_array('time', $evalList)) {
$inputId = uniqid('tceforms-timefield-');
$cssClass = 'tceforms-textfield tceforms-timefield';
$cssClass = 'tceforms-textfield tceforms-timefield';
} elseif (in_array('int', $evalList)) {
$inputId = uniqid('tceforms-intfield-');
$cssClass = 'tceforms-textfield tceforms-intfield';
$cssClass = 'tceforms-textfield tceforms-intfield';
} elseif (in_array('double2', $evalList)) {
$inputId = uniqid('tceforms-double2field-');
$cssClass = 'tceforms-textfield tceforms-double2field';
$cssClass = 'tceforms-textfield tceforms-double2field';
} else {
$inputId = uniqid('tceforms-textfield-');
$cssClass = 'tceforms-textfield';
}
$cssClass = 'tceforms-textfield';
}
if (isset($config['wizards']['link'])) {
$inputId = uniqid('tceforms-linkfield-');
$cssClass = 'tceforms-textfield tceforms-linkfield';
......
$PA['fieldChangeFunc'] = array_merge(array('typo3form.fieldGet'=>'typo3form.fieldGet('.$paramsList.');'), $PA['fieldChangeFunc']);
$mLgd = ($config['max']?$config['max']:256);
$iOnChange = implode('',$PA['fieldChangeFunc']);
$item.='<input type="text" id="' . $inputId . '" class="' . $cssClass . '" name="'.$PA['itemFormElName'].'_hr" value=""'.$this->formWidth($size).' maxlength="'.$mLgd.'" onchange="'.htmlspecialchars($iOnChange).'"'.$PA['onFocus'].' />'; // This is the EDITABLE form field.
$item.='<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />'; // This is the ACTUAL form field - values from the EDITABLE field must be transferred to this field which is the one that is written to the database.
$item .= $fieldAppendix;
$this->extJSCODE.='typo3form.fieldSet('.$paramsList.');';
// going through all custom evaluations configured for this field
......
}
$GLOBALS['SOBE']->doc->loadPrototype();
$GLOBALS['SOBE']->doc->loadExtJS();
$this->loadJavascriptLib('../t3lib/jsfunc.evalfield.js');
// @TODO: Change to loadJavascriptLib(), but fix "TS = new typoScript()" issue first - see bug #9494
$jsFile[] = '<script type="text/javascript" src="'.$this->backPath.'jsfunc.tbe_editor.js"></script>';
// needed for tceform manipulation (date picker)
$typo3Settings = array(
'datePickerUSmode' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? 1 : 0,
'dateFormat' => array('j-n-Y', 'G:i j-n-Y'),
'dateFormatUS' => array('n-j-Y', 'G:i n-j-Y'),
);
$out .= '
Ext.ns("TYPO3");
TYPO3.settings = ' . json_encode($typo3Settings) . ';';
$this->loadJavascriptLib('../t3lib/js/extjs/tceforms.js');
// if IRRE fields were processed, add the JavaScript functions:
if ($this->inline->inlineCount) {
$GLOBALS['SOBE']->doc->loadScriptaculous();
t3lib/js/extjs/tceforms.js (revision 0)
/***************************************************************
* extJS for TCEforms
*
* $Id$
*
* Copyright notice
*
* (c) 2009 Steffen Kamper <info@sk-typo3.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
Ext.ns('TYPO3');
// class to manipulate TCEFORMS
TYPO3.TCEFORMS = {
init: function() {
Ext.QuickTips.init();
this.convertDateFieldsToDatePicker();
},
convertDateFieldsToDatePicker: function() {
var dateFields = Ext.select("*[id^=tceforms-datefield-], *[id^=tceforms-datetimefield-]");
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 = Ext.get('picker-' + element.dom.id);
var menu = new Ext.menu.DateMenu({
id: 'p' + element.dom.id,
format: format[index],
value: Date.parseDate(element.dom.value, format[index]),
handler: function(picker, date){
var relElement = Ext.getDom(picker.id.substring(1));
relElement.value = date.format(format[index]);
if (Ext.isFunction(relElement.onchange)) {
relElement.onchange.call(relElement);
}
},
listeners: {
beforeshow: function(picker) {
var relElement = Ext.getDom(picker.id.substring(1));
if (relElement.value) {
Ext.getCmp('p' + relElement.id).setValue(Date.parseDate(relElement.value, format[index]));
}
}
}
});
datepicker.on('click', function(){
menu.show(datepicker);
});
});
}
}
Ext.onReady(TYPO3.TCEFORMS.init, TYPO3.TCEFORMS);
(5-5/5)