r20385 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20384‎ | r20385 | r20386 >
Date:11:39, 13 March 2007
Author:daniel
Status:old
Tags:
Comment:
introducing onlyroot option (and removing obsolete email address)
Modified paths:
  • /trunk/extensions/CategoryTree/CategoryTree.css (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTree.i18n.lt.php (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTree.i18n.nl.php (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTree.i18n.php (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTree.js (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTree.php (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTreeFunctions.php (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTreePage.php (modified) (history)
  • /trunk/extensions/CategoryTree/README (modified) (history)

Diff [purge]

Index: trunk/extensions/CategoryTree/CategoryTree.php
@@ -5,8 +5,8 @@
66 * to display the category structure of a wiki
77 *
88 * @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
1111 * @licence GNU General Public Licence 2.0 or later
1212 */
1313
@@ -112,6 +112,25 @@
113113 }
114114
115115 /**
 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+/**
116135 * Entry point for the <categorytree> tag parser hook.
117136 * This loads CategoryTreeFunctions.php and calls CategoryTree::getTag()
118137 */
@@ -135,20 +154,15 @@
136155 $mode = CT_MODE_CATEGORIES;
137156 }
138157
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;
150160
 161+ if ( $onlyroot ) $display = 'onlyroot';
 162+ else if ( $hideroot ) $display = 'hideroot';
 163+ else $display = 'expandroot';
 164+
151165 $ct = new CategoryTree;
152 - return $ct->getTag( $parser, $cat, $mode, $hideroot, $style );
 166+ return $ct->getTag( $parser, $cat, $mode, $display, $style );
153167 }
154168
155169 /**
Index: trunk/extensions/CategoryTree/README
@@ -1,6 +1,6 @@
22 --------------------------------------------------------------------------
33 README for the CategoryTree extension
4 -Copyright © 2006 Daniel Kinzler
 4+Copyright © 2006-2007 Daniel Kinzler
55 Licenses: GNU General Public Licence (GPL)
66 GNU Free Documentation License (GFDL)
77 --------------------------------------------------------------------------
@@ -49,12 +49,14 @@
5050
5151 The custom tag is called <categorytree>. For example, if you put
5252 <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
5454 attributes, using a HTML-like syntax:
5555
5656 * hideroot - set this to "on" to hide the "root" node of the tree, i.e.
5757 the mention of category Foo from the example.
5858
 59+* onlyroot - set this to "on" show only the "root" node of the tree initially
 60+
5961 * mode - can be "categories" (the default), "pages" or "all". "categories"
6062 only lists subcategories; "pages" lists all pages in the category
6163 except images; "all" shows all pages in the category.
Index: trunk/extensions/CategoryTree/CategoryTree.i18n.php
@@ -4,7 +4,7 @@
55 * Internationalisation file for the CategoryTree extension
66 *
77 * @addtogroup Extensions
8 - * @author Daniel Kinzler <duesentrieb@brightbyte.de>
 8+ * @author Daniel Kinzler, brightbyte.de
99 * @copyright © 2006 Daniel Kinzler
1010 * @licence GNU General Public Licence 2.0 or later
1111 */
Index: trunk/extensions/CategoryTree/CategoryTree.js
@@ -4,7 +4,7 @@
55 *
66 * @package MediaWiki
77 * @subpackage Extensions
8 - * @author Daniel Kinzler <duesentrieb@brightbyte.de>
 8+ * @author Daniel Kinzler, brightbyte.de
99 * @copyright © 2006 Daniel Kinzler
1010 * @licence GNU General Public Licence 2.0 or later
1111 */
Index: trunk/extensions/CategoryTree/CategoryTree.i18n.nl.php
@@ -4,7 +4,7 @@
55 * Internationalisation file for the CategoryTree extension
66 *
77 * @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
99 * @copyright © 2006 Daniel Kinzler, JePe, Siebrand
1010 * @licence GNU General Public Licence 2.0 or later
1111 */
Index: trunk/extensions/CategoryTree/CategoryTreeFunctions.php
@@ -5,8 +5,8 @@
66 * to display the category structure of a wiki
77 *
88 * @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
1111 * @licence GNU General Public Licence 2.0 or later
1212 */
1313
@@ -113,7 +113,7 @@
114114 * Custom tag implementation. This is called by efCategoryTreeParserHook, which is used to
115115 * load CategoryTreeFunctions.php on demand.
116116 */
117 - function getTag( &$parser, $category, $mode, $hideroot = false, $style = '' ) {
 117+ function getTag( &$parser, $category, $mode, $display = 'expandroot', $style = '' ) {
118118 global $wgCategoryTreeDisableCache, $wgCategoryTreeDynamicTag;
119119 static $uniq = 0;
120120
@@ -138,7 +138,7 @@
139139 $html .= wfCloseElement( 'span' );
140140 }
141141 else {
142 - if ( !$hideroot ) $html .= CategoryTree::renderNode( $title, $mode, true, $wgCategoryTreeDynamicTag );
 142+ if ( $display != 'hideroot' ) $html .= CategoryTree::renderNode( $title, $mode, $display != 'onlyroot', $wgCategoryTreeDynamicTag );
143143 else if ( !$wgCategoryTreeDynamicTag ) $html .= $this->renderChildren( $title, $mode );
144144 else {
145145 $uniq += 1;
@@ -273,7 +273,7 @@
274274
275275 $load = false;
276276
277 - if ( $loadchildren ) {
 277+ if ( $children && $loadchildren ) {
278278 $uniq += 1;
279279
280280 $load = 'ct-' . $uniq . '-' . mt_rand( 1, 100000 );
Index: trunk/extensions/CategoryTree/CategoryTree.i18n.lt.php
@@ -4,7 +4,7 @@
55 * Internationalisation file for the CategoryTree extension
66 *
77 * @addtogroup Extensions
8 - * @author Daniel Kinzler <duesentrieb@brightbyte.de>
 8+ * @author Daniel Kinzler, brightbyte.de
99 * @copyright © 2006 Daniel Kinzler
1010 * @licence GNU General Public Licence 2.0 or later
1111 */
Index: trunk/extensions/CategoryTree/CategoryTreePage.php
@@ -4,7 +4,7 @@
55 * to display the category structure of a wiki
66 *
77 * @addtogroup Extensions
8 - * @author Daniel Kinzler <duesentrieb@brightbyte.de>
 8+ * @author Daniel Kinzler, brightbyte.de
99 * @copyright © 2006 Daniel Kinzler
1010 * @licence GNU General Public Licence 2.0 or later
1111 */
Index: trunk/extensions/CategoryTree/CategoryTree.css
@@ -4,7 +4,7 @@
55 *
66 * @package MediaWiki
77 * @subpackage Extensions
8 - * @author Daniel Kinzler <duesentrieb@brightbyte.de>
 8+ * @author Daniel Kinzler, brightbyte.de
99 * @copyright © 2006 Daniel Kinzler
1010 * @licence GNU General Public Licence 2.0 or later
1111 */