2006-08-24 18:11:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class CategoryTreeCategoryPage extends CategoryPage {
|
2010-08-13 22:07:48 +00:00
|
|
|
protected $mCategoryViewerClass = 'CategoryTreeCategoryViewer';
|
2006-08-24 18:11:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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() {
|
2008-07-02 08:49:13 +00:00
|
|
|
global $wgOut, $wgCategoryTreeCategoryPageOptions, $wgCategoryTreeForceHeaders;
|
2008-06-28 20:13:20 +00:00
|
|
|
|
2012-02-09 01:23:31 +00:00
|
|
|
if ( !isset( $this->categorytree ) ) {
|
|
|
|
if ( !$wgCategoryTreeForceHeaders ) {
|
|
|
|
CategoryTree::setHeaders( $wgOut );
|
|
|
|
}
|
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
|
2012-02-09 01:23:31 +00:00
|
|
|
* @param $cat Category
|
|
|
|
* @param $sortkey
|
|
|
|
* @param $pageLength
|
2006-09-02 12:14:12 +00:00
|
|
|
*/
|
2010-09-09 22:35:32 +00:00
|
|
|
function addSubcategoryObject( Category $cat, $sortkey, $pageLength ) {
|
2010-07-25 17:12:50 +00:00
|
|
|
global $wgRequest;
|
2008-02-04 09:22:12 +00:00
|
|
|
|
2008-06-30 14:09:47 +00:00
|
|
|
$title = $cat->getTitle();
|
|
|
|
|
2006-09-02 12:55:29 +00:00
|
|
|
if ( $wgRequest->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();
|
|
|
|
}
|
|
|
|
}
|