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
;
25 use Wikimedia\Rdbms\IDatabase
;
28 * SpecialShortpages extends QueryPage. It is used to return the shortest
29 * pages in the database.
31 * @ingroup SpecialPage
33 class ShortPagesPage
extends QueryPage
{
35 function __construct( $name = 'Shortpages' ) {
36 parent
::__construct( $name );
39 function isSyndicated() {
43 public function getQueryInfo() {
46 'page_namespace' => MWNamespace
::getContentNamespaces(),
47 'page_is_redirect' => 0
50 $options = [ 'USE INDEX' => [ 'page' => 'page_redirect_namespace_len' ] ];
52 // Allow extensions to modify the query
53 Hooks
::run( 'ShortPagesQuery', [ &$tables, &$conds, &$joinConds, &$options ] );
58 'namespace' => 'page_namespace',
59 'title' => 'page_title',
63 'join_conds' => $joinConds,
68 function getOrderFields() {
69 return [ 'page_len' ];
73 * @param IDatabase $db
74 * @param ResultWrapper $res
76 function preprocessResults( $db, $res ) {
77 $this->executeLBFromResultWrapper( $res );
80 function sortDescending() {
86 * @param object $result Result row
89 function formatResult( $skin, $result ) {
90 $dm = $this->getLanguage()->getDirMark();
92 $title = Title
::makeTitleSafe( $result->namespace, $result->title
);
94 return Html
::element( 'span', [ 'class' => 'mw-invalidtitle' ],
95 Linker
::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title
) );
98 $linkRenderer = $this->getLinkRenderer();
99 $hlink = $linkRenderer->makeKnownLink(
101 $this->msg( 'hist' )->text(),
103 [ 'action' => 'history' ]
105 $hlinkInParentheses = $this->msg( 'parentheses' )->rawParams( $hlink )->escaped();
107 if ( $this->isCached() ) {
108 $plink = $linkRenderer->makeLink( $title );
109 $exists = $title->exists();
111 $plink = $linkRenderer->makeKnownLink( $title );
115 $size = $this->msg( 'nbytes' )->numParams( $result->value
)->escaped();
118 ?
"${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]"
119 : "<del>${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]</del>";
122 protected function getGroupName() {
123 return 'maintenance';