Add rate limiter to Special:ConfirmEmail
[lhc/web/wiklou.git] / includes / specials / SpecialMostlinkedcategories.php
1 <?php
2 /**
3 * Implements Special:Mostlinkedcategories
4 *
5 * Copyright © 2005, Ævar Arnfjörð Bjarmason
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
21 *
22 * @file
23 * @ingroup SpecialPage
24 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
25 */
26
27 use MediaWiki\MediaWikiServices;
28 use Wikimedia\Rdbms\IResultWrapper;
29 use Wikimedia\Rdbms\IDatabase;
30
31 /**
32 * A querypage to show categories ordered in descending order by the pages in them
33 *
34 * @ingroup SpecialPage
35 */
36 class MostlinkedCategoriesPage extends QueryPage {
37 function __construct( $name = 'Mostlinkedcategories' ) {
38 parent::__construct( $name );
39 }
40
41 function isSyndicated() {
42 return false;
43 }
44
45 public function getQueryInfo() {
46 return [
47 'tables' => [ 'category' ],
48 'fields' => [ 'title' => 'cat_title',
49 'namespace' => NS_CATEGORY,
50 'value' => 'cat_pages' ],
51 'conds' => [ 'cat_pages > 0' ],
52 ];
53 }
54
55 function sortDescending() {
56 return true;
57 }
58
59 /**
60 * Fetch user page links and cache their existence
61 *
62 * @param IDatabase $db
63 * @param IResultWrapper $res
64 */
65 function preprocessResults( $db, $res ) {
66 $this->executeLBFromResultWrapper( $res );
67 }
68
69 /**
70 * @param Skin $skin
71 * @param object $result Result row
72 * @return string
73 */
74 function formatResult( $skin, $result ) {
75 $nt = Title::makeTitleSafe( NS_CATEGORY, $result->title );
76 if ( !$nt ) {
77 return Html::element(
78 'span',
79 [ 'class' => 'mw-invalidtitle' ],
80 Linker::getInvalidTitleDescription(
81 $this->getContext(),
82 NS_CATEGORY,
83 $result->title )
84 );
85 }
86
87 $text = MediaWikiServices::getInstance()->getContentLanguage()
88 ->convert( htmlspecialchars( $nt->getText() ) );
89 $plink = $this->getLinkRenderer()->makeLink( $nt, new HtmlArmor( $text ) );
90 $nlinks = $this->msg( 'nmembers' )->numParams( $result->value )->escaped();
91
92 return $this->getLanguage()->specialList( $plink, $nlinks );
93 }
94
95 protected function getGroupName() {
96 return 'highuse';
97 }
98 }