2006-08-24 18:11:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class CategoryTreeCategoryViewer extends CategoryViewer {
|
2014-08-17 21:03:48 +00:00
|
|
|
public $child_cats;
|
2008-02-04 09:22:12 +00:00
|
|
|
|
2012-02-09 01:23:31 +00:00
|
|
|
/**
|
|
|
|
* @var CategoryTree
|
|
|
|
*/
|
2014-08-17 21:03:48 +00:00
|
|
|
public $categorytree;
|
2012-02-09 01:23:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return CategoryTree
|
|
|
|
*/
|
2008-06-28 20:13:20 +00:00
|
|
|
function getCategoryTree() {
|
2016-11-08 03:27:56 +00:00
|
|
|
global $wgCategoryTreeCategoryPageOptions, $wgCategoryTreeForceHeaders;
|
2008-06-28 20:13:20 +00:00
|
|
|
|
2012-02-09 01:23:31 +00:00
|
|
|
if ( !isset( $this->categorytree ) ) {
|
|
|
|
if ( !$wgCategoryTreeForceHeaders ) {
|
2016-11-08 03:27:56 +00:00
|
|
|
CategoryTree::setHeaders( $this->getOutput() );
|
2012-02-09 01:23:31 +00:00
|
|
|
}
|
2008-06-28 20:13:20 +00:00
|
|
|
|
|
|
|
$this->categorytree = new CategoryTree( $wgCategoryTreeCategoryPageOptions );
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->categorytree;
|
|
|
|
}
|
|
|
|
|
2006-09-02 12:14:12 +00:00
|
|
|
/**
|
|
|
|
* Add a subcategory to the internal lists
|
2017-10-11 18:25:13 +00:00
|
|
|
* @param Category $cat
|
|
|
|
* @param string $sortkey
|
|
|
|
* @param int $pageLength
|
2006-09-02 12:14:12 +00:00
|
|
|
*/
|
2010-09-09 22:35:32 +00:00
|
|
|
function addSubcategoryObject( Category $cat, $sortkey, $pageLength ) {
|
2008-06-30 14:09:47 +00:00
|
|
|
$title = $cat->getTitle();
|
|
|
|
|
2016-11-08 03:27:56 +00:00
|
|
|
if ( $this->getRequest()->getCheck( 'notree' ) ) {
|
2012-02-09 01:23:31 +00:00
|
|
|
parent::addSubcategoryObject( $cat, $sortkey, $pageLength );
|
|
|
|
return;
|
2006-09-02 12:55:29 +00:00
|
|
|
}
|
2008-02-04 09:22:12 +00:00
|
|
|
|
2008-06-28 20:13:20 +00:00
|
|
|
$tree = $this->getCategoryTree();
|
2008-02-04 09:22:12 +00:00
|
|
|
|
2008-06-30 14:09:47 +00:00
|
|
|
$this->children[] = $tree->renderNodeInfo( $title, $cat );
|
2006-09-02 12:14:12 +00:00
|
|
|
|
|
|
|
$this->children_start_char[] = $this->getSubcategorySortChar( $title, $sortkey );
|
|
|
|
}
|
2008-02-04 09:22:12 +00:00
|
|
|
|
2006-08-24 18:11:35 +00:00
|
|
|
function clearCategoryState() {
|
2016-10-14 16:11:52 +00:00
|
|
|
$this->child_cats = [];
|
2006-08-24 18:11:35 +00:00
|
|
|
parent::clearCategoryState();
|
|
|
|
}
|
2008-02-04 09:22:12 +00:00
|
|
|
|
2006-08-24 18:11:35 +00:00
|
|
|
function finaliseCategoryState() {
|
2010-04-20 22:00:34 +00:00
|
|
|
if ( $this->flip ) {
|
2008-06-30 14:09:47 +00:00
|
|
|
$this->child_cats = array_reverse( $this->child_cats );
|
2006-08-24 18:11:35 +00:00
|
|
|
}
|
|
|
|
parent::finaliseCategoryState();
|
|
|
|
}
|
|
|
|
}
|