We relaunched the TWiki.org project with an expanded TWiki charter, and we invite you to participate! The TWiki.org Code of Conduct agreement took effect on 27 Oct 2008. We ask existing twiki.org users to opt-in. You need to opt-in to participate in the Blog, Codev, Plugins and TWiki webs. -- PeterThoeny - 27 Oct 2008
Tags:
create new tag
, view all tags

Question

I wanted to change ATTACHEDFILELINKFORMAT as specified in ConfigurableAttachLinkFormat. Now I wanted to use other place holders like $fileextension, $date (date the attachment was added) or $year-$mo-$day to be more precise.

Now I see that this is not possible. Is there a extension planed or do I need to request that for further development? Is it possible to set this variable in the topic I want to attach to (or any topic that is included)?

Environment

TWiki version: TWikiRelease04x01x02
TWiki plugins: SpreadSheetPlugin? , BugzillaLinkPlugin? , BugzillaQueryPlugin? , ChartPlugin? , CommentPlugin? , CounterPlugin? , EasyTimelinePlugin? , EditTablePlugin? , GlobalReplacePlugin? , InterwikiPlugin? , PreferencesPlugin? , RedirectPlugin? , RenderListPlugin? , SlideShowPlugin? , SmiliesPlugin? , SnmpCommandPlugin? , TWikiDrawPlugin? , TablePlugin? , TextSectionPlugin? , TreeBrowserPlugin? , TreePlugin? , TwistyPlugin?
Server OS: CentOS? ?
Web server: Apache ?
Perl version: 5.6.1 ?
Client OS: MS Windows 2000 SP 4
Web Browser: Mozilla FireFox? 2.0.0.12
Categories: Missing functionality

-- MichaelDeckert - 26 Mar 2008

Answer

ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.

I think I found an answer myself. I changed some details in Time.pm:

    $value = $formatString;
    $value =~ s/\$seco?n?d?s?/sprintf('%02d',$sec)/gei;
    $value =~ s/\$minu?t?e?s?/sprintf('%02d',$min)/gei;
    $value =~ s/\$hour?s?/sprintf('%02d',$hour)/gei;
    $value =~ s/\$day/sprintf('%02d',$day)/gei;
    $value =~ s/\$wday/$WEEKDAY[$wday]/gi;
    $value =~ s/\$dow/$wday/gi;
    $value =~ s/\$week/_weekNumber($day,$mon,$year,$wday)/egi;
    $value =~ s/\$mont?h?/$ISOMONTH[$mon]/gi;
    $value =~ s/\$mo/sprintf('%02d',$mon+1)/gei;
    $value =~ s/\$year?/sprintf('%04d',$year+1900)/gei;
    $value =~ s/\$ye/sprintf('%02d',$year%100)/gei;
    $value =~ s/\$epoch/$epochSeconds/gi;

so have leading zeros. Then i added to Attach.pm:

...
    $fileComment = $attName unless ( $fileComment );
    my $date = $att->{date} if defined $att->{date};
...

and

...
    $fileLink =~ s/\$name/$attName/;

    my $fileext = $attName;
    $fileext =~ s/(.*\.)*([^.]*)/\2/;
    $fileLink =~ s/\$fileext/$fileext/;

    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;
...

-- MichaelDeckert - 27 Mar 2008

 
Change status to:
Topic revision: r2 - 27 Mar 2008 - 07:33:31 - MichaelDeckert
 
TWIKI.NET
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback