When the CSRF token on is not available in the session, show the
[lhc/web/wiklou.git] / includes / specials / SpecialWantedcategories.php
1 <?php
2 /**
3 * Implements Special:Wantedcategories
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 */
25
26 /**
27 * A querypage to list the most wanted categories - implements Special:Wantedcategories
28 *
29 * @ingroup SpecialPage
30 */
31 class WantedCategoriesPage extends WantedQueryPage {
32
33 function getName() {
34 return 'Wantedcategories';
35 }
36
37 function getSQL() {
38 $dbr = wfGetDB( DB_SLAVE );
39 list( $categorylinks, $page ) = $dbr->tableNamesN( 'categorylinks', 'page' );
40 $name = $dbr->addQuotes( $this->getName() );
41 return
42 "
43 SELECT
44 $name as type,
45 " . NS_CATEGORY . " as namespace,
46 cl_to as title,
47 COUNT(*) as value
48 FROM $categorylinks
49 LEFT JOIN $page ON cl_to = page_title AND page_namespace = ". NS_CATEGORY ."
50 WHERE page_title IS NULL
51 GROUP BY cl_to
52 ";
53 }
54
55 function formatResult( $skin, $result ) {
56 global $wgLang, $wgContLang;
57
58 $nt = Title::makeTitle( $result->namespace, $result->title );
59 $text = htmlspecialchars( $wgContLang->convert( $nt->getText() ) );
60
61 $plink = $this->isCached() ?
62 $skin->link( $nt, $text ) :
63 $skin->link(
64 $nt,
65 $text,
66 array(),
67 array(),
68 array( 'broken' )
69 );
70
71 $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),
72 $wgLang->formatNum( $result->value ) );
73 return wfSpecialList($plink, $nlinks);
74 }
75 }
76
77 /**
78 * constructor
79 */
80 function wfSpecialWantedCategories() {
81 list( $limit, $offset ) = wfCheckLimits();
82
83 $wpp = new WantedCategoriesPage();
84
85 $wpp->doQuery( $offset, $limit );
86 }