r20839 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20838‎ | r20839 | r20840 >
Date:13:28, 30 March 2007
Author:daniel
Status:old
Tags:
Comment:
removing empty spans for w3c conformity, as suggested by Miki11
Modified paths:
  • /trunk/extensions/CategoryTree/CategoryTree.php (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTreeFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CategoryTree/CategoryTreeFunctions.php
@@ -331,13 +331,13 @@
332332 $s .= wfOpenElement( 'div', array( 'class' => 'CategoryTreeSection' ) );
333333 $s .= wfOpenElement( 'div', array( 'class' => 'CategoryTreeItem' ) );
334334
335 - $s .= wfOpenElement( 'span', array( 'class' => 'CategoryTreeBullet' ) );
336335 if ( $ns == NS_CATEGORY ) {
 336+ $s .= wfOpenElement( 'span', array( 'class' => 'CategoryTreeBullet' ) );
337337 $s .= '[' . wfElement( 'a', $linkattr, $txt ) . '] ';
 338+ $s .= wfCloseElement( 'span' );
338339 } else {
339340 $s .= ' ';
340341 }
341 - $s .= wfCloseElement( 'span' );
342342
343343 $s .= wfOpenElement( 'a', array( 'class' => $labelClass, 'href' => $wikiLink ) ) . $label . wfCloseElement( 'a' );
344344 $s .= wfCloseElement( 'div' );
Index: trunk/extensions/CategoryTree/CategoryTree.php
@@ -34,11 +34,10 @@
3535 * $wgCategoryTreeUseCache - enable HTTP cache for anon users. Default is false.
3636 * $wgCategoryTreeUnifiedView - use unified view on category pages, instead of "tree" or "traditional list". Default is true.
3737 * $wgCategoryTreeOmitNamespace - never show namespace prefix. Default is false
38 -
39 - * $wgCategoryMaxDepth - maximum value for depth argument; can be an
40 - * integer, or an array of two integers. The first element is the maximum
41 - * depth for the "pages" and "all" modes; the second is for the categories
42 - * mode. Ignored if $wgCategoryTreeDynamicTag is true.
 38+ * $wgCategoryTreeMaxDepth - maximum value for depth argument; An array that maps mode values to
 39+ * the maximum depth acceptable for the depth option.
 40+ * Per default, the "categories" mode has a max depth of 2,
 41+ * all other modes have a max depth of 1.
4342 */
4443
4544 $wgCategoryTreeMaxChildren = 200;
@@ -48,7 +47,7 @@
4948 $wgCategoryTreeHTTPCache = false;
5049 $wgCategoryTreeUnifiedView = true;
5150 $wgCategoryTreeOmitNamespace = false;
52 -$wgCategoryMaxDepth = array(1,2);
 51+$wgCategoryTreeMaxDepth = array(CT_MODE_PAGES => 1, CT_MODE_ALL => 1, CT_MODE_CATEGORIES => 2);
5352
5453 /**
5554 * Register extension setup hook and credits
@@ -122,39 +121,23 @@
123122 * Internal function to cap depth
124123 */
125124
126 -function efCategoryTreeCapDepth( $mode, $depth )
127 -{
 125+function efCategoryTreeCapDepth( $mode, $depth ) {
 126+ global $wgCategoryTreeMaxDepth;
128127
129 - if (is_numeric($depth))
130 - $depth = intval($depth);
131 - else
132 - $depth = 1;
133 -
 128+ if (is_numeric($depth))
 129+ $depth = intval($depth);
 130+ else return 1;
134131
135 - global $wgCategoryMaxDepth;
136 - if (is_array($wgCategoryMaxDepth)) {
137 - switch($mode) {
138 - case CT_MODE_PAGES:
139 - case CT_MODE_ALL:
140 - $max = isset($wgCategoryMaxDepth[0])?$wgCategoryMaxDepth[0]:1;
141 - break;
142 - case CT_MODE_CATEGORIES:
143 - default:
144 - $max = isset($wgCategoryMaxDepth[1])?$wgCategoryMaxDepth[1]:1;
145 - break;
146 - }
147 - } elseif (is_numeric($wgCategoryMaxDepth)) {
148 - $max = $wgCategoryMaxDepth;
149 - } else {
150 - wfDebug( 'efCategoryTreeCapDepth: $wgCategoryMaxDepth is invalid.' );
151 - $max = 1;
152 - }
153 -
154 - //echo "mode $mode:max is $max\n";
155 - if ($depth>$max)
156 - $depth = $max;
157 -
158 - return $depth;
 132+ if (is_array($wgCategoryTreeMaxDepth)) {
 133+ $max = isset($wgCategoryTreeMaxDepth[$mode]) ? $wgCategoryTreeMaxDepth[$mode] : 1;
 134+ } elseif (is_numeric($wgCategoryTreeMaxDepth)) {
 135+ $max = $wgCategoryTreeMaxDepth;
 136+ } else {
 137+ wfDebug( 'efCategoryTreeCapDepth: $wgCategoryTreeMaxDepth is invalid.' );
 138+ $max = 1;
 139+ }
 140+
 141+ return min($depth, $max);
159142 }
160143
161144 /**
@@ -205,13 +188,10 @@
206189
207190 $depth = efCategoryTreeCapDepth($mode,@$argv[ 'depth' ]);
208191
209 - if ( $onlyroot ) $display = 'onlyroot';
210 - else if ( $hideroot ) $display = 'hideroot';
211 - else $display = 'expandroot';
 192+ if ( $onlyroot ) $depth = 0;
212193
213194 $ct = new CategoryTree;
214195 return $ct->getTag( $parser, $cat, $mode, $hideroot, $style, $depth );
215 - return $ct->getTag( $parser, $cat, $mode, $display, $style, $depth );
216196 }
217197
218198 /**