3 * Implements Special:Wantedcategories
5 * Copyright © 2005 Ævar Arnfjörð Bjarmason
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.
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.
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
23 * @ingroup SpecialPage
27 * A querypage to list the most wanted categories - implements Special:Wantedcategories
29 * @ingroup SpecialPage
31 class WantedCategoriesPage
extends WantedQueryPage
{
32 private $currentCategoryCounts;
34 function __construct( $name = 'Wantedcategories' ) {
35 parent
::__construct( $name );
38 function getQueryInfo() {
40 'tables' => [ 'categorylinks', 'page' ],
42 'namespace' => NS_CATEGORY
,
46 'conds' => [ 'page_title IS NULL' ],
47 'options' => [ 'GROUP BY' => 'cl_to' ],
48 'join_conds' => [ 'page' => [ 'LEFT JOIN',
49 [ 'page_title = cl_to',
50 'page_namespace' => NS_CATEGORY
] ] ]
54 function preprocessResults( $db, $res ) {
55 parent
::preprocessResults( $db, $res );
57 $this->currentCategoryCounts
= [];
59 if ( !$res->numRows() ||
!$this->isCached() ) {
63 // Fetch (hopefully) up-to-date numbers of pages in each category.
64 // This should be fast enough as we limit the list to a reasonable length.
67 foreach ( $res as $row ) {
68 $allCategories[] = $row->title
;
71 $categoryRes = $db->select(
73 [ 'cat_title', 'cat_pages' ],
74 [ 'cat_title' => $allCategories ],
77 foreach ( $categoryRes as $row ) {
78 $this->currentCategoryCounts
[$row->cat_title
] = intval( $row->cat_pages
);
81 // Back to start for display
87 * @param object $result Result row
90 function formatResult( $skin, $result ) {
93 $nt = Title
::makeTitle( $result->namespace, $result->title
);
94 $text = htmlspecialchars( $wgContLang->convert( $nt->getText() ) );
96 if ( !$this->isCached() ) {
97 // We can assume the freshest data
98 $plink = Linker
::link(
105 $nlinks = $this->msg( 'nmembers' )->numParams( $result->value
)->escaped();
107 $plink = Linker
::link( $nt, $text );
109 $currentValue = isset( $this->currentCategoryCounts
[$result->title
] )
110 ?
$this->currentCategoryCounts
[$result->title
]
112 $cachedValue = intval( $result->value
); // T76910
114 // If the category has been created or emptied since the list was refreshed, strike it
115 if ( $nt->isKnown() ||
$currentValue === 0 ) {
116 $plink = "<del>$plink</del>";
119 // Show the current number of category entries if it changed
120 if ( $currentValue !== $cachedValue ) {
121 $nlinks = $this->msg( 'nmemberschanged' )
122 ->numParams( $cachedValue, $currentValue )->escaped();
124 $nlinks = $this->msg( 'nmembers' )->numParams( $cachedValue )->escaped();
128 return $this->getLanguage()->specialList( $plink, $nlinks );
131 protected function getGroupName() {
132 return 'maintenance';