Following changes to lib/TWiki/attach.pm allows time/date processing:
Add after
use strict;
use Assert;
use TWiki::Time;
and add before
# I18N: Site specified %ATTACHEDIMAGEFORMAT% or %ATTACHEDFILELINKFORMAT%,
# ensure that filename is URL encoded - first $name must be URL.
$fileLink =~ s/\$name/$fileURL/;
$fileLink =~ s/\$name/$attName/;
my $fileext = $attName;
$fileext =~ s/(.*\.)*([^.]*)/$2/;
$fileLink =~ s/\$fileext/$fileext/;
if (defined $att->{date})
{
my $date = $att->{date};
use Time::localtime;
my ($seconds,$minutes,$hours,$day,$mo,$ye,$wday,$ydat,$isdst) = gmtime($date);
#require TWiki::time;
$fileLink =~ s/\$date/TWiki::Time::formatTime( $date || 0)/gei;
$fileLink =~ s/\$seconds/TWiki::Time::formatTime( $date || 0, "\$seconds")/gei;
$fileLink =~ s/\$minutes/TWiki::Time::formatTime( $date || 0, "\$minutes")/gei;
$fileLink =~ s/\$hours/TWiki::Time::formatTime( $date || 0, "\$hours")/gei;
$fileLink =~ s/\$wday/TWiki::Time::formatTime( $date || 0, "\$wday")/gei;
$fileLink =~ s/\$day/TWiki::Time::formatTime( $date || 0, "\$day")/gei;
$fileLink =~ s/\$month/TWiki::Time::formatTime( $date || 0, "\$month")/gei;
$fileLink =~ s/\$mo/TWiki::Time::formatTime( $date || 0, "\$mo")/gei;
$fileLink =~ s/\$year/TWiki::Time::formatTime( $date || 0, "\$year")/gei;
$fileLink =~ s/\$ye/TWiki::Time::formatTime( $date || 0, "\$ye")/gei;
}
After this change, following attachment example is possible:
On TWIki Site:
* Local ATTACHEDFILELINKFORMAT = |$year-$mo-$day|Effort |[[%ATTACHURL%/$name][%ICON{$fileext}% $name]]| received from company xy |
Simple enhancement with nice effects, good enough to add to the next twiki version?
--
TWiki:Main/SaschaVetter
- 18 Aug 2008