mediawiki-extensions-Catego.../CategoryTreeCategoryViewer.php
Umherirrender 1f1defc070 Split CategoryPageSubclass.php into two files
Makes MediaWiki.Files.OneClassPerFile.MultipleFound pass


Change-Id: Ic4d064272a5297e33b1edc090b807937cfb06545
2017-12-16 13:03:29 +01:00

61 lines
1.3 KiB
PHP

<?php
class CategoryTreeCategoryViewer extends CategoryViewer {
public $child_cats;
/**
* @var CategoryTree
*/
public $categorytree;
/**
* @return CategoryTree
*/
function getCategoryTree() {
global $wgCategoryTreeCategoryPageOptions, $wgCategoryTreeForceHeaders;
if ( !isset( $this->categorytree ) ) {
if ( !$wgCategoryTreeForceHeaders ) {
CategoryTree::setHeaders( $this->getOutput() );
}
$this->categorytree = new CategoryTree( $wgCategoryTreeCategoryPageOptions );
}
return $this->categorytree;
}
/**
* Add a subcategory to the internal lists
* @param Category $cat
* @param string $sortkey
* @param int $pageLength
*/
function addSubcategoryObject( Category $cat, $sortkey, $pageLength ) {
$title = $cat->getTitle();
if ( $this->getRequest()->getCheck( 'notree' ) ) {
parent::addSubcategoryObject( $cat, $sortkey, $pageLength );
return;
}
$tree = $this->getCategoryTree();
$this->children[] = $tree->renderNodeInfo( $title, $cat );
$this->children_start_char[] = $this->getSubcategorySortChar( $title, $sortkey );
}
function clearCategoryState() {
$this->child_cats = [];
parent::clearCategoryState();
}
function finaliseCategoryState() {
if ( $this->flip ) {
$this->child_cats = array_reverse( $this->child_cats );
}
parent::finaliseCategoryState();
}
}