MediaWiki  1.33.1
CategoryTreeCategoryViewer.php
Go to the documentation of this file.
1 <?php
22  public $child_cats;
23 
27  public $categorytree;
28 
32  private function getCategoryTree() {
33  global $wgCategoryTreeCategoryPageOptions;
34 
35  if ( !isset( $this->categorytree ) ) {
38  }
39 
40  $this->categorytree = new CategoryTree( $wgCategoryTreeCategoryPageOptions );
41  }
42 
43  return $this->categorytree;
44  }
45 
52  public function addSubcategoryObject( Category $cat, $sortkey, $pageLength ) {
53  $title = $cat->getTitle();
54 
55  if ( $this->getRequest()->getCheck( 'notree' ) ) {
56  parent::addSubcategoryObject( $cat, $sortkey, $pageLength );
57  return;
58  }
59 
60  $tree = $this->getCategoryTree();
61 
62  $this->children[] = $tree->renderNodeInfo( $title, $cat );
63 
64  $this->children_start_char[] = $this->getSubcategorySortChar( $title, $sortkey );
65  }
66 
70  public function clearCategoryState() {
71  $this->child_cats = [];
72  parent::clearCategoryState();
73  }
74 
78  public function finaliseCategoryState() {
79  if ( $this->flip ) {
80  $this->child_cats = array_reverse( $this->child_cats );
81  }
82  parent::finaliseCategoryState();
83  }
84 }
Category\getTitle
getTitle()
Definition: Category.php:251
Category
Category objects are immutable, strictly speaking.
Definition: Category.php:31
CategoryTree
Core functions for the CategoryTree extension, an AJAX based gadget to display the category structure...
Definition: CategoryTree.php:29
CategoryTreeCategoryViewer\addSubcategoryObject
addSubcategoryObject(Category $cat, $sortkey, $pageLength)
Add a subcategory to the internal lists.
Definition: CategoryTreeCategoryViewer.php:52
CategoryViewer\getSubcategorySortChar
getSubcategorySortChar( $title, $sortkey)
Get the character to be used for sorting subcategories.
Definition: CategoryViewer.php:223
ContextSource\getRequest
getRequest()
Definition: ContextSource.php:71
CategoryTreeCategoryViewer
Definition: CategoryTreeCategoryViewer.php:21
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
CategoryViewer\$cat
Category $cat
Category object for this page.
Definition: CategoryViewer.php:74
CategoryTreeHooks\shouldForceHeaders
static shouldForceHeaders()
Definition: CategoryTreeHooks.php:35
ContextSource\getOutput
getOutput()
Definition: ContextSource.php:112
CategoryTreeCategoryViewer\clearCategoryState
clearCategoryState()
@inheritDoc
Definition: CategoryTreeCategoryViewer.php:70
CategoryTreeCategoryViewer\$categorytree
CategoryTree $categorytree
Definition: CategoryTreeCategoryViewer.php:27
CategoryTreeCategoryViewer\$child_cats
$child_cats
Definition: CategoryTreeCategoryViewer.php:22
CategoryViewer
Definition: CategoryViewer.php:24
CategoryViewer\$title
Title $title
Definition: CategoryViewer.php:65
CategoryTreeCategoryViewer\getCategoryTree
getCategoryTree()
Definition: CategoryTreeCategoryViewer.php:32
CategoryTreeCategoryViewer\finaliseCategoryState
finaliseCategoryState()
@inheritDoc
Definition: CategoryTreeCategoryViewer.php:78
CategoryTree\setHeaders
static setHeaders(OutputPage $outputPage)
Add ResourceLoader modules to the OutputPage object.
Definition: CategoryTree.php:254