mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-27 17:51:00 +00:00
7a749a6e9a
Change-Id: I6c34c0f15c9759e9e2b04fd6da93e5c577a40ce5
67 lines
1.4 KiB
PHP
67 lines
1.4 KiB
PHP
<?php
|
|
|
|
class CategoryTreeCategoryPage extends CategoryPage {
|
|
protected $mCategoryViewerClass = 'CategoryTreeCategoryViewer';
|
|
}
|
|
|
|
class CategoryTreeCategoryViewer extends CategoryViewer {
|
|
public $child_cats;
|
|
|
|
/**
|
|
* @var CategoryTree
|
|
*/
|
|
public $categorytree;
|
|
|
|
/**
|
|
* @return CategoryTree
|
|
*/
|
|
function getCategoryTree() {
|
|
global $wgOut, $wgCategoryTreeCategoryPageOptions, $wgCategoryTreeForceHeaders;
|
|
|
|
if ( !isset( $this->categorytree ) ) {
|
|
if ( !$wgCategoryTreeForceHeaders ) {
|
|
CategoryTree::setHeaders( $wgOut );
|
|
}
|
|
|
|
$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 ) {
|
|
global $wgRequest;
|
|
|
|
$title = $cat->getTitle();
|
|
|
|
if ( $wgRequest->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 = array();
|
|
parent::clearCategoryState();
|
|
}
|
|
|
|
function finaliseCategoryState() {
|
|
if ( $this->flip ) {
|
|
$this->child_cats = array_reverse( $this->child_cats );
|
|
}
|
|
parent::finaliseCategoryState();
|
|
}
|
|
}
|