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
21 * @ingroup SpecialPage
24 use Wikimedia\Rdbms\ResultWrapper
;
27 * SpecialShortpages extends QueryPage. It is used to return the shortest
28 * pages in the database.
30 * @ingroup SpecialPage
32 class ShortPagesPage
extends QueryPage
{
34 function __construct( $name = 'Shortpages' ) {
35 parent
::__construct( $name );
38 function isSyndicated() {
42 public function getQueryInfo() {
45 'page_namespace' => MWNamespace
::getContentNamespaces(),
46 'page_is_redirect' => 0
49 $options = [ 'USE INDEX' => [ 'page' => 'page_redirect_namespace_len' ] ];
51 // Allow extensions to modify the query
52 Hooks
::run( 'ShortPagesQuery', [ &$tables, &$conds, &$joinConds, &$options ] );
57 'namespace' => 'page_namespace',
58 'title' => 'page_title',
62 'join_conds' => $joinConds,
67 function getOrderFields() {
68 return [ 'page_len' ];
72 * @param IDatabase $db
73 * @param ResultWrapper $res
75 function preprocessResults( $db, $res ) {
76 $this->executeLBFromResultWrapper( $res );
79 function sortDescending() {
85 * @param object $result Result row
88 function formatResult( $skin, $result ) {
89 $dm = $this->getLanguage()->getDirMark();
91 $title = Title
::makeTitleSafe( $result->namespace, $result->title
);
93 return Html
::element( 'span', [ 'class' => 'mw-invalidtitle' ],
94 Linker
::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title
) );
97 $linkRenderer = $this->getLinkRenderer();
98 $hlink = $linkRenderer->makeKnownLink(
100 $this->msg( 'hist' )->text(),
102 [ 'action' => 'history' ]
104 $hlinkInParentheses = $this->msg( 'parentheses' )->rawParams( $hlink )->escaped();
106 if ( $this->isCached() ) {
107 $plink = $linkRenderer->makeLink( $title );
108 $exists = $title->exists();
110 $plink = $linkRenderer->makeKnownLink( $title );
114 $size = $this->msg( 'nbytes' )->numParams( $result->value
)->escaped();
117 ?
"${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]"
118 : "<del>${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]</del>";
121 protected function getGroupName() {
122 return 'maintenance';