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

Bernhard Kraft kraftb at kraftb.at
Tue Feb 28 07:42:11 CET 2006


Hello,


This is a CVS patch request.


BT reference:
http://bugs.typo3.org/view.php?id=2716


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)


Extra about a "SHARED" method:

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

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 !!



greets,
Bernhard
-- 
----------------------------------------------------------------------
"Freiheit ist immer auch die Freiheit des Andersdenkenden"
Rosa Luxemburg, 1871 - 1919
----------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: correct_negativeAge_2006-02-28.diff
Type: text/x-patch
Size: 716 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20060228/6d255d7c/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20060228/6d255d7c/attachment.pgp 


More information about the TYPO3-team-core mailing list