r34833 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34832‎ | r34833 | r34834 >
Date:22:11, 14 May 2008
Author:nad
Status:old
Tags:
Comment:
bug fix, only first tree on page would render correctly
Modified paths:
  • /trunk/extensions/TreeAndMenu/TreeAndMenu.php (modified) (history)

Diff [purge]

Index: trunk/extensions/TreeAndMenu/TreeAndMenu.php
@@ -10,7 +10,7 @@
1111
1212 if (!defined('MEDIAWIKI')) die('Not an entry point.');
1313
14 -define('TREEANDMENU_VERSION','1.0.0, 2008-04-17');
 14+define('TREEANDMENU_VERSION','1.0.1, 2008-05-15');
1515
1616 # Set any unset images to default titles
1717 if (!isset($wgTreeViewImages) || !is_array($wgTreeViewImages)) $wgTreeViewImages = array();
@@ -159,17 +159,19 @@
160160 }
161161
162162 # 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) {
168169 $node++;
169170 list($id,$depth,$icon,$item,$start) = $info;
170171 $args = $this->args[$id];
171172 $type = $args['type'];
 173+ $end = $node == count($rows) || $rows[$node][4];
172174 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;
174176
175177 # Append node script for this row
176178 if ($depth > $last) $parents[$depth] = $node-1;
@@ -200,7 +202,6 @@
201203 $$pos .= "<a href=\"javascript: {$this->uniqname}$id.{$arg}All();\">&nbsp;{$arg} all</a>&nbsp;";
202204 if ($top) $top = "<p>&nbsp;$top</p>";
203205 if ($bottom) $bottom = "<p>&nbsp;$bottom</p>";
204 - if ($root) $add = "tree.add(0,-1,'$root');";
205206 $html = "$top<div class='$class' id='$id'>
206207 <script type=\"$wgJsMimeType\">
207208 // TreeAndMenu{$this->version}

Status & tagging log