Project

General

Profile

Bug #15133 » bug-1697.diff

Administrator Admin, 2007-04-28 01:41

View differences:

t3lib/class.t3lib_tceforms.php (working copy)
$paramsList = "'".$PA['itemFormElName']."','".implode(',',$evalList)."','".trim($config['is_in'])."',".(isset($config['checkbox'])?1:0).",'".$config['checkbox']."'";
if (isset($config['checkbox'])) {
// Setting default "click-checkbox" values for eval types "date" and "datetime":
$thisMidnight = mktime(0,0,0);
$checkSetValue = in_array('date',$evalList) ? $thisMidnight : '';
$checkSetValue = in_array('datetime',$evalList) ? time() : $checkSetValue;
$thisMidnight = gmmktime(0,0,0);
if (in_array('date',$evalList)) {
$checkSetValue = $thisMidnight;
} elseif (in_array('datetime',$evalList)) {
$checkSetValue = time();
} elseif (in_array('year',$evalList)) {
$checkSetValue = gmdate('Y');
}
$cOnClick = 'typo3form.fieldGet('.$paramsList.',1,\''.$checkSetValue.'\');'.implode('',$PA['fieldChangeFunc']);
$item.='<input type="checkbox"'.$this->insertDefStyle('check').' name="'.$PA['itemFormElName'].'_cb" onclick="'.htmlspecialchars($cOnClick).'" />';
}
if((in_array('date',$evalList) || in_array('datetime',$evalList)) && $PA['itemFormElValue']>0){
// Add server timezone offset to UTC to our stored date
$hoursOffset = date('O',$PA['itemFormElValue'])/100;
$PA['itemFormElValue'] += ($hoursOffset*60*60);
}
$PA['fieldChangeFunc'] = array_merge(array('typo3form.fieldGet'=>'typo3form.fieldGet('.$paramsList.');'), $PA['fieldChangeFunc']);
$mLgd = ($config['max']?$config['max']:256);
t3lib/jsfunc.evalfield.js (working copy)
this.getSecs = evalFunc_getSecs;
this.getYear = evalFunc_getYear;
this.getTimeSecs = evalFunc_getTimeSecs;
this.getTime = evalFunc_getTime;
this.getDate = evalFunc_getDate;
this.getTimestamp = evalFunc_getTimestamp;
this.caseSwitch = evalFunc_caseSwitch;
this.evalObjValue = evalFunc_evalObjValue;
this.outputObjValue = evalFunc_outputObjValue;
......
this.btrim = evalFunc_btrim;
var today = new Date();
this.lastYear = this.getYear(today);
this.lastDate = this.getSecs(today);
this.lastTime = this.getTimeSecs(today);
this.lastDate = this.getDate(today);
this.lastTime = this.getTimestamp(today);
this.isInString = '';
this.USmode = 0;
}
......
return this.parseDouble(inVal);
}
var today = new Date()
var today = new Date();
var add=0;
var value = this.ltrim(inVal);
var values = new evalFunc_split(value);
......
case "d":
case "t":
case "n":
var theTime = new Date(this.getYear(today), today.getMonth(), today.getDate(), today.getHours(), today.getMinutes());
this.lastDate = this.getSecs(theTime)
if (values.valPol[1]) {
add = this.pol(values.valPol[1],this.parseInt(values.values[1]));
}
......
default:
var index = value.indexOf(' ');
if (index!=-1) {
var theSecs = this.input("date",value.substr(index,value.length)) + this.input("time",value.substr(0,index));
this.lastDate = theSecs;
this.lastTime = this.input("date",value.substr(index,value.length)) + this.input("time",value.substr(0,index));
}
}
this.lastDate+=add*24*60*60;
return this.lastDate;
this.lastTime+=add*24*60*60;
return this.lastTime;
break;
case "year":
switch (theCmd) {
case "d":
case "t":
case "n":
var theTime = today;
this.lastYear = this.getYear(theTime);
if (values.valPol[1]) {
add = this.pol(values.valPol[1],this.parseInt(values.values[1]));
}
......
add = this.pol(values.valPol[2],this.parseInt(values.values[2]));
}
var year = (values.values[1])?this.parseInt(values.values[1]):this.getYear(today);
if ( (year>=0&&year<38) || (year>=70&&year<100) || (year>=1970&&year<2038) ) {
if (year<100) {
year = (year<38) ? year+=2000 : year+=1900;
}
} else {year = this.getYear(today);}
if ( (year>=0&&year<38) || (year>=70&&year<100) || (year>=1970&&year<2038) ) {
if (year<100) {
year = (year<38) ? year+=2000 : year+=1900;
}
} else {
year = this.getYear(today);
}
this.lastYear = year
}
this.lastYear+=add;
......
case "d":
case "t":
case "n":
var theTime = new Date(this.getYear(today), today.getMonth(), today.getDate());
this.lastDate = this.getSecs(theTime);
if (values.valPol[1]) {
add = this.pol(values.valPol[1],this.parseInt(values.values[1]));
}
......
}
var year = (values.values[3])?this.parseInt(values.values[3]):this.getYear(today);
if ( (year>=0&&year<38) || (year>=70&&year<100) || (year>=1970&&year<2038) ) {
if (year<100) {
year = (year<38) ? year+=2000 : year+=1900;
}
} else {year = this.getYear(today);}
var month = (values.values[this.USmode?1:2])?this.parseInt(values.values[this.USmode?1:2]):today.getMonth()+1;
if (month > 12) {month=12;}
if (month < 1) {month=1;}
var day = (values.values[this.USmode?2:1])?this.parseInt(values.values[this.USmode?2:1]):today.getDate();
if (day > 31) {day=31;}
if (day < 1) {day=1;}
if (''+day+'-'+month+'-'+year == "1-1-1970") {
var theTime = new Date(); theTime.setTime(0);
if ( (year>=0&&year<38) || (year>=70&&year<100) || (year>=1970&&year<2038) ) {
if (year<100) {
year = (year<38) ? year+=2000 : year+=1900;
}
} else {
var theTime = new Date(parseInt(year), parseInt(month)-1, parseInt(day));
year = this.getYear(today);
}
this.lastDate = this.getSecs(theTime)
var month = (values.values[this.USmode?1:2])?this.parseInt(values.values[this.USmode?1:2]):today.getUTCMonth()+1;
var day = (values.values[this.USmode?2:1])?this.parseInt(values.values[this.USmode?2:1]):today.getUTCDate();
var theTime = new Date(parseInt(year), parseInt(month)-1, parseInt(day));
// Substract timezone offset from client
this.lastDate = this.getTimestamp(theTime);
theTime.setTime((this.lastDate - theTime.getTimezoneOffset()*60)*1000);
this.lastDate = this.getTimestamp(theTime);
}
this.lastDate+=add*24*60*60;
if (this.lastDate<0) {this.lastDate=0;}
......
case "d":
case "t":
case "n":
var theTime = new Date(this.getYear(today), today.getMonth(), today.getDate(), today.getHours(), today.getMinutes(), ((type=="timesec")?today.getSeconds():0));
this.lastTime = this.getTimeSecs(theTime);
if (values.valPol[1]) {
add = this.pol(values.valPol[1],this.parseInt(values.values[1]));
}
......
var temp = values.values[1];
values = new evalFunc_splitSingle(temp);
}
var sec = (values.values[3])?this.parseInt(values.values[3]):today.getSeconds();
if (sec > 59) {sec=59;}
var min = (values.values[2])?this.parseInt(values.values[2]):today.getMinutes();
if (min > 59) {min=59;}
var hour = (values.values[1])?this.parseInt(values.values[1]):today.getHours();
if (hour > 23) {hour=23;}
var theTime = new Date(this.getYear(today), today.getMonth(), today.getDate(), hour, min, ((type=="timesec")?sec:0));
this.lastTime = this.getTimeSecs(theTime)
var sec = (values.values[3])?this.parseInt(values.values[3]):today.getUTCSeconds();
if (sec > 59) {sec=59;}
var min = (values.values[2])?this.parseInt(values.values[2]):today.getUTCMinutes();
if (min > 59) {min=59;}
var hour = (values.values[1])?this.parseInt(values.values[1]):today.getUTCHours();
if (hour > 23) {hour=23;}
var theTime = new Date(this.getYear(today), today.getUTCMonth(), today.getUTCDate(), hour, min, ((type=="timesec")?sec:0));
this.lastTime = this.getTimestamp(theTime);
theTime.setTime((this.lastTime - theTime.getTimezoneOffset()*60)*1000);
this.lastTime = this.getTime(theTime);
}
this.lastTime+=add*60;
if (this.lastTime<0) {this.lastTime+=24*60*60;}
......
switch (type) {
case "date":
if (!parseInt(value)) {return '';}
var theTime = new Date();
theTime.setTime(value*1000);
var theTime = new Date(parseInt(value) * 1000);
if (this.USmode) {
theString = (theTime.getMonth()+1)+'-'+theTime.getDate()+'-'+this.getYear(theTime);
theString = (theTime.getUTCMonth()+1)+'-'+theTime.getUTCDate()+'-'+this.getYear(theTime);
} else {
theString = theTime.getDate()+'-'+(theTime.getMonth()+1)+'-'+this.getYear(theTime);
theString = theTime.getUTCDate()+'-'+(theTime.getUTCMonth()+1)+'-'+this.getYear(theTime);
}
break;
case "datetime":
if (!parseInt(value)) {return '';}
var theTime = new Date();
theTime.setTime(value*1000);
theString = this.output("time",this.getTimeSecs(theTime))+' '+this.output("date",value);
theString = this.output("time",value)+' '+this.output("date",value);
break;
case "time":
case "timesec":
if (!parseInt(value)) {return '';}
var theTime = new Date();
theTime.setTime(value*1000);
var h = Math.floor(value/3600);
var m = Math.floor((value-h*3600)/60);
var s = Math.floor(value-h*3600-m*60);
var theTime = new Date(parseInt(value) * 1000);
var h = theTime.getUTCHours();
var m = theTime.getUTCMinutes();
var s = theTime.getUTCSeconds();
theString = h+':'+((m<10)?'0':'')+m + ((type=="timesec")?':'+((s<10)?'0':'')+s:'');
break;
case "password":
......
return theString;
}
function evalFunc_getSecs(timeObj) {
return Math.round(timeObj.getTime()/1000);
return Math.round(timeObj.getUTCSeconds()/1000);
}
// Seconds since midnight:
function evalFunc_getTime(timeObj) {
return timeObj.getUTCHours()*60*60+timeObj.getUTCMinutes()*60+Math.round(timeObj.getUTCSeconds()/1000);
}
function evalFunc_getYear(timeObj) {
return (timeObj.getYear()>200) ? timeObj.getYear() : (timeObj.getYear()+1900);
return timeObj.getUTCFullYear();
}
// Seconds since midnight with client timezone offset:
function evalFunc_getTimeSecs(timeObj) {
return timeObj.getHours()*60*60+timeObj.getMinutes()*60+timeObj.getSeconds();
}
function evalFunc_getDate(timeObj) {
var theTime = new Date(this.getYear(timeObj), timeObj.getUTCMonth(), timeObj.getUTCDate());
return this.getTimestamp(theTime);
}
function evalFunc_dummy (evallist,is_in,checkbox,checkboxValue) {
this.evallist = evallist;
this.is_in = is_in;
......
if(ePos == -1) {ePos = theStr.length;}
return (theStr.substring(sPos+lengthOfDelim,ePos));
}
function evalFunc_getTimestamp(timeObj) {
return Date.parse(timeObj)/1000;
}
t3lib/class.t3lib_tcemain.php (working copy)
switch($func) {
case 'int':
case 'year':
case 'date':
case 'datetime':
case 'time':
case 'timesec':
$value = intval($value);
break;
case 'date':
case 'datetime':
$value = intval($value);
if($value>0){
$zone = date('O',$value)/100;
$value -= ($zone*60*60);
}
break;
case 'double2':
$theDec = 0;
for ($a=strlen($value); $a>0; $a--) {
typo3/jsfunc.tbe_editor.js (working copy)
var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
if (checkbox_off) {
if (document[TBE_EDITOR.formname][theField+"_cb"].checked) {
var split = evallist.split(',');
for (var i = 0; split.length > i; i++) {
var el = split[i].replace(/ /g, '');
if (el == 'datetime' || el == 'date') {
var now = new Date();
checkSetValue = Date.parse(now)/1000 - now.getTimezoneOffset()*60;
break;
} else if (el == 'time' || el == 'timesec') {
checkSetValue = evalFunc_getTimeSecs(new Date());
break;
}
}
document[TBE_EDITOR.formname][theField].value=checkSetValue;
} else {
document[TBE_EDITOR.formname][theField].value=checkboxValue;
(1-1/2)