From: <de...@de...> - 2008-07-27 10:15:59
|
Author: ArthurClemens Date: 2008-07-27 05:16:08 -0500 (Sun, 27 Jul 2008) New Revision: 17146 Trac url: http://develop.twiki.org/trac/changeset/17146 Modified: twiki/trunk/AttachmentListPlugin/data/TWiki/AttachmentListPlugin.txt twiki/trunk/AttachmentListPlugin/lib/TWiki/Plugins/AttachmentListPlugin.pm Log: Item5736: fix localization in $fileUrl using fix of AurelioAHeckert; add newline before footer Modified: twiki/trunk/AttachmentListPlugin/data/TWiki/AttachmentListPlugin.txt =================================================================== --- twiki/trunk/AttachmentListPlugin/data/TWiki/AttachmentListPlugin.txt 2008-07-27 00:03:06 UTC (rev 17145) +++ twiki/trunk/AttachmentListPlugin/data/TWiki/AttachmentListPlugin.txt 2008-07-27 10:16:08 UTC (rev 17146) @@ -191,7 +191,7 @@ | Copyright ©: | TWiki:Main.VinodKulkarni, TWiki:Main.SopanShewale (2006), TWiki:Main.ArthurClemens (2006, 2007, 2008) | | License: | [[http://www.gnu.org/copyleft/gpl.html][GPL]] | | Dependencies: | %$DEPENDENCIES% | -| Plugin Version: | 24 Feb 2008 (V1.2.4) | +| Plugin Version: | 27 Jul 2008 (V1.2.5) | | Change History: | <!-- versions below in reverse order --> | | 20 Feb 2008 - v.1.2.1 - 1.2.3 | Arthur Clemens: Fixed error with format tokens on TWiki older than 4.2; by default sort files by name. | | 20 Feb 2008 - v.1.2 | Arthur Clemens: Added parameter =includefilepattern= and formatting parameter =$fileExtension=. When using parameter =sort= the files are now secondary sorted on filename. Added decoding of format tokens. | Modified: twiki/trunk/AttachmentListPlugin/lib/TWiki/Plugins/AttachmentListPlugin.pm =================================================================== --- twiki/trunk/AttachmentListPlugin/lib/TWiki/Plugins/AttachmentListPlugin.pm 2008-07-27 00:03:06 UTC (rev 17145) +++ twiki/trunk/AttachmentListPlugin/lib/TWiki/Plugins/AttachmentListPlugin.pm 2008-07-27 10:16:08 UTC (rev 17146) @@ -28,7 +28,7 @@ # This is a free-form string you can use to "name" your own plugin version. # It is *not* used by the build automation tools, but is reported as part # of the version number in PLUGINDESCRIPTIONS. -$RELEASE = '1.2.4'; +$RELEASE = '1.2.5'; $pluginName = 'AttachmentListPlugin'; # Name of this Plugin @@ -49,7 +49,8 @@ $defaultFormat = ' * [[$fileUrl][$fileName]] $fileComment'; # Get plugin preferences - $defaultFormat = TWiki::Func::getPreferencesValue('FORMAT') + $defaultFormat = + TWiki::Func::getPreferencesValue('FORMAT') || TWiki::Func::getPluginPreferencesValue('FORMAT') || $defaultFormat; @@ -58,7 +59,8 @@ $imageFormat = '<img src=\'$fileUrl\' alt=\'$fileComment\' />'; # Get plugin preferences - $imageFormat = TWiki::Func::getPreferencesValue('IMAGE_FORMAT') + $imageFormat = + TWiki::Func::getPreferencesValue('IMAGE_FORMAT') || TWiki::Func::getPluginPreferencesValue('IMAGE_FORMAT') || $imageFormat; @@ -111,6 +113,7 @@ my $excludeWebs = $params->{'excludeweb'} || ''; my $excludeFiles = $params->{'excludefile'} || ''; my $includeFilePattern = $params->{'includefilepattern'} || undef; + my $excludeFilePattern = $params->{'excludefilepattern'} || undef; my $excludeExtensionsParam = $params->{'excludeextension'} || ''; my $extensionsParam = $params->{"extension"} || $params->{"filter"}; # "abc, def" syntax. Substring match will be used @@ -136,6 +139,9 @@ : 0; # don't hide by default } + TWiki::Func::writeDebug("params->{'topic'}=$params->{'topic'}"); + TWiki::Func::writeDebug("includeFilePattern=$includeFilePattern"); + my %excludedFiles = makeHashFromString($excludeFiles); # store once for re-use in loop @@ -144,9 +150,10 @@ my @files = createAttachmentList( $topic, $web, $excludeTopics, $excludeWebs ); - my $sortedFiles = sortFileData( \@files, $sort, $sortOrder, $fromDate, $toDate ); + my $sortedFiles = + sortFileData( \@files, $sort, $sortOrder, $fromDate, $toDate ); my @sortedFiles = @$sortedFiles; - + my $count = 0; foreach my $fileData (@sortedFiles) { @@ -167,6 +174,7 @@ ); my $filename = $attachment->{name}; + TWiki::Func::writeDebug("filename=$filename"); # filter on extension my $fileExtension = $attachment->{_AttachmentListPlugin_extension}; @@ -184,6 +192,9 @@ if ( defined $includeFilePattern ) { next unless ( $filename =~ /$includeFilePattern/ ); } + if ( defined $excludeFilePattern ) { + next if ( $filename =~ /$excludeFilePattern/ ); + } my $attrSize = $attachment->{size}; my $attrUser = $attachment->{user} || 'UnknownUser'; @@ -297,8 +308,13 @@ $s =~ s/\$hidden/$hidden/g; } - my $fileUrl = - $pubUrl . "/$attachmentTopicWeb/$attachmentTopic/$filename"; + my $webEnc = $attachmentTopicWeb; + $webEnc =~ s/([^-_.a-zA-Z0-9])/sprintf("%%%02x",ord($1))/eg; + my $topicEnc = $attachmentTopic; + $topicEnc =~ s/([^-_.a-zA-Z0-9])/sprintf("%%%02x",ord($1))/eg; + my $fileEnc = $filename; + $fileEnc =~ s/([^-_.a-zA-Z0-9])/sprintf("%%%02x",ord($1))/eg; + my $fileUrl = "$pubUrl/$webEnc/$topicEnc/$fileEnc"; $s =~ s/\$fileUrl/$fileUrl/g; $s =~ s/\$fileTopic/$attachmentTopic/g; @@ -317,6 +333,7 @@ } else { $header .= "\n" if ( $header ne '' ); + $footer = "\n" . $footer if ( $footer ne '' ); $outtext = $header . $outtext . $footer; } |