4d54c86e37a90ba7fd7ac6a787ae5c307a5eb446
[lhc/web/wiklou.git] / includes / specials / SpecialWantedcategories.php
1 <?php
2 /**
3 * @file
4 * @ingroup SpecialPage
5 */
6
7 /**
8 * A querypage to list the most wanted categories - implements Special:Wantedcategories
9 *
10 * @ingroup SpecialPage
11 *
12 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
13 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
14 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
15 */
16 class WantedCategoriesPage extends WantedQueryPage {
17
18 function getName() {
19 return 'Wantedcategories';
20 }
21
22 function getSQL() {
23 $dbr = wfGetDB( DB_SLAVE );
24 list( $categorylinks, $page ) = $dbr->tableNamesN( 'categorylinks', 'page' );
25 $name = $dbr->addQuotes( $this->getName() );
26 return
27 "
28 SELECT
29 $name as type,
30 " . NS_CATEGORY . " as namespace,
31 cl_to as title,
32 COUNT(*) as value
33 FROM $categorylinks
34 LEFT JOIN $page ON cl_to = page_title AND page_namespace = ". NS_CATEGORY ."
35 WHERE page_title IS NULL
36 GROUP BY cl_to
37 ";
38 }
39
40 function formatResult( $skin, $result ) {
41 global $wgLang, $wgContLang;
42
43 $nt = Title::makeTitle( $result->namespace, $result->title );
44 $text = $wgContLang->convert( $nt->getText() );
45
46 $plink = $this->isCached() ?
47 $skin->link( $nt, htmlspecialchars( $text ) ) :
48 $skin->makeBrokenLinkObj( $nt, htmlspecialchars( $text ) );
49
50 $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),
51 $wgLang->formatNum( $result->value ) );
52 return wfSpecialList($plink, $nlinks);
53 }
54 }
55
56 /**
57 * constructor
58 */
59 function wfSpecialWantedCategories() {
60 list( $limit, $offset ) = wfCheckLimits();
61
62 $wpp = new WantedCategoriesPage();
63
64 $wpp->doQuery( $offset, $limit );
65 }