* (bug 3803) Fix links on Special:Wantedcategories with miser mode off
[lhc/web/wiklou.git] / includes / SpecialWantedcategories.php
1 <?php
2 /**
3 * A querypage to list the most wanted categories
4 *
5 * @package MediaWiki
6 * @subpackage SpecialPage
7 *
8 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
9 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
10 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
11 */
12
13 /* */
14 require_once 'QueryPage.php';
15
16 /**
17 * @package MediaWiki
18 * @subpackage SpecialPage
19 */
20 class WantedCategoriesPage extends QueryPage {
21
22 function getName() { return 'Wantedcategories'; }
23 function isExpensive() { return true; }
24 function isSyndicated() { return false; }
25
26 function getSQL() {
27 $dbr =& wfGetDB( DB_SLAVE );
28 extract( $dbr->tableNames( 'categorylinks', 'page' ) );
29 $name = $dbr->addQuotes( $this->getName() );
30 return
31 "
32 SELECT
33 $name as type,
34 " . NS_CATEGORY . " as namespace,
35 cl_to as title,
36 COUNT(*) as value
37 FROM $categorylinks
38 LEFT JOIN $page ON cl_to = page_title
39 WHERE page_len IS NULL
40 GROUP BY cl_to
41 ";
42 }
43
44 function sortDescending() { return true; }
45
46 function formatResult( $skin, $result ) {
47 global $wgContLang;
48
49 $nt = Title::makeTitle( $result->namespace, $result->title );
50 $text = $wgContLang->convert( $nt->getText() );
51
52 $plink = $this->isCached() ?
53 $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ) :
54 $skin->makeBrokenLinkObj( $nt, htmlspecialchars( $text ) );
55
56 $nlinks = wfMsg( 'nlinks', $result->value );
57 return "$plink ($nlinks)";
58 }
59 }
60
61 /**
62 * constructor
63 */
64 function wfSpecialWantedCategories() {
65 list( $limit, $offset ) = wfCheckLimits();
66
67 $wpp = new WantedCategoriesPage();
68
69 $wpp->doQuery( $offset, $limit );
70 }
71
72 ?>