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 {
|
2008-06-30 14:09:47 +00:00
|
|
|
var $child_cats;
|
2008-02-04 09:22:12 +00:00
|
|
|
|
2012-02-09 01:23:31 +00:00
|
|
|
/**
|
|
|
|
* @var CategoryTree
|
|
|
|
*/
|
|
|
|
var $categorytree;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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() {
|
2008-06-30 14:09:47 +00:00
|
|
|
$this->child_cats = array();
|
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();
|
|
|
|
}
|
|
|
|
}
|