Skip to content

Commit

Permalink
Item10760: corrected the code to fix bug from previous commit. now br…
Browse files Browse the repository at this point in the history
…anchfooter and branchheader parameters should function accordingly.

git-svn-id: http://svn.foswiki.org/trunk/TopicRecursePlugin@11724 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
TemiVarghese authored and TemiVarghese committed May 19, 2011
1 parent 061c804 commit 9188d68
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions data/System/VarTOPICRECURSE.txt
Expand Up @@ -14,10 +14,10 @@
| =header="..."= %BR% \
=footer="..."= | Custom format results: see [[FormattedSearch]] for usage & examples | =*Search: '$rootquery'*$n= %BR% =*Total: $ntopics*= |
| =format="..."= %BR% \
| =branchheader="..."= %BR% \
=branchfooter="..."= | Custom format results: see [[FormattedSearch]] for usage & examples | |
=formatbranch="..."= %BR% \
=formatleaf="..."= | Custom format results: see [[FormattedSearch]] for usage &amp; examples; "branch" format is for nodes which have descendents; "leaf" format is for terminating nodes for which there are no others below. | =$indent* [<nop>[$web.<nop>$topic][$topic]]= |
| =branchheader="..."= %BR% \
=branchfooter="..."= | Custom format results: see [[FormattedSearch]] for usage &amp; examples | |
| =separator="..."= | Separator _between_ search hits. See [[#FormatTokens]] | =$n= |
| =nodelimit= | Maximum number of nodes to be displayed. 0 = no limit. | =50= |
| =depthlimit= | Maximum depth to recurse to. 0 = no limit. | =0= |
Expand Down
17 changes: 11 additions & 6 deletions lib/Foswiki/Plugins/TopicRecursePlugin/Core.pm
Expand Up @@ -96,8 +96,18 @@ sub formatNodes {
my $result = renderNode( $node, $spec->{formatbranch} );

if ( not $node->isRoot() ) {
push( @renderednodes, $spec->{branchheader}.$result.$spec->{branchfooter} );
push( @renderednodes, $result );
}
while ( $node->hasNext() ) {
my $child = $node->next();
push( @renderednodes, formatNodes( $child, $spec ));
}
if(@renderednodes){
my $length = $#renderednodes;
$renderednodes[0] = $spec->{branchheader}.$renderednodes[0];
$renderednodes[1] = $spec->{branchheader}.$renderednodes[1];
$renderednodes[$length] = $renderednodes[$length].$spec->{branchfooter}.$spec->{branchfooter};
}
}
else {

Expand All @@ -108,11 +118,6 @@ sub formatNodes {
push( @renderednodes, $result );
}
}
while ( $node->hasNext() ) {
my $child = $node->next();
push( @renderednodes, formatNodes( $child, $spec ) );
}

return @renderednodes;
}

Expand Down

0 comments on commit 9188d68

Please sign in to comment.