MediaWiki  1.32.5
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 ( $options)
 
 getOption ( $name)
 
 getOptionsAsCacheKey ( $depth=null)
 
 getOptionsAsJsStructure ( $depth=null)
 
 getTag ( $parser, $category, $hideroot=false, $attr=[], $depth=1, $allowMissing=false)
 Custom tag implementation. More...
 
 renderChildren ( $title, $depth=1)
 Returns a string with an HTML representation of the children of the given category. More...
 
 renderNode ( $title, $children=0)
 Returns a string with a HTML represenation of the given page. More...
 
 renderNodeInfo ( $title, $cat, $children=0)
 Returns a string with a HTML represenation of the given page. More...
 
 renderParents ( $title)
 Returns a string with an HTML representation of the parents of the given category. More...
 

Static Public Member Functions

static capDepth ( $mode, $depth)
 Internal function to cap depth. More...
 
static createCountString (IContextSource $context, $cat, $countMode)
 Create a string which format the page, subcat and file counts of a category. More...
 
static decodeBoolean ( $value)
 Helper function to convert a string to a boolean value. More...
 
static decodeHidePrefix ( $value)
 
static decodeMode ( $mode)
 
static makeTitle ( $title)
 Creates a Title object from a user provided (and thus unsafe) string. More...
 
static setHeaders ( $outputPage)
 Add ResourceLoader modules to the OutputPage object. More...
 

Public Attributes

 $mOptions = []
 

Static Protected Member Functions

static encodeOptions ( $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()

Member Function Documentation

◆ capDepth()

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

Internal function to cap depth.

Parameters
string$mode
int$depth
Returns
int|mixed

Definition at line 795 of file CategoryTree.php.

References wfDebug().

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

◆ createCountString()

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

Create a string which format the page, subcat and file counts of a category.

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

Definition at line 715 of file CategoryTree.php.

References $context, $s, $wgContLang, a, and(), in, Xml\tags(), and up.

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 174 of file CategoryTree.php.

References $value.

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

◆ decodeHidePrefix()

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

Definition at line 209 of file CategoryTree.php.

References $value, CategoryTreeHidePrefix\ALWAYS, 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 137 of file CategoryTree.php.

References CategoryTreeMode\ALL, 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 91 of file CategoryTree.php.

References $namespaces, $wgContLang, as, and NS_MAIN.

Referenced by __construct().

◆ encodeOptions()

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

Definition at line 264 of file CategoryTree.php.

References $opt, $options, and FormatJson\encode().

Referenced by getOptionsAsJsStructure().

◆ getOption()

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

Definition at line 76 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 280 of file CategoryTree.php.

References as.

◆ getOptionsAsJsStructure()

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

Definition at line 300 of file CategoryTree.php.

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

Referenced by getTag().

◆ getOptionsAsUrlParameters()

CategoryTree::getOptionsAsUrlParameters ( )
private
Returns
string

Definition at line 315 of file CategoryTree.php.

Referenced by renderParents().

◆ getTag()

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

Custom tag implementation.

This is called by CategoryTreeHooks::parserHook, which is used to load CategoryTreeFunctions.php on demand.

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

Definition at line 330 of file CategoryTree.php.

References $html, $parser, $title, Xml\closeElement(), Html\closeElement(), getOptionsAsJsStructure(), makeTitle(), Html\openElement(), plain, renderChildren(), renderNode(), and wfMessage().

◆ isInverse()

CategoryTree::isInverse ( )
private
Returns
bool

Definition at line 83 of file CategoryTree.php.

References getOption(), and CategoryTreeMode\PARENTS.

Referenced by renderChildren(), and renderNode().

◆ 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 770 of file CategoryTree.php.

References $t, $title, Title\newFromText(), and NS_CATEGORY.

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

◆ renderChildren()

CategoryTree::renderChildren (   $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 394 of file CategoryTree.php.

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

Referenced by getTag(), and renderNodeInfo().

◆ renderNode()

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

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

Parameters
Title$title
int$children
Returns
string

Definition at line 541 of file CategoryTree.php.

References $title, isInverse(), Category\newFromTitle(), NS_CATEGORY, and renderNodeInfo().

Referenced by getTag().

◆ renderNodeInfo()

CategoryTree::renderNodeInfo (   $title,
  $cat,
  $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$cat
int$children
Returns
string

Definition at line 563 of file CategoryTree.php.

References $s, $title, CategoryTreeHidePrefix\ALWAYS, CategoryTreeHidePrefix\AUTO, CategoryTreeMode\CATEGORIES, CategoryTreeHidePrefix\CATEGORIES, Xml\closeElement(), createCountString(), Xml\element(), RequestContext\getMain(), getOption(), NS_CATEGORY, Xml\openElement(), CategoryTreeMode\PAGES, CategoryTreeMode\PARENTS, plain, renderChildren(), Xml\tags(), and wfMessage().

Referenced by renderChildren(), and renderNode().

◆ renderParents()

CategoryTree::renderParents (   $title)

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

Parameters
Title$title
Returns
string

Definition at line 492 of file CategoryTree.php.

References $dbr, $res, $s, $t, $title, as, Xml\closeElement(), DB_REPLICA, Xml\element(), getOptionsAsUrlParameters(), SpecialPage\getTitleFor(), Title\newFromRow(), NS_CATEGORY, Xml\openElement(), wfGetDB(), and wfMessage().

◆ setHeaders()

static CategoryTree::setHeaders (   $outputPage)
static

Add ResourceLoader modules to the OutputPage object.

Parameters
OutputPage$outputPage

Definition at line 252 of file CategoryTree.php.

Referenced by CategoryTreeHooks\addHeaders(), CategoryTreePage\execute(), CategoryTreeCategoryViewer\getCategoryTree(), CategoryTreeHooks\parserHook(), and CategoryTreeHooks\parserOutput().

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: