]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/specials/SpecialWantedcategories.php
MediaWiki 1.16.1-scripts
[autoinstallsdev/mediawiki.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 = htmlspecialchars( $wgContLang->convert( $nt->getText() ) );
45
46                 $plink = $this->isCached() ?
47                         $skin->link( $nt, $text ) :
48                         $skin->link(
49                                 $nt,
50                                 $text,
51                                 array(),
52                                 array(),
53                                 array( 'broken' )
54                         );
55
56                 $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),
57                         $wgLang->formatNum( $result->value ) );
58                 return wfSpecialList($plink, $nlinks);
59         }
60 }
61
62 /**
63  * constructor
64  */
65 function wfSpecialWantedCategories() {
66         list( $limit, $offset ) = wfCheckLimits();
67
68         $wpp = new WantedCategoriesPage();
69
70         $wpp->doQuery( $offset, $limit );
71 }