mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-15 03:43:55 +00:00
a4493424fd
Needed after I9937148dd8114e7167d6a581e64bfed5fdcc568e Change-Id: Iea507743a7f03ae01aa5869e9a30e3dcbce8f5ce
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 $cat Category
|
|
* @param $sortkey
|
|
* @param $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();
|
|
}
|
|
}
|