2006-08-24 18:11:35 +00:00
|
|
|
<?php
|
2018-04-16 06:50:28 +00:00
|
|
|
/**
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
*/
|
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
|
|
|
|
*/
|
2018-04-11 03:47:26 +00:00
|
|
|
private function getCategoryTree() {
|
2018-04-16 06:41:38 +00:00
|
|
|
global $wgCategoryTreeCategoryPageOptions;
|
2008-06-28 20:13:20 +00:00
|
|
|
|
2012-02-09 01:23:31 +00:00
|
|
|
if ( !isset( $this->categorytree ) ) {
|
2018-04-16 06:41:38 +00:00
|
|
|
if ( !CategoryTreeHooks::shouldForceHeaders() ) {
|
2016-11-08 03:27:56 +00:00
|
|
|
CategoryTree::setHeaders( $this->getOutput() );
|
2012-02-09 01:23:31 +00:00
|
|
|
}
|
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
|
2017-10-11 18:25:13 +00:00
|
|
|
* @param Category $cat
|
|
|
|
* @param string $sortkey
|
|
|
|
* @param int $pageLength
|
2006-09-02 12:14:12 +00:00
|
|
|
*/
|
2018-04-11 03:47:26 +00:00
|
|
|
public function addSubcategoryObject( Category $cat, $sortkey, $pageLength ) {
|
2008-06-30 14:09:47 +00:00
|
|
|
$title = $cat->getTitle();
|
|
|
|
|
2016-11-08 03:27:56 +00:00
|
|
|
if ( $this->getRequest()->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
|
|
|
|
2018-04-11 03:47:26 +00:00
|
|
|
public 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
|
|
|
|
2018-04-11 03:47:26 +00:00
|
|
|
public 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();
|
|
|
|
}
|
|
|
|
}
|