| Index: trunk/extensions/CategoryTree/CategoryTreeFunctions.php |
| — | — | @@ -331,13 +331,13 @@ |
| 332 | 332 | $s .= wfOpenElement( 'div', array( 'class' => 'CategoryTreeSection' ) ); |
| 333 | 333 | $s .= wfOpenElement( 'div', array( 'class' => 'CategoryTreeItem' ) ); |
| 334 | 334 | |
| 335 | | - $s .= wfOpenElement( 'span', array( 'class' => 'CategoryTreeBullet' ) ); |
| 336 | 335 | if ( $ns == NS_CATEGORY ) { |
| | 336 | + $s .= wfOpenElement( 'span', array( 'class' => 'CategoryTreeBullet' ) ); |
| 337 | 337 | $s .= '[' . wfElement( 'a', $linkattr, $txt ) . '] '; |
| | 338 | + $s .= wfCloseElement( 'span' ); |
| 338 | 339 | } else { |
| 339 | 340 | $s .= ' '; |
| 340 | 341 | } |
| 341 | | - $s .= wfCloseElement( 'span' ); |
| 342 | 342 | |
| 343 | 343 | $s .= wfOpenElement( 'a', array( 'class' => $labelClass, 'href' => $wikiLink ) ) . $label . wfCloseElement( 'a' ); |
| 344 | 344 | $s .= wfCloseElement( 'div' ); |
| Index: trunk/extensions/CategoryTree/CategoryTree.php |
| — | — | @@ -34,11 +34,10 @@ |
| 35 | 35 | * $wgCategoryTreeUseCache - enable HTTP cache for anon users. Default is false. |
| 36 | 36 | * $wgCategoryTreeUnifiedView - use unified view on category pages, instead of "tree" or "traditional list". Default is true. |
| 37 | 37 | * $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. |
| 43 | 42 | */ |
| 44 | 43 | |
| 45 | 44 | $wgCategoryTreeMaxChildren = 200; |
| — | — | @@ -48,7 +47,7 @@ |
| 49 | 48 | $wgCategoryTreeHTTPCache = false; |
| 50 | 49 | $wgCategoryTreeUnifiedView = true; |
| 51 | 50 | $wgCategoryTreeOmitNamespace = false; |
| 52 | | -$wgCategoryMaxDepth = array(1,2); |
| | 51 | +$wgCategoryTreeMaxDepth = array(CT_MODE_PAGES => 1, CT_MODE_ALL => 1, CT_MODE_CATEGORIES => 2); |
| 53 | 52 | |
| 54 | 53 | /** |
| 55 | 54 | * Register extension setup hook and credits |
| — | — | @@ -122,39 +121,23 @@ |
| 123 | 122 | * Internal function to cap depth |
| 124 | 123 | */ |
| 125 | 124 | |
| 126 | | -function efCategoryTreeCapDepth( $mode, $depth ) |
| 127 | | -{ |
| | 125 | +function efCategoryTreeCapDepth( $mode, $depth ) { |
| | 126 | + global $wgCategoryTreeMaxDepth; |
| 128 | 127 | |
| 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; |
| 134 | 131 | |
| 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); |
| 159 | 142 | } |
| 160 | 143 | |
| 161 | 144 | /** |
| — | — | @@ -205,13 +188,10 @@ |
| 206 | 189 | |
| 207 | 190 | $depth = efCategoryTreeCapDepth($mode,@$argv[ 'depth' ]); |
| 208 | 191 | |
| 209 | | - if ( $onlyroot ) $display = 'onlyroot'; |
| 210 | | - else if ( $hideroot ) $display = 'hideroot'; |
| 211 | | - else $display = 'expandroot'; |
| | 192 | + if ( $onlyroot ) $depth = 0; |
| 212 | 193 | |
| 213 | 194 | $ct = new CategoryTree; |
| 214 | 195 | return $ct->getTag( $parser, $cat, $mode, $hideroot, $style, $depth ); |
| 215 | | - return $ct->getTag( $parser, $cat, $mode, $display, $style, $depth ); |
| 216 | 196 | } |
| 217 | 197 | |
| 218 | 198 | /** |