3 * Special handling for category description pages.
4 * Modelled after ImagePage.php.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
24 if ( !defined( 'MEDIAWIKI' ) )
28 * Special handling for category description pages, showing pages,
29 * subcategories and file that belong to the category
31 class CategoryPage
extends Article
{
32 # Subclasses can change this to override the viewer class.
33 protected $mCategoryViewerClass = 'CategoryViewer';
37 * @return WikiCategoryPage
39 protected function newPage( Title
$title ) {
40 // Overload mPage with a category-specific page
41 return new WikiCategoryPage( $title );
45 * Constructor from a page id
46 * @param $id Int article ID to load
47 * @return CategoryPage|null
49 public static function newFromID( $id ) {
50 $t = Title
::newFromID( $id );
51 # @todo FIXME: Doesn't inherit right
52 return $t == null ?
null : new self( $t );
53 # return $t == null ? null : new static( $t ); // PHP 5.3
57 $request = $this->getContext()->getRequest();
58 $diff = $request->getVal( 'diff' );
59 $diffOnly = $request->getBool( 'diffonly',
60 $this->getContext()->getUser()->getOption( 'diffonly' ) );
62 if ( isset( $diff ) && $diffOnly ) {
67 if ( !wfRunHooks( 'CategoryPageView', array( &$this ) ) ) {
71 $title = $this->getTitle();
72 if ( NS_CATEGORY
== $title->getNamespace() ) {
73 $this->openShowCategory();
78 if ( NS_CATEGORY
== $title->getNamespace() ) {
79 $this->closeShowCategory();
83 function openShowCategory() {
87 function closeShowCategory() {
88 // Use these as defaults for back compat --catrope
89 $request = $this->getContext()->getRequest();
90 $oldFrom = $request->getVal( 'from' );
91 $oldUntil = $request->getVal( 'until' );
93 $reqArray = $request->getValues();
95 $from = $until = array();
96 foreach ( array( 'page', 'subcat', 'file' ) as $type ) {
97 $from[$type] = $request->getVal( "{$type}from", $oldFrom );
98 $until[$type] = $request->getVal( "{$type}until", $oldUntil );
100 // Do not want old-style from/until propagating in nav links.
101 if ( !isset( $reqArray["{$type}from"] ) && isset( $reqArray["from"] ) ) {
102 $reqArray["{$type}from"] = $reqArray["from"];
104 if ( !isset( $reqArray["{$type}to"] ) && isset( $reqArray["to"] ) ) {
105 $reqArray["{$type}to"] = $reqArray["to"];
109 unset( $reqArray["from"] );
110 unset( $reqArray["to"] );
112 $viewer = new $this->mCategoryViewerClass( $this->getContext()->getTitle(), $this->getContext(), $from, $until, $reqArray );
113 $this->getContext()->getOutput()->addHTML( $viewer->getHTML() );