mediawiki-extensions-Catego.../CategoryPageSubclass.php
Aryeh Gregor 07ab72b8aa Fix extensions to work with category sort changes
Three different extensions were copy-pasting all of
CategoryPage::closeShowCategory() just to change which CategoryViewer
descendant was used.  I changed the base class to use a member variable
for the CategoryViewer class, so this reduces code duplication too.  I
only tested this on CategoryTree; MetavidWiki is certainly still broken,
from the looks of it (assumes $this->from is a string), but
PeopleCategories might be okay.  Hard to avoid breaking extensions with
this sort of schema/index change.
2010-08-13 22:07:48 +00:00

53 lines
1.3 KiB
PHP

<?php
class CategoryTreeCategoryPage extends CategoryPage {
protected $mCategoryViewerClass = 'CategoryTreeCategoryViewer';
}
class CategoryTreeCategoryViewer extends CategoryViewer {
var $child_cats;
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;
$title = $cat->getTitle();
if ( $wgRequest->getCheck( 'notree' ) ) {
return parent::addSubcategoryObject( $cat, $sortkey, $pageLength );
}
$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();
}
}