fcdb893f0307a27fc70be18deb490dcf6de2af48
[lhc/web/wiklou.git] / includes / specials / SpecialWantedcategories.php
1 <?php
2 /**
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 * http://www.gnu.org/copyleft/gpl.html
18 */
19
20 /**
21 * A querypage to list the most wanted categories - implements Special:Wantedcategories
22 *
23 * @file
24 * @ingroup SpecialPage
25 *
26 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
27 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
28 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
29 */
30 class WantedCategoriesPage extends WantedQueryPage {
31
32 function getName() {
33 return 'Wantedcategories';
34 }
35
36 function getSQL() {
37 $dbr = wfGetDB( DB_SLAVE );
38 list( $categorylinks, $page ) = $dbr->tableNamesN( 'categorylinks', 'page' );
39 $name = $dbr->addQuotes( $this->getName() );
40 return
41 "
42 SELECT
43 $name as type,
44 " . NS_CATEGORY . " as namespace,
45 cl_to as title,
46 COUNT(*) as value
47 FROM $categorylinks
48 LEFT JOIN $page ON cl_to = page_title AND page_namespace = ". NS_CATEGORY ."
49 WHERE page_title IS NULL
50 GROUP BY cl_to
51 ";
52 }
53
54 function formatResult( $skin, $result ) {
55 global $wgLang, $wgContLang;
56
57 $nt = Title::makeTitle( $result->namespace, $result->title );
58 $text = htmlspecialchars( $wgContLang->convert( $nt->getText() ) );
59
60 $plink = $this->isCached() ?
61 $skin->link( $nt, $text ) :
62 $skin->link(
63 $nt,
64 $text,
65 array(),
66 array(),
67 array( 'broken' )
68 );
69
70 $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),
71 $wgLang->formatNum( $result->value ) );
72 return wfSpecialList($plink, $nlinks);
73 }
74 }
75
76 /**
77 * constructor
78 */
79 function wfSpecialWantedCategories() {
80 list( $limit, $offset ) = wfCheckLimits();
81
82 $wpp = new WantedCategoriesPage();
83
84 $wpp->doQuery( $offset, $limit );
85 }