Index: lib/TWiki/Plugins/TreePlugin.pm
===================================================================
--- lib/TWiki/Plugins/TreePlugin.pm (revision 11499)
+++ lib/TWiki/Plugins/TreePlugin.pm (working copy)
@@ -36,7 +36,7 @@
%FormatMap $RootLabel
);
-$VERSION = '$Rev$';
+$VERSION = 'v0.6';
$RootLabel = "_RootLabel_"; # what we use to label the root of a tree if not a topic
@@ -194,9 +194,19 @@
my ($topic, $modTime, $author, $summary) = split /\|/; # parse out data
# get parent
- my( $meta, $text ) = &TWiki::Func::readTopic( $attrWeb, $topic );
+ my( $meta, $text ) = &TWiki::Func::readTopic( $attrWeb, $topic );
+
+ my $ref=0;
+ if ($TWiki::Plugins::VERSION < 1.1)
+ {
+ $ref = $meta->findOne( "TOPICPARENT" );
+ }
+ else
+ {
+ $ref = $meta->get( "TOPICPARENT" );
+ }
- my $ref = $meta->get( "TOPICPARENT" );
+
my %par = (defined $ref ? %$ref : ());
my $parent = ( %par )
? _findTWikiNode($par{"name"}, \%nodes) # yes i have a parent, get it
@@ -244,6 +254,14 @@
}
#$renderedTree = $AGdebugmsg . $renderedTree;
$renderedTree = "
" . $renderedTree . "
";
+
+ #SL: Substitute $index in the rendered tree, $index is most useful to implement menus in combination with TreeBrowserPlugin
+ if (defined $formatter->data("format"))
+ {
+ my $Index=0;
+ $renderedTree =~ s/\$Index/$Index++;$Index/egi;
+ }
+
return $renderedTree;
}
@@ -405,9 +423,20 @@
my $formfields;
# so: is new topic to have a form? if so, put in new fields
- my $ref = $meta->get( "FORM" );
- my %form = (defined $ref ? %$ref : ());
- #my %form = $meta->get( "FORM" );
+
+
+ my $ref=0;
+ if ($TWiki::Plugins::VERSION < 1.1)
+ {
+ $ref = $meta->findOne( "FORM" );
+ }
+ else
+ {
+ $ref = $meta->get( "FORM" );
+ }
+
+ my %form = (defined $ref ? %$ref : ());
+
if( %form ) {
my $name = $form{"name"};
$formfields = &TWiki::Form::getFieldParams($meta);
@@ -435,9 +464,17 @@
}
# get this form name
- my $ref = $meta->get( "FORM" );
- my %form = (defined $ref ? %$ref : ());
- #my %form = $meta->get( "FORM" );
+ my $ref=0;
+ if ($TWiki::Plugins::VERSION < 1.1)
+ {
+ $ref = $meta->findOne( "FORM" );
+ }
+ else
+ {
+ $ref = $meta->get( "FORM" );
+ }
+
+ my %form = (defined $ref ? %$ref : ());
my $name = $form{"name"} if ( %form ) || "";
# get new form name, if any
Index: lib/TWiki/Plugins/TreePlugin/FormatOutlineNodeFormatter.pm
===================================================================
--- lib/TWiki/Plugins/TreePlugin/FormatOutlineNodeFormatter.pm (revision 11500)
+++ lib/TWiki/Plugins/TreePlugin/FormatOutlineNodeFormatter.pm (working copy)
@@ -49,18 +49,12 @@
sub formatNode {
my ($this, $node, $count, $level) = @_;
- #SL: do not render at level 0
+ #SL: do not render at level 0 when using "levelprefix"
if ($level == 0 && $this->data("levelprefix"))
{
return "";
}
- #SL: Experiments
- #my $itemcount=$this->formatCount($count)+$this->formatCount($level); #=(defined $this->data("itemcount")?$this->data("itemcount"):0);
- #my $itemcount=(defined $this->data("itemcount")?$this->data("itemcount"):0);
- #$itemcount++;
- #$this->data("itemcount",$itemcount);
-
my $res = $this->data("format");
my $nodeLinkName = '[[' . $node->name() . ']]';
@@ -75,8 +69,6 @@
$res =~ s/\$outnum/$this->formatOutNum($node)/geo;
$res =~ s/\$count/$this->formatCount($count)/geo;
- #SL: Experiments
- #$res =~ s/\$itemcount/$itemcount/geoi;
$res =~ s/\$level/$this->formatLevel($level)/geo;
$res =~ s/\$n/\n/go;
@@ -96,7 +88,7 @@
# some meta substitutions go here
}
- #SL: levelprefix
+ #SL: levelprefix allows rendering of bullet list using TWiki syntax thus enabling combination with TreeBrowserPlugin
if (defined($this->data("levelprefix")))
{
my $i=$level;
Index: data/TWiki/TreePlugin.txt
===================================================================
--- data/TWiki/TreePlugin.txt (revision 11501)
+++ data/TWiki/TreePlugin.txt (working copy)
@@ -1,4 +1,4 @@
-%META:TOPICINFO{author="StephaneLenclud" date="1158443010" format="1.1" reprev="1.5" version="1.5"}%
+%META:TOPICINFO{author="StephaneLenclud" date="1159730103" format="1.1" reprev="1.7" version="1.7"}%
---+!! %TOPIC%
Enables dynamic generation of TWiki topic trees based on topics' parent-child relationships.
@@ -48,6 +48,7 @@
* _$modTime_ - the topic's modification time
* _$level_ - the tree depth of the topic (in whatever format)
* _$count_ - the topic's child position
+ * _$index_ - the index of the topic in the tree. Starts from one. Most useful when used in combination with [[TWiki:Plugins.TreeBrowserPlugin][TreeBrowserPlugin]]
* _$onum_ - outline number for the topic (eg, 1.3.4.2)
* _$url_ - the current topic's URL
* *formatbranch* - specify the format for a group of children (=outline= & =coloroutline=)
@@ -136,9 +137,10 @@
| One Line Description: | View Twiki topics as nodes in a tree |
| Plugin Author: | TWiki:Main.SlavaKozlov |
-| Plugin Version: | v0.5 |
+| Plugin Version: | v0.6 |
| Change History: | |
-| 16 Sep 2006: | (v0.5) - TWiki:Main.StephaneLenclud: adding levelprefix parameter to unable usage in combination with TreeBrowserPlugin |
+| 1 Oct 2006: | (v0.6) - TWiki:Main.StephaneLenclud: adding =$index= format subsitution. Useful when used in combination with TreeBrowserPlugin. Also attempting to restore compatibility with Cairo, but still waiting for someone to test it. |
+| 16 Sep 2006: | (v0.5) - TWiki:Main.StephaneLenclud: adding =levelprefix= parameter to unable usage in combination with TreeBrowserPlugin. |
| 26 Jul 2006: | (v0.4) - TWiki:Main.SteffenPoulsen: Ported to TWiki-4 / Dakar. Leading text removed, less warnings, no double bracket links, css classnames around output. |
| 15 Feb 2002: | Alpha (0.2) release |
| 08 Feb 2002: | Internal (0.1) release |
Index: data/Sandbox/HeadingOutlineSample.txt
===================================================================
--- data/Sandbox/HeadingOutlineSample.txt (revision 11391)
+++ data/Sandbox/HeadingOutlineSample.txt (working copy)
@@ -1,4 +1,4 @@
-%META:TOPICINFO{author="MartinRaabe" date="1042728360" format="1.0" version="1.1"}%
+
%META:TOPICPARENT{name="TreePluginSamples"}%
Index: data/Sandbox/TreePluginSamples.txt
===================================================================
--- data/Sandbox/TreePluginSamples.txt (revision 11391)
+++ data/Sandbox/TreePluginSamples.txt (working copy)
@@ -1,4 +1,4 @@
-%META:TOPICINFO{author="MartinRaabe" date="1042732920" format="1.0" version="1.2"}%
+
%META:TOPICPARENT{name="TWiki.TreePlugin"}%
Here are some ways of using %TWIKIWEB%.TreePlugin's =%TREEVIEW%= tag.
Index: data/Sandbox/TreeBookviewOutlineSample.txt
===================================================================
--- data/Sandbox/TreeBookviewOutlineSample.txt (revision 11391)
+++ data/Sandbox/TreeBookviewOutlineSample.txt (working copy)
@@ -1,4 +1,4 @@
-%META:TOPICINFO{author="MartinRaabe" date="1042728240" format="1.0" version="1.1"}%
+
%META:TOPICPARENT{name="TreePluginSamples"}%