Skip to content

Commit

Permalink
Item11359:
Browse files Browse the repository at this point in the history
   * fixed filtering zero
   * fixed counting list items without formating them (thanks Oliver Krueger for pointing that out)
   *  added hideempty parameter to enable/disable rendering empty list items



git-svn-id: http://svn.foswiki.org/trunk/FilterPlugin@13591 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Jan 10, 2012
1 parent a8443d4 commit 2b97b8c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion data/System/FilterPlugin.txt
Expand Up @@ -90,6 +90,7 @@ prepended with a header and appended with a footer in case the list is not empty
* footer="...": footer string
* separator="...": string to be inserted between list items
* 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")
* skip="...": number of list items to skip, not adding them to the result
* sort="on,off,alpha,num,nocase" order of the formatted items (default "off")
Expand Down Expand Up @@ -258,11 +259,12 @@ compare with [[http://en.wikipedia.org/wiki/Category:Philosophy_articles_needing
* Set SHORTDESCRIPTION = Substitute and extract information from content by using regular expressions
-->
| Plugin Author: | Michael Daum |
| Copyright ©: | 2005-2011, Michael Daum http://michaeldaumconsulting.com |
| Copyright ©: | 2005-2012, Michael Daum http://michaeldaumconsulting.com |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 10 Jan 2012: | fixed filtering zero; fixed counting list items without formating them; added =hideempty= parameter to enable/disable rendering empty list items |
| 29 Sep 2011: | fixed SUBST macro =topic= param processing embedded META |
| 25 Aug 2011: | fixed perl rookie error initializing defaults |
| 14 Jul 2011: | fixed parsing zero values in lists (by Grzegorz Marszalek) |
Expand Down
4 changes: 2 additions & 2 deletions lib/Foswiki/Plugins/FilterPlugin.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2005-2011 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2005-2012 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -25,7 +25,7 @@ use vars qw(
);

$VERSION = '$Rev$';
$RELEASE = '2.07';
$RELEASE = '2.08';
$NO_PREFS_IN_TOPIC = 1;
$SHORTDESCRIPTION = 'Substitute and extract information from content by using regular expressions';

Expand Down
9 changes: 5 additions & 4 deletions lib/Foswiki/Plugins/FilterPlugin/Core.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2005-2011 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2005-2012 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -93,7 +93,7 @@ sub handleFilter {

# get the source text
my $text = '';
if ($theText) { # direct text
if (defined $theText) { # direct text
$text = $theText;
} else { # topic text
return '' if $filteredTopic{"$theWeb.$theTopic"};
Expand Down Expand Up @@ -529,6 +529,7 @@ sub handleFormatList {
my $theMap = $params->{map};
my $theNullFormat = $params->{null} || '';
my $theTokenize = $params->{tokenize};
my $theHideEmpty = Foswiki::Func::isTrue($params->{hideempty}, 1);

$theFormat = '$1' unless defined $theFormat;

Expand Down Expand Up @@ -637,15 +638,15 @@ sub handleFormatList {
next if $seen{$line};
$seen{$line} = 1;
}
next if $line eq '';

$line =~ s/\$index/$count+1/ge;
if ($theSelection && $item =~ /$theSelection/) {
$line =~ s/\$marker/$theMarker/g
} else {
$line =~ s/\$marker//go;
}
if ($skip-- <= 0) {
push @result, $line;
push @result, $line unless ($theHideEmpty && $line eq '');
$count++;
last if $theLimit - $count == 0;
}
Expand Down

0 comments on commit 2b97b8c

Please sign in to comment.