mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-27 09:43:06 +00:00
introducing onlyroot option (and removing obsolete email address)
This commit is contained in:
parent
cc3f98e5b3
commit
06647afe4a
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @package MediaWiki
|
||||
* @subpackage Extensions
|
||||
* @author Daniel Kinzler <duesentrieb@brightbyte.de>
|
||||
* @author Daniel Kinzler, brightbyte.de
|
||||
* @copyright © 2006 Daniel Kinzler
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Internationalisation file for the CategoryTree extension
|
||||
*
|
||||
* @addtogroup Extensions
|
||||
* @author Daniel Kinzler <duesentrieb@brightbyte.de>
|
||||
* @author Daniel Kinzler, brightbyte.de
|
||||
* @copyright © 2006 Daniel Kinzler
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Internationalisation file for the CategoryTree extension
|
||||
*
|
||||
* @addtogroup Extensions
|
||||
* @author Dutch translation by JePe and Siebrand, source file by Daniel Kinzler <duesentrieb@brightbyte.de>
|
||||
* @author Dutch translation by JePe and Siebrand, source file by Daniel Kinzler, brightbyte.de
|
||||
* @copyright © 2006 Daniel Kinzler, JePe, Siebrand
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Internationalisation file for the CategoryTree extension
|
||||
*
|
||||
* @addtogroup Extensions
|
||||
* @author Daniel Kinzler <duesentrieb@brightbyte.de>
|
||||
* @author Daniel Kinzler, brightbyte.de
|
||||
* @copyright © 2006 Daniel Kinzler
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @package MediaWiki
|
||||
* @subpackage Extensions
|
||||
* @author Daniel Kinzler <duesentrieb@brightbyte.de>
|
||||
* @author Daniel Kinzler, brightbyte.de
|
||||
* @copyright © 2006 Daniel Kinzler
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
*/
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* to display the category structure of a wiki
|
||||
*
|
||||
* @addtogroup Extensions
|
||||
* @author Daniel Kinzler <duesentrieb@brightbyte.de>
|
||||
* @copyright © 2006 Daniel Kinzler
|
||||
* @author Daniel Kinzler, brightbyte.de
|
||||
* @copyright © 2006-2007 Daniel Kinzler
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
*/
|
||||
|
||||
|
@ -111,6 +111,25 @@ function efCategoryTreeAjaxWrapper( $category, $mode = CT_MODE_CATEGORIES ) {
|
|||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to convert a string to a boolean value.
|
||||
* Perhaps make this a global function in MediaWiki proper
|
||||
*/
|
||||
function efCategoryTreeAsBool( $s ) {
|
||||
if ( is_null( $s ) || is_bool( $s ) ) return $s;
|
||||
$s = trim( strtolower( $s ) );
|
||||
|
||||
if ( $s === '1' || $s === 'yes' || $s === 'on' || $s === 'true' ) {
|
||||
return true;
|
||||
}
|
||||
else if ( $s === '0' || $s === 'no' || $s === 'off' || $s === 'false' ) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for the <categorytree> tag parser hook.
|
||||
* This loads CategoryTreeFunctions.php and calls CategoryTree::getTag()
|
||||
|
@ -135,20 +154,15 @@ function efCategoryTreeParserHook( $cat, $argv, &$parser ) {
|
|||
$mode = CT_MODE_CATEGORIES;
|
||||
}
|
||||
|
||||
$hideroot = isset( $argv[ 'hideroot' ] ) ? $argv[ 'hideroot' ] : null;
|
||||
if ( $hideroot !== NULL ) {
|
||||
$hideroot = trim( strtolower( $hideroot ) );
|
||||
|
||||
if ( $hideroot === '1' || $hideroot === 'yes' || $hideroot === 'on' || $hideroot === 'true' ) {
|
||||
$hideroot = true;
|
||||
}
|
||||
else if ( $hideroot === '0' || $hideroot === 'no' || $hideroot === 'off' || $hideroot === 'false' ) {
|
||||
$hideroot = false;
|
||||
}
|
||||
}
|
||||
$hideroot = isset( $argv[ 'hideroot' ] ) ? efCategoryTreeAsBool( $argv[ 'hideroot' ] ) : null;
|
||||
$onlyroot = isset( $argv[ 'onlyroot' ] ) ? efCategoryTreeAsBool( $argv[ 'onlyroot' ] ) : null;
|
||||
|
||||
if ( $onlyroot ) $display = 'onlyroot';
|
||||
else if ( $hideroot ) $display = 'hideroot';
|
||||
else $display = 'expandroot';
|
||||
|
||||
$ct = new CategoryTree;
|
||||
return $ct->getTag( $parser, $cat, $mode, $hideroot, $style );
|
||||
return $ct->getTag( $parser, $cat, $mode, $display, $style );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* to display the category structure of a wiki
|
||||
*
|
||||
* @addtogroup Extensions
|
||||
* @author Daniel Kinzler <duesentrieb@brightbyte.de>
|
||||
* @copyright © 2006 Daniel Kinzler
|
||||
* @author Daniel Kinzler, brightbyte.de
|
||||
* @copyright © 2006-2007 Daniel Kinzler
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
*/
|
||||
|
||||
|
@ -113,7 +113,7 @@ class CategoryTree {
|
|||
* Custom tag implementation. This is called by efCategoryTreeParserHook, which is used to
|
||||
* load CategoryTreeFunctions.php on demand.
|
||||
*/
|
||||
function getTag( &$parser, $category, $mode, $hideroot = false, $style = '' ) {
|
||||
function getTag( &$parser, $category, $mode, $display = 'expandroot', $style = '' ) {
|
||||
global $wgCategoryTreeDisableCache, $wgCategoryTreeDynamicTag;
|
||||
static $uniq = 0;
|
||||
|
||||
|
@ -138,7 +138,7 @@ class CategoryTree {
|
|||
$html .= wfCloseElement( 'span' );
|
||||
}
|
||||
else {
|
||||
if ( !$hideroot ) $html .= CategoryTree::renderNode( $title, $mode, true, $wgCategoryTreeDynamicTag );
|
||||
if ( $display != 'hideroot' ) $html .= CategoryTree::renderNode( $title, $mode, $display != 'onlyroot', $wgCategoryTreeDynamicTag );
|
||||
else if ( !$wgCategoryTreeDynamicTag ) $html .= $this->renderChildren( $title, $mode );
|
||||
else {
|
||||
$uniq += 1;
|
||||
|
@ -273,7 +273,7 @@ class CategoryTree {
|
|||
|
||||
$load = false;
|
||||
|
||||
if ( $loadchildren ) {
|
||||
if ( $children && $loadchildren ) {
|
||||
$uniq += 1;
|
||||
|
||||
$load = 'ct-' . $uniq . '-' . mt_rand( 1, 100000 );
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* to display the category structure of a wiki
|
||||
*
|
||||
* @addtogroup Extensions
|
||||
* @author Daniel Kinzler <duesentrieb@brightbyte.de>
|
||||
* @author Daniel Kinzler, brightbyte.de
|
||||
* @copyright © 2006 Daniel Kinzler
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
*/
|
||||
|
|
6
README
6
README
|
@ -1,6 +1,6 @@
|
|||
--------------------------------------------------------------------------
|
||||
README for the CategoryTree extension
|
||||
Copyright © 2006 Daniel Kinzler
|
||||
Copyright © 2006-2007 Daniel Kinzler
|
||||
Licenses: GNU General Public Licence (GPL)
|
||||
GNU Free Documentation License (GFDL)
|
||||
--------------------------------------------------------------------------
|
||||
|
@ -49,12 +49,14 @@ parsing the HTML of category pages.
|
|||
|
||||
The custom tag is called <categorytree>. For example, if you put
|
||||
<categorytree>Foo</categorytree> on a wiki page, it will show the contents
|
||||
of category Foo as a dynamic tree on that page. The tag accepts three
|
||||
of category Foo as a dynamic tree on that page. The tag accepts the following
|
||||
attributes, using a HTML-like syntax:
|
||||
|
||||
* hideroot - set this to "on" to hide the "root" node of the tree, i.e.
|
||||
the mention of category Foo from the example.
|
||||
|
||||
* onlyroot - set this to "on" show only the "root" node of the tree initially
|
||||
|
||||
* mode - can be "categories" (the default), "pages" or "all". "categories"
|
||||
only lists subcategories; "pages" lists all pages in the category
|
||||
except images; "all" shows all pages in the category.
|
||||
|
|
Loading…
Reference in a new issue