[TYPO3-core] RFC: Fix negative age in FE

Wolfgang Klinger wolfgang at stufenlos.net
Tue Feb 28 08:11:45 CET 2006


 *hiya!*

 On Tue, 28 Feb 2006, Bernhard Kraft wrote the following:
> Description (copy from BT):
> There are two different methods used for calculating the age of a record. As the on in tslib_content always seems to get used for calculating a real age of a news record or something it seems it never has occured that somebody outputted the age of a timestamp which lies in the future.
> 
> There is a little difference between the method t3lib_BEfunc::calcAge and tslib_cObj->calcAge. The difference is that currently in the FE version no abs() is done and thus negative timestamps will always be lower than 3600 and the first if condition will always match.
> 
> Solution (would also be nice to use this on for the BE or have ONE SHARED method:
> Make a variable which contains the absolute value of the seconds value.
> Compare in which unit to display using the absolute value.
> Generate the output using the original value (no need for a $prefix variable and string juggling)

 +1

> I guess we need some kind of library framework.
> Currently we have t3lib_div if we want something to be callable from FE and BE and stuff everything
> in.
> 
> This is not good for one reasons which others are surely other minded: you can't XCLASS t3lib_div.
> 
> and another one: we get one huge unmaintainable class.
> 
> I would propose to filter out which methods in t3lib_div are about what and then split them up in
> for example:
> class.t3lib_datetime.php
> class.t3lib_io.php

 Yes.

> or class.t3lib_whatever.php (<- this one is my favourite ... it will be the successor of t3lib_div :)

 *hehe*

> We also should tend to always generate instances of our objects. I don't know which of you know
> about the "Design Pattern" "Singleton" but we already have it in T3.
> The method to instanciate a singleton in T3 is:
> $cObj = t3lib_div::getUserObj(':&tslib_cObj', 'tslib_');
> instead of
> $cObj = t3lib_div::makeInstance('tslib_cObj');
> 
> By using the & you will have only one instance !!

 I think a static call is rather equal or even faster in processing
 time compared to calling an instanciated object's method, so the
 sentence "We also should tend to always generate instances of our
 objects" is a bit misleading in my eyes.
 That's only reasonable where applicable.


 bye
 Wolfgang




More information about the TYPO3-team-core mailing list