• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item5935: attach.pm enhancement: add time processing to code

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine   Enhancement Waiting for Feedback   n/a  

Edit Form Data

Summary:
Reported By:
Codebase:
Applies To:
Component:
Priority:
Current State:
Waiting For:
Target Release:
Released In:
 

Detail

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

ItemTemplate
Summary attach.pm enhancement: add time processing to code
ReportedBy TWiki:Main.SaschaVetter
Codebase 4.2.0, 4.2.1, 4.2.2
SVN Range TWiki-5.0.0, Mon, 11 Aug 2008, build 17408
AppliesTo Engine
Component

Priority Enhancement
CurrentState Waiting for Feedback
WaitingFor

Checkins

TargetRelease n/a
ReleasedIn

Topic revision: r1 - 2008-08-18 - SaschaVetter
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback