mediawiki-extensions-Catego.../CategoryPageSubclass.php

53 lines
1.3 KiB
PHP
Raw Normal View History

<?php
class CategoryTreeCategoryPage extends CategoryPage {
protected $mCategoryViewerClass = 'CategoryTreeCategoryViewer';
}
class CategoryTreeCategoryViewer extends CategoryViewer {
var $child_cats;
2008-02-04 09:22:12 +00:00
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
*/
function addSubcategoryObject( $cat, $sortkey, $pageLength ) {
global $wgRequest;
2008-02-04 09:22:12 +00:00
$title = $cat->getTitle();
if ( $wgRequest->getCheck( 'notree' ) ) {
return parent::addSubcategoryObject( $cat, $sortkey, $pageLength );
}
2008-02-04 09:22:12 +00:00
$tree = $this->getCategoryTree();
2008-02-04 09:22:12 +00:00
$this->children[] = $tree->renderNodeInfo( $title, $cat );
$this->children_start_char[] = $this->getSubcategorySortChar( $title, $sortkey );
}
2008-02-04 09:22:12 +00:00
function clearCategoryState() {
$this->child_cats = array();
parent::clearCategoryState();
}
2008-02-04 09:22:12 +00:00
function finaliseCategoryState() {
if ( $this->flip ) {
$this->child_cats = array_reverse( $this->child_cats );
}
parent::finaliseCategoryState();
}
}