3 * Class for viewing MediaWiki category description pages.
4 * Modelled after ImagePage.php.
9 if ( !defined( 'MEDIAWIKI' ) )
13 * Special handling for category description pages, showing pages,
14 * subcategories and file that belong to the category
16 class CategoryPage
extends Article
{
17 # Subclasses can change this to override the viewer class.
18 protected $mCategoryViewerClass = 'CategoryViewer';
22 * @return WikiCategoryPage
24 protected function newPage( Title
$title ) {
25 // Overload mPage with a category-specific page
26 return new WikiCategoryPage( $title );
30 * Constructor from a page id
31 * @param $id Int article ID to load
32 * @return CategoryPage|null
34 public static function newFromID( $id ) {
35 $t = Title
::newFromID( $id );
36 # @todo FIXME: Doesn't inherit right
37 return $t == null ?
null : new self( $t );
38 # return $t == null ? null : new static( $t ); // PHP 5.3
42 $request = $this->getContext()->getRequest();
43 $diff = $request->getVal( 'diff' );
44 $diffOnly = $request->getBool( 'diffonly',
45 $this->getContext()->getUser()->getOption( 'diffonly' ) );
47 if ( isset( $diff ) && $diffOnly ) {
52 if ( !wfRunHooks( 'CategoryPageView', array( &$this ) ) ) {
56 $title = $this->getTitle();
57 if ( NS_CATEGORY
== $title->getNamespace() ) {
58 $this->openShowCategory();
63 if ( NS_CATEGORY
== $title->getNamespace() ) {
64 $this->closeShowCategory();
68 function openShowCategory() {
72 function closeShowCategory() {
73 // Use these as defaults for back compat --catrope
74 $request = $this->getContext()->getRequest();
75 $oldFrom = $request->getVal( 'from' );
76 $oldUntil = $request->getVal( 'until' );
78 $reqArray = $request->getValues();
80 $from = $until = array();
81 foreach ( array( 'page', 'subcat', 'file' ) as $type ) {
82 $from[$type] = $request->getVal( "{$type}from", $oldFrom );
83 $until[$type] = $request->getVal( "{$type}until", $oldUntil );
85 // Do not want old-style from/until propagating in nav links.
86 if ( !isset( $reqArray["{$type}from"] ) && isset( $reqArray["from"] ) ) {
87 $reqArray["{$type}from"] = $reqArray["from"];
89 if ( !isset( $reqArray["{$type}to"] ) && isset( $reqArray["to"] ) ) {
90 $reqArray["{$type}to"] = $reqArray["to"];
94 unset( $reqArray["from"] );
95 unset( $reqArray["to"] );
97 $viewer = new $this->mCategoryViewerClass( $this->getContext()->getTitle(), $this->getContext(), $from, $until, $reqArray );
98 $this->getContext()->getOutput()->addHTML( $viewer->getHTML() );