Special case opus mime detction
[mediawiki.git] / includes / specials / SpecialShortpages.php
bloba78b082432d79c781a937fc8f83d9c8fb9978f8c
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 public function getQueryInfo() {
41 $tables = [ 'page' ];
42 $conds = [
43 'page_namespace' => MWNamespace::getContentNamespaces(),
44 'page_is_redirect' => 0
46 $joinConds = [];
47 $options = [ 'USE INDEX' => [ 'page' => 'page_redirect_namespace_len' ] ];
49 // Allow extensions to modify the query
50 Hooks::run( 'ShortPagesQuery', [ &$tables, &$conds, &$joinConds, &$options ] );
52 return [
53 'tables' => $tables,
54 'fields' => [
55 'namespace' => 'page_namespace',
56 'title' => 'page_title',
57 'value' => 'page_len'
59 'conds' => $conds,
60 'join_conds' => $joinConds,
61 'options' => $options
65 function getOrderFields() {
66 return [ 'page_len' ];
69 /**
70 * @param IDatabase $db
71 * @param ResultWrapper $res
73 function preprocessResults( $db, $res ) {
74 $this->executeLBFromResultWrapper( $res );
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', [ 'class' => 'mw-invalidtitle' ],
92 Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) );
95 $linkRenderer = $this->getLinkRenderer();
96 $hlink = $linkRenderer->makeKnownLink(
97 $title,
98 $this->msg( 'hist' )->text(),
99 [],
100 [ 'action' => 'history' ]
102 $hlinkInParentheses = $this->msg( 'parentheses' )->rawParams( $hlink )->escaped();
104 if ( $this->isCached() ) {
105 $plink = $linkRenderer->makeLink( $title );
106 $exists = $title->exists();
107 } else {
108 $plink = $linkRenderer->makeKnownLink( $title );
109 $exists = true;
112 $size = $this->msg( 'nbytes' )->numParams( $result->value )->escaped();
114 return $exists
115 ? "${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]"
116 : "<del>${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]</del>";
119 protected function getGroupName() {
120 return 'maintenance';