mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-15 20:09:58 +00:00
3a6c96bc63
Change-Id: Ib896238f89e2d72a6b7022af9a9fd8570d7b1356
65 lines
1.4 KiB
PHP
65 lines
1.4 KiB
PHP
<?php
|
|
|
|
class CategoryTreeCategoryPage extends CategoryPage {
|
|
public $mCategoryViewerClass = 'CategoryTreeCategoryViewer';
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|