Index: trunk/extensions/TreeAndMenu/TreeAndMenu.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | |
12 | 12 | if (!defined('MEDIAWIKI')) die('Not an entry point.'); |
13 | 13 | |
14 | | -define('TREEANDMENU_VERSION','1.0.0, 2008-04-17'); |
| 14 | +define('TREEANDMENU_VERSION','1.0.1, 2008-05-15'); |
15 | 15 | |
16 | 16 | # Set any unset images to default titles |
17 | 17 | if (!isset($wgTreeViewImages) || !is_array($wgTreeViewImages)) $wgTreeViewImages = array(); |
— | — | @@ -159,17 +159,19 @@ |
160 | 160 | } |
161 | 161 | |
162 | 162 | # PASS-2: build the JavaScript and replace into $text |
163 | | - $parents = array(); # parent node for each depth |
164 | | - $parity = array(); # keep track of odd/even rows for each depth |
165 | | - $last = -1; |
166 | | - $nodes = ''; |
167 | | - foreach ($rows as $node => $info) { |
| 163 | + $parents = array(); # parent node for each depth |
| 164 | + $parity = array(); # keep track of odd/even rows for each depth |
| 165 | + $node = 0; |
| 166 | + $last = -1; |
| 167 | + $nodes = ''; |
| 168 | + foreach ($rows as $info) { |
168 | 169 | $node++; |
169 | 170 | list($id,$depth,$icon,$item,$start) = $info; |
170 | 171 | $args = $this->args[$id]; |
171 | 172 | $type = $args['type']; |
| 173 | + $end = $node == count($rows) || $rows[$node][4]; |
172 | 174 | if (!isset($args['root'])) $args['root'] = ''; # tmp - need to handle rootless trees |
173 | | - $end = $node == count($rows) || $rows[$node][4]; |
| 175 | + if ($start) $node = 1; |
174 | 176 | |
175 | 177 | # Append node script for this row |
176 | 178 | if ($depth > $last) $parents[$depth] = $node-1; |
— | — | @@ -200,7 +202,6 @@ |
201 | 203 | $$pos .= "<a href=\"javascript: {$this->uniqname}$id.{$arg}All();\"> {$arg} all</a> "; |
202 | 204 | if ($top) $top = "<p> $top</p>"; |
203 | 205 | if ($bottom) $bottom = "<p> $bottom</p>"; |
204 | | - if ($root) $add = "tree.add(0,-1,'$root');"; |
205 | 206 | $html = "$top<div class='$class' id='$id'> |
206 | 207 | <script type=\"$wgJsMimeType\"> |
207 | 208 | // TreeAndMenu{$this->version} |