MediaWiki REL1_33
CategoryTree Class Reference

Core functions for the CategoryTree extension, an AJAX based gadget to display the category structure of a wiki. More...

Public Member Functions

 __construct (array $options)
 @suppress PhanTypeInvalidDimOffset
 
 getOption ( $name)
 
 getOptionsAsCacheKey ( $depth=null)
 
 getOptionsAsJsStructure ( $depth=null)
 
 getTag (Parser $parser=null, $category, $hideroot=false, array $attr=[], $depth=1, $allowMissing=false)
 Custom tag implementation.
 
 renderChildren (Title $title, $depth=1)
 Returns a string with an HTML representation of the children of the given category.
 
 renderNode (Title $title, $children=0)
 Returns a string with a HTML represenation of the given page.
 
 renderNodeInfo (Title $title, Category $cat=null, $children=0)
 Returns a string with a HTML represenation of the given page.
 
 renderParents (Title $title)
 Returns a string with an HTML representation of the parents of the given category.
 

Static Public Member Functions

static capDepth ( $mode, $depth)
 Internal function to cap depth @suppress PhanPluginDuplicateConditionalNullCoalescing until PHP7 is required.
 
static createCountString (IContextSource $context, Category $cat=null, $countMode)
 Create a string which format the page, subcat and file counts of a category @suppress PhanParamReqAfterOpt $cat is not optional but nullable.
 
static decodeBoolean ( $value)
 Helper function to convert a string to a boolean value.
 
static decodeHidePrefix ( $value)
 
static decodeMode ( $mode)
 
static makeTitle ( $title)
 Creates a Title object from a user provided (and thus unsafe) string.
 
static setHeaders (OutputPage $outputPage)
 Add ResourceLoader modules to the OutputPage object.
 

Public Attributes

 $mOptions = []
 

Static Protected Member Functions

static encodeOptions (array $options, $enc)
 

Private Member Functions

 getOptionsAsUrlParameters ()
 
 isInverse ()
 

Static Private Member Functions

static decodeNamespaces ( $nn)
 

Detailed Description

Core functions for the CategoryTree extension, an AJAX based gadget to display the category structure of a wiki.

Definition at line 29 of file CategoryTree.php.

Constructor & Destructor Documentation

◆ __construct()

CategoryTree::__construct ( array $options)

Member Function Documentation

◆ capDepth()

static CategoryTree::capDepth ( $mode,
$depth )
static

Internal function to cap depth @suppress PhanPluginDuplicateConditionalNullCoalescing until PHP7 is required.

Parameters
string$mode
int$depth
Returns
int|mixed

Definition at line 802 of file CategoryTree.php.

References and(), and wfDebug().

Referenced by ApiCategoryTree\execute(), and CategoryTreeHooks\parserHook().

◆ createCountString()

static CategoryTree::createCountString ( IContextSource $context,
Category $cat = null,
$countMode )
static

Create a string which format the page, subcat and file counts of a category @suppress PhanParamReqAfterOpt $cat is not optional but nullable.

Parameters
IContextSource$context
Category | null$cat
int$countMode
Returns
string

Definition at line 718 of file CategoryTree.php.

References $context, $s, $wgContLang, and and().

Referenced by CategoryTreeHooks\onSpecialTrackingCategoriesGenerateCatLink(), and renderNodeInfo().

◆ decodeBoolean()

static CategoryTree::decodeBoolean ( $value)
static

Helper function to convert a string to a boolean value.

Perhaps make this a global function in MediaWiki proper

Parameters
mixed$value
Returns
bool|null|string

Definition at line 176 of file CategoryTree.php.

References $value, and and().

Referenced by __construct(), and CategoryTreeHooks\parserHook().

◆ decodeHidePrefix()

static CategoryTree::decodeHidePrefix ( $value)
static
Parameters
mixed$value
Returns
int|string

Definition at line 211 of file CategoryTree.php.

References $value, CategoryTreeHidePrefix\ALWAYS, and(), CategoryTreeHidePrefix\AUTO, CategoryTreeHidePrefix\CATEGORIES, and CategoryTreeHidePrefix\NEVER.

Referenced by __construct().

◆ decodeMode()

static CategoryTree::decodeMode ( $mode)
static
Parameters
mixed$mode
Returns
int|string

Definition at line 139 of file CategoryTree.php.

References CategoryTreeMode\ALL, and(), CategoryTreeMode\CATEGORIES, CategoryTreeMode\PAGES, and CategoryTreeMode\PARENTS.

Referenced by __construct(), and CategoryTreeHooks\initialize().

◆ decodeNamespaces()

static CategoryTree::decodeNamespaces ( $nn)
staticprivate
Parameters
mixed$nn
Returns
array|bool

Definition at line 92 of file CategoryTree.php.

References $namespaces, $wgContLang, and(), and NS_MAIN.

Referenced by __construct().

◆ encodeOptions()

static CategoryTree::encodeOptions ( array $options,
$enc )
staticprotected
Parameters
array$options
string$enc
Returns
mixed
Exceptions
Exception

Definition at line 266 of file CategoryTree.php.

References $opt, $options, and and().

Referenced by getOptionsAsJsStructure().

◆ getOption()

CategoryTree::getOption ( $name)
Parameters
string$name
Returns
mixed

Definition at line 77 of file CategoryTree.php.

References $name.

Referenced by isInverse(), renderChildren(), and renderNodeInfo().

◆ getOptionsAsCacheKey()

CategoryTree::getOptionsAsCacheKey ( $depth = null)
Parameters
string | null$depth
Returns
string

Definition at line 282 of file CategoryTree.php.

References and().

◆ getOptionsAsJsStructure()

CategoryTree::getOptionsAsJsStructure ( $depth = null)
Parameters
int | null$depth
Returns
mixed

Definition at line 302 of file CategoryTree.php.

References $mOptions, $opt, $s, and encodeOptions().

Referenced by getTag().

◆ getOptionsAsUrlParameters()

CategoryTree::getOptionsAsUrlParameters ( )
private
Returns
string

Definition at line 317 of file CategoryTree.php.

References and().

◆ getTag()

CategoryTree::getTag ( Parser $parser = null,
$category,
$hideroot = false,
array $attr = [],
$depth = 1,
$allowMissing = false )

Custom tag implementation.

This is called by CategoryTreeHooks::parserHook, which is used to load CategoryTreeFunctions.php on demand. @suppress PhanParamReqAfterOpt $parser is not optional but nullable

Parameters
Parser | null$parser
string$category
bool$hideroot
array$attr
int$depth
bool$allowMissing
Returns
bool|string

Definition at line 333 of file CategoryTree.php.

References $html, $parser, and(), getOptionsAsJsStructure(), makeTitle(), plain, renderChildren(), renderNode(), and wfMessage().

◆ isInverse()

CategoryTree::isInverse ( )
private
Returns
bool

Definition at line 84 of file CategoryTree.php.

References getOption(), and CategoryTreeMode\PARENTS.

Referenced by renderChildren().

◆ makeTitle()

static CategoryTree::makeTitle ( $title)
static

Creates a Title object from a user provided (and thus unsafe) string.

Parameters
string$title
Returns
null|Title

Definition at line 776 of file CategoryTree.php.

References $t, and(), and NS_CATEGORY.

Referenced by CategoryTreePage\execute(), ApiCategoryTree\execute(), ApiCategoryTree\getConditionalRequestData(), and getTag().

◆ renderChildren()

CategoryTree::renderChildren ( Title $title,
$depth = 1 )

Returns a string with an HTML representation of the children of the given category.

Parameters
Title$title
int$depth
Returns
string

Definition at line 397 of file CategoryTree.php.

References $dbr, $namespaces, $options, $res, $s, $t, $tables, CategoryTreeMode\ALL, and(), DB_REPLICA, getOption(), isInverse(), NS_CATEGORY, CategoryTreeMode\PAGES, renderNodeInfo(), and wfGetDB().

Referenced by getTag(), and renderNodeInfo().

◆ renderNode()

CategoryTree::renderNode ( Title $title,
$children = 0 )

Returns a string with a HTML represenation of the given page.

Parameters
Title$title
int$children
Returns
string

Definition at line 544 of file CategoryTree.php.

References and(), NS_CATEGORY, and renderNodeInfo().

Referenced by getTag().

◆ renderNodeInfo()

CategoryTree::renderNodeInfo ( Title $title,
Category $cat = null,
$children = 0 )

Returns a string with a HTML represenation of the given page.

$info must be an associative array, containing at least a Title object under the 'title' key.

Parameters
Title$title
Category | null$cat
int$children
Returns
string

Definition at line 566 of file CategoryTree.php.

References $s, CategoryTreeHidePrefix\ALWAYS, and(), CategoryTreeHidePrefix\AUTO, CategoryTreeHidePrefix\CATEGORIES, CategoryTreeMode\CATEGORIES, createCountString(), getOption(), NS_CATEGORY, CategoryTreeMode\PAGES, CategoryTreeMode\PARENTS, renderChildren(), and wfMessage().

Referenced by renderChildren(), and renderNode().

◆ renderParents()

CategoryTree::renderParents ( Title $title)

Returns a string with an HTML representation of the parents of the given category.

Parameters
Title$title
Returns
string

Definition at line 495 of file CategoryTree.php.

References $dbr, $res, $s, $t, and(), DB_REPLICA, NS_CATEGORY, wfGetDB(), and wfMessage().

◆ setHeaders()

Member Data Documentation

◆ $mOptions

CategoryTree::$mOptions = []

Definition at line 30 of file CategoryTree.php.

Referenced by getOptionsAsJsStructure().


The documentation for this class was generated from the following file: