Skip to content

Commit

Permalink
Item11807:
Browse files Browse the repository at this point in the history
   * add lastseparator to FORMATLIST
   * fixed paging when using together with =include= and =exclude= parameters



git-svn-id: http://svn.foswiki.org/trunk/FilterPlugin@15048 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Jun 19, 2012
1 parent 9600b8b commit 839d72a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 26 deletions.
25 changes: 5 additions & 20 deletions data/System/FilterPlugin.txt
@@ -1,23 +1,7 @@
%META:TOPICINFO{author="ProjectContributor" comment="reprev" date="1275898567" format="1.1" reprev="3" version="3"}%
<!--

PLEASE DO NOT EDIT THIS TOPIC

It is automatically generated from the subversion repository, and any changes
you make will simply be overwritten the next time a release is generated.

Instead, you could check your fix in, raise a bug in the Bugs web, or mail the author.
-->
---+!! <nop>%TOPIC%
---+!! %TOPIC%
%TOC%
<table style="float:right">
<tr>
<td><img src="%ATTACHURLPATH%/wikiringlogo40x40.png"></td>
<td><a href="http://wikiring.com" title="Make your Wiki ring!" style="text-decoration:none">
Powered by <br /> <nop>WikiRing Consultants </a>
</td>
</tr>
</table>

---++ Description
This plugin allows to substitute and extract information from content by
using regular expressions. There are three different types of new functions:
Expand Down Expand Up @@ -90,6 +74,7 @@ prepended with a header and appended with a footer in case the list is not empty
* header="...": header string
* footer="...": footer string
* separator="...": string to be inserted between list items
* lastseparator="...": string separating the last item from the rest of the list
* null="...": the format string to render the empty list
* hideempty="on,off": when set to "on" then empty list items will not be added to the result (empty in the sense of ''); set this to "off" to still add them (default "on")
* limit="...": max number of items to be taken out of the list (default "-1")
Expand Down Expand Up @@ -267,6 +252,8 @@ compare with [[http://en.wikipedia.org/wiki/Category:Philosophy_articles_needing
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 19 Jun 2012: | added =lastseparator= (by Foswiki:Main/OliverKrueger);\
fixed paging when using together with =include= and =exclude= parameters |
| 15 May 2012: | fixed paging through lists in FORMATLIST |
| 05 May 2012: | fixed lists not being processed properly before iterating over them in FORMATLIST and MAKEINDEX |
| 19 Apr 2012: | modernized plugin by using a proper OO-core; \
Expand Down Expand Up @@ -315,5 +302,3 @@ compare with [[http://en.wikipedia.org/wiki/Category:Philosophy_articles_needing
| Other Dependencies: | none |
| Plugin Home: | Foswiki:Extensions/%TOPIC% |
| Support: | Foswiki:Support/%TOPIC% |

%META:FILEATTACHMENT{name="wikiringlogo40x40.png" attr="h" autoattached="1" comment="" date="1189788323" path="wikiringlogo40x40.png" size="2571" user="ProjectContributor" version="1"}%
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/FilterPlugin.pm
Expand Up @@ -22,7 +22,7 @@ use warnings;
use Foswiki::Func();

our $VERSION = '$Rev$';
our $RELEASE = '3.02';
our $RELEASE = '3.10';
our $NO_PREFS_IN_TOPIC = 1;
our $SHORTDESCRIPTION = 'Substitute and extract information from content by using regular expressions';
our $core;
Expand Down
16 changes: 12 additions & 4 deletions lib/Foswiki/Plugins/FilterPlugin/Core.pm
Expand Up @@ -518,6 +518,7 @@ sub handleFormatList {
my $theFooter = $params->{footer} || '';
my $theSplit = $params->{split};
my $theSeparator = $params->{separator};
my $theLastSeparator = $params->{lastseparator};
my $theLimit = $params->{limit};
my $theSkip = $params->{skip} || 0;
my $theSort = $params->{sort} || 'off';
Expand Down Expand Up @@ -547,6 +548,7 @@ sub handleFormatList {
#writeDebug("theFormat='$theFormat'");
#writeDebug("theSplit='$theSplit'");
#writeDebug("theSeparator='$theSeparator'");
#writeDebug("theLastSeparator='$theLastSeparator'");
#writeDebug("theLimit='$theLimit'");
#writeDebug("theSkip='$theSkip'");
#writeDebug("theSort='$theSort'");
Expand Down Expand Up @@ -602,15 +604,16 @@ sub handleFormatList {
if ($theLimit) {
my %seen = ();
foreach my $item (@theList) {
$count++;
next if $count <= $theSkip;
last if $theLimit > 0 && $hits >= $theLimit;

#writeDebug("found '$item'");
next if $theExclude && $item =~ /^($theExclude)$/;
next if $theInclude && $item !~ /^($theInclude)$/;
next if $item =~ /^$/; # skip empty elements

$count++;
next if $count <= $theSkip;
last if $theLimit > 0 && $hits >= $theLimit;

my $arg1 = '';
my $arg2 = '';
my $arg3 = '';
Expand Down Expand Up @@ -680,7 +683,12 @@ sub handleFormatList {
return '' unless $theNullFormat;
$result = $theNullFormat;
} else {
$result = join($theSeparator, @result);
if (defined($theLastSeparator) && ($count > 1)) {
my $lastElement = pop(@result);
$result = join($theSeparator, @result) . $theLastSeparator . $lastElement;
} else {
$result = join($theSeparator, @result);
}
}

$result = $theHeader.$result.$theFooter;
Expand Down
1 change: 0 additions & 1 deletion lib/Foswiki/Plugins/FilterPlugin/MANIFEST
@@ -1,4 +1,3 @@
data/System/FilterPlugin.txt 0644
lib/Foswiki/Plugins/FilterPlugin/Core.pm 0644
lib/Foswiki/Plugins/FilterPlugin.pm 0644
pub/System/FilterPlugin/wikiringlogo40x40.png 0644
Binary file removed pub/System/FilterPlugin/wikiringlogo40x40.png
Binary file not shown.

0 comments on commit 839d72a

Please sign in to comment.