mediawiki-extensions-Catego.../CategoryTreeCategoryViewer.php

61 lines
1.3 KiB
PHP
Raw Normal View History

<?php
class CategoryTreeCategoryViewer extends CategoryViewer {
public $child_cats;
2008-02-04 09:22:12 +00:00
/**
* @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;
}
2008-02-04 09:22:12 +00:00
$tree = $this->getCategoryTree();
2008-02-04 09:22:12 +00:00
$this->children[] = $tree->renderNodeInfo( $title, $cat );
$this->children_start_char[] = $this->getSubcategorySortChar( $title, $sortkey );
}
2008-02-04 09:22:12 +00:00
function clearCategoryState() {
$this->child_cats = [];
parent::clearCategoryState();
}
2008-02-04 09:22:12 +00:00
function finaliseCategoryState() {
if ( $this->flip ) {
$this->child_cats = array_reverse( $this->child_cats );
}
parent::finaliseCategoryState();
}
}