Merge "Add ss_active_users in SiteStats::isSane"
[mediawiki.git] / includes / specials / SpecialShortpages.php
blob9b50875a3bfff59bc8dd1dc43db667486c810f74
1 <?php
2 /**
3 * Implements Special:Shortpages
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup SpecialPage
24 /**
25 * SpecialShortpages extends QueryPage. It is used to return the shortest
26 * pages in the database.
28 * @ingroup SpecialPage
30 class ShortPagesPage extends QueryPage {
32 function __construct( $name = 'Shortpages' ) {
33 parent::__construct( $name );
36 function isSyndicated() {
37 return false;
40 function getQueryInfo() {
41 return array(
42 'tables' => array( 'page' ),
43 'fields' => array( 'namespace' => 'page_namespace',
44 'title' => 'page_title',
45 'value' => 'page_len' ),
46 'conds' => array( 'page_namespace' =>
47 MWNamespace::getContentNamespaces(),
48 'page_is_redirect' => 0 ),
49 'options' => array( 'USE INDEX' => 'page_redirect_namespace_len' )
53 function getOrderFields() {
54 return array( 'page_len' );
57 /**
58 * @param $db DatabaseBase
59 * @param ResultWrapper $res
61 function preprocessResults( $db, $res ) {
62 # There's no point doing a batch check if we aren't caching results;
63 # the page must exist for it to have been pulled out of the table
64 if ( !$this->isCached() || !$res->numRows() ) {
65 return;
68 $batch = new LinkBatch();
69 foreach ( $res as $row ) {
70 $batch->add( $row->namespace, $row->title );
72 $batch->execute();
74 $res->seek( 0 );
77 function sortDescending() {
78 return false;
81 /**
82 * @param Skin $skin
83 * @param object $result Result row
84 * @return string
86 function formatResult( $skin, $result ) {
87 $dm = $this->getLanguage()->getDirMark();
89 $title = Title::makeTitleSafe( $result->namespace, $result->title );
90 if ( !$title ) {
91 return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ),
92 Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) );
95 $hlink = Linker::linkKnown(
96 $title,
97 $this->msg( 'hist' )->escaped(),
98 array(),
99 array( 'action' => 'history' )
101 $hlinkInParentheses = $this->msg( 'parentheses' )->rawParams( $hlink )->escaped();
103 if ( $this->isCached() ) {
104 $plink = Linker::link( $title );
105 $exists = $title->exists();
106 } else {
107 $plink = Linker::linkKnown( $title );
108 $exists = true;
111 $size = $this->msg( 'nbytes' )->numParams( $result->value )->escaped();
113 return $exists
114 ? "${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]"
115 : "<del>${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]</del>";
118 protected function getGroupName() {
119 return 'maintenance';