Index: trunk/extensions/CategoryTree/CategoryTree.php |
— | — | @@ -5,8 +5,8 @@ |
6 | 6 | * to display the category structure of a wiki |
7 | 7 | * |
8 | 8 | * @addtogroup Extensions |
9 | | - * @author Daniel Kinzler <duesentrieb@brightbyte.de> |
10 | | - * @copyright © 2006 Daniel Kinzler |
| 9 | + * @author Daniel Kinzler, brightbyte.de |
| 10 | + * @copyright © 2006-2007 Daniel Kinzler |
11 | 11 | * @licence GNU General Public Licence 2.0 or later |
12 | 12 | */ |
13 | 13 | |
— | — | @@ -112,6 +112,25 @@ |
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
| 116 | +* Helper function to convert a string to a boolean value. |
| 117 | +* Perhaps make this a global function in MediaWiki proper |
| 118 | +*/ |
| 119 | +function efCategoryTreeAsBool( $s ) { |
| 120 | + if ( is_null( $s ) || is_bool( $s ) ) return $s; |
| 121 | + $s = trim( strtolower( $s ) ); |
| 122 | + |
| 123 | + if ( $s === '1' || $s === 'yes' || $s === 'on' || $s === 'true' ) { |
| 124 | + return true; |
| 125 | + } |
| 126 | + else if ( $s === '0' || $s === 'no' || $s === 'off' || $s === 'false' ) { |
| 127 | + return false; |
| 128 | + } |
| 129 | + else { |
| 130 | + return NULL; |
| 131 | + } |
| 132 | +} |
| 133 | + |
| 134 | +/** |
116 | 135 | * Entry point for the <categorytree> tag parser hook. |
117 | 136 | * This loads CategoryTreeFunctions.php and calls CategoryTree::getTag() |
118 | 137 | */ |
— | — | @@ -135,20 +154,15 @@ |
136 | 155 | $mode = CT_MODE_CATEGORIES; |
137 | 156 | } |
138 | 157 | |
139 | | - $hideroot = isset( $argv[ 'hideroot' ] ) ? $argv[ 'hideroot' ] : null; |
140 | | - if ( $hideroot !== NULL ) { |
141 | | - $hideroot = trim( strtolower( $hideroot ) ); |
142 | | - |
143 | | - if ( $hideroot === '1' || $hideroot === 'yes' || $hideroot === 'on' || $hideroot === 'true' ) { |
144 | | - $hideroot = true; |
145 | | - } |
146 | | - else if ( $hideroot === '0' || $hideroot === 'no' || $hideroot === 'off' || $hideroot === 'false' ) { |
147 | | - $hideroot = false; |
148 | | - } |
149 | | - } |
| 158 | + $hideroot = isset( $argv[ 'hideroot' ] ) ? efCategoryTreeAsBool( $argv[ 'hideroot' ] ) : null; |
| 159 | + $onlyroot = isset( $argv[ 'onlyroot' ] ) ? efCategoryTreeAsBool( $argv[ 'onlyroot' ] ) : null; |
150 | 160 | |
| 161 | + if ( $onlyroot ) $display = 'onlyroot'; |
| 162 | + else if ( $hideroot ) $display = 'hideroot'; |
| 163 | + else $display = 'expandroot'; |
| 164 | + |
151 | 165 | $ct = new CategoryTree; |
152 | | - return $ct->getTag( $parser, $cat, $mode, $hideroot, $style ); |
| 166 | + return $ct->getTag( $parser, $cat, $mode, $display, $style ); |
153 | 167 | } |
154 | 168 | |
155 | 169 | /** |
Index: trunk/extensions/CategoryTree/README |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | -------------------------------------------------------------------------- |
3 | 3 | README for the CategoryTree extension |
4 | | -Copyright © 2006 Daniel Kinzler |
| 4 | +Copyright © 2006-2007 Daniel Kinzler |
5 | 5 | Licenses: GNU General Public Licence (GPL) |
6 | 6 | GNU Free Documentation License (GFDL) |
7 | 7 | -------------------------------------------------------------------------- |
— | — | @@ -49,12 +49,14 @@ |
50 | 50 | |
51 | 51 | The custom tag is called <categorytree>. For example, if you put |
52 | 52 | <categorytree>Foo</categorytree> on a wiki page, it will show the contents |
53 | | -of category Foo as a dynamic tree on that page. The tag accepts three |
| 53 | +of category Foo as a dynamic tree on that page. The tag accepts the following |
54 | 54 | attributes, using a HTML-like syntax: |
55 | 55 | |
56 | 56 | * hideroot - set this to "on" to hide the "root" node of the tree, i.e. |
57 | 57 | the mention of category Foo from the example. |
58 | 58 | |
| 59 | +* onlyroot - set this to "on" show only the "root" node of the tree initially |
| 60 | + |
59 | 61 | * mode - can be "categories" (the default), "pages" or "all". "categories" |
60 | 62 | only lists subcategories; "pages" lists all pages in the category |
61 | 63 | except images; "all" shows all pages in the category. |
Index: trunk/extensions/CategoryTree/CategoryTree.i18n.php |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | * Internationalisation file for the CategoryTree extension |
6 | 6 | * |
7 | 7 | * @addtogroup Extensions |
8 | | - * @author Daniel Kinzler <duesentrieb@brightbyte.de> |
| 8 | + * @author Daniel Kinzler, brightbyte.de |
9 | 9 | * @copyright © 2006 Daniel Kinzler |
10 | 10 | * @licence GNU General Public Licence 2.0 or later |
11 | 11 | */ |
Index: trunk/extensions/CategoryTree/CategoryTree.js |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | * |
6 | 6 | * @package MediaWiki |
7 | 7 | * @subpackage Extensions |
8 | | - * @author Daniel Kinzler <duesentrieb@brightbyte.de> |
| 8 | + * @author Daniel Kinzler, brightbyte.de |
9 | 9 | * @copyright © 2006 Daniel Kinzler |
10 | 10 | * @licence GNU General Public Licence 2.0 or later |
11 | 11 | */ |
Index: trunk/extensions/CategoryTree/CategoryTree.i18n.nl.php |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | * Internationalisation file for the CategoryTree extension |
6 | 6 | * |
7 | 7 | * @addtogroup Extensions |
8 | | - * @author Dutch translation by JePe and Siebrand, source file by Daniel Kinzler <duesentrieb@brightbyte.de> |
| 8 | + * @author Dutch translation by JePe and Siebrand, source file by Daniel Kinzler, brightbyte.de |
9 | 9 | * @copyright © 2006 Daniel Kinzler, JePe, Siebrand |
10 | 10 | * @licence GNU General Public Licence 2.0 or later |
11 | 11 | */ |
Index: trunk/extensions/CategoryTree/CategoryTreeFunctions.php |
— | — | @@ -5,8 +5,8 @@ |
6 | 6 | * to display the category structure of a wiki |
7 | 7 | * |
8 | 8 | * @addtogroup Extensions |
9 | | - * @author Daniel Kinzler <duesentrieb@brightbyte.de> |
10 | | - * @copyright © 2006 Daniel Kinzler |
| 9 | + * @author Daniel Kinzler, brightbyte.de |
| 10 | + * @copyright © 2006-2007 Daniel Kinzler |
11 | 11 | * @licence GNU General Public Licence 2.0 or later |
12 | 12 | */ |
13 | 13 | |
— | — | @@ -113,7 +113,7 @@ |
114 | 114 | * Custom tag implementation. This is called by efCategoryTreeParserHook, which is used to |
115 | 115 | * load CategoryTreeFunctions.php on demand. |
116 | 116 | */ |
117 | | - function getTag( &$parser, $category, $mode, $hideroot = false, $style = '' ) { |
| 117 | + function getTag( &$parser, $category, $mode, $display = 'expandroot', $style = '' ) { |
118 | 118 | global $wgCategoryTreeDisableCache, $wgCategoryTreeDynamicTag; |
119 | 119 | static $uniq = 0; |
120 | 120 | |
— | — | @@ -138,7 +138,7 @@ |
139 | 139 | $html .= wfCloseElement( 'span' ); |
140 | 140 | } |
141 | 141 | else { |
142 | | - if ( !$hideroot ) $html .= CategoryTree::renderNode( $title, $mode, true, $wgCategoryTreeDynamicTag ); |
| 142 | + if ( $display != 'hideroot' ) $html .= CategoryTree::renderNode( $title, $mode, $display != 'onlyroot', $wgCategoryTreeDynamicTag ); |
143 | 143 | else if ( !$wgCategoryTreeDynamicTag ) $html .= $this->renderChildren( $title, $mode ); |
144 | 144 | else { |
145 | 145 | $uniq += 1; |
— | — | @@ -273,7 +273,7 @@ |
274 | 274 | |
275 | 275 | $load = false; |
276 | 276 | |
277 | | - if ( $loadchildren ) { |
| 277 | + if ( $children && $loadchildren ) { |
278 | 278 | $uniq += 1; |
279 | 279 | |
280 | 280 | $load = 'ct-' . $uniq . '-' . mt_rand( 1, 100000 ); |
Index: trunk/extensions/CategoryTree/CategoryTree.i18n.lt.php |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | * Internationalisation file for the CategoryTree extension |
6 | 6 | * |
7 | 7 | * @addtogroup Extensions |
8 | | - * @author Daniel Kinzler <duesentrieb@brightbyte.de> |
| 8 | + * @author Daniel Kinzler, brightbyte.de |
9 | 9 | * @copyright © 2006 Daniel Kinzler |
10 | 10 | * @licence GNU General Public Licence 2.0 or later |
11 | 11 | */ |
Index: trunk/extensions/CategoryTree/CategoryTreePage.php |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | * to display the category structure of a wiki |
6 | 6 | * |
7 | 7 | * @addtogroup Extensions |
8 | | - * @author Daniel Kinzler <duesentrieb@brightbyte.de> |
| 8 | + * @author Daniel Kinzler, brightbyte.de |
9 | 9 | * @copyright © 2006 Daniel Kinzler |
10 | 10 | * @licence GNU General Public Licence 2.0 or later |
11 | 11 | */ |
Index: trunk/extensions/CategoryTree/CategoryTree.css |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | * |
6 | 6 | * @package MediaWiki |
7 | 7 | * @subpackage Extensions |
8 | | - * @author Daniel Kinzler <duesentrieb@brightbyte.de> |
| 8 | + * @author Daniel Kinzler, brightbyte.de |
9 | 9 | * @copyright © 2006 Daniel Kinzler |
10 | 10 | * @licence GNU General Public Licence 2.0 or later |
11 | 11 | */ |