[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/page/ -> CategoryPage.php (source)

   1  <?php
   2  /**
   3   * Special handling for category description pages.
   4   * Modelled after ImagePage.php.
   5   *
   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.
  10   *
  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.
  15   *
  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
  20   *
  21   * @file
  22   */
  23  
  24  /**
  25   * Special handling for category description pages, showing pages,
  26   * subcategories and file that belong to the category
  27   */
  28  class CategoryPage extends Article {
  29      # Subclasses can change this to override the viewer class.
  30      protected $mCategoryViewerClass = 'CategoryViewer';
  31  
  32      /**
  33       * @param Title $title
  34       * @return WikiCategoryPage
  35       */
  36  	protected function newPage( Title $title ) {
  37          // Overload mPage with a category-specific page
  38          return new WikiCategoryPage( $title );
  39      }
  40  
  41      /**
  42       * Constructor from a page id
  43       * @param int $id Article ID to load
  44       * @return CategoryPage|null
  45       */
  46  	public static function newFromID( $id ) {
  47          $t = Title::newFromID( $id );
  48          # @todo FIXME: Doesn't inherit right
  49          return $t == null ? null : new self( $t );
  50          # return $t == null ? null : new static( $t ); // PHP 5.3
  51      }
  52  
  53  	function view() {
  54          $request = $this->getContext()->getRequest();
  55          $diff = $request->getVal( 'diff' );
  56          $diffOnly = $request->getBool( 'diffonly',
  57              $this->getContext()->getUser()->getOption( 'diffonly' ) );
  58  
  59          if ( $diff !== null && $diffOnly ) {
  60              parent::view();
  61              return;
  62          }
  63  
  64          if ( !wfRunHooks( 'CategoryPageView', array( &$this ) ) ) {
  65              return;
  66          }
  67  
  68          $title = $this->getTitle();
  69          if ( NS_CATEGORY == $title->getNamespace() ) {
  70              $this->openShowCategory();
  71          }
  72  
  73          parent::view();
  74  
  75          if ( NS_CATEGORY == $title->getNamespace() ) {
  76              $this->closeShowCategory();
  77          }
  78      }
  79  
  80  	function openShowCategory() {
  81          # For overloading
  82      }
  83  
  84  	function closeShowCategory() {
  85          // Use these as defaults for back compat --catrope
  86          $request = $this->getContext()->getRequest();
  87          $oldFrom = $request->getVal( 'from' );
  88          $oldUntil = $request->getVal( 'until' );
  89  
  90          $reqArray = $request->getValues();
  91  
  92          $from = $until = array();
  93          foreach ( array( 'page', 'subcat', 'file' ) as $type ) {
  94              $from[$type] = $request->getVal( "{$type}from", $oldFrom );
  95              $until[$type] = $request->getVal( "{$type}until", $oldUntil );
  96  
  97              // Do not want old-style from/until propagating in nav links.
  98              if ( !isset( $reqArray["{$type}from"] ) && isset( $reqArray["from"] ) ) {
  99                  $reqArray["{$type}from"] = $reqArray["from"];
 100              }
 101              if ( !isset( $reqArray["{$type}to"] ) && isset( $reqArray["to"] ) ) {
 102                  $reqArray["{$type}to"] = $reqArray["to"];
 103              }
 104          }
 105  
 106          unset( $reqArray["from"] );
 107          unset( $reqArray["to"] );
 108  
 109          $viewer = new $this->mCategoryViewerClass(
 110              $this->getContext()->getTitle(),
 111              $this->getContext(),
 112              $from,
 113              $until,
 114              $reqArray
 115          );
 116          $this->getContext()->getOutput()->addHTML( $viewer->getHTML() );
 117      }
 118  }


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1