BUG#76 For categories, don't use the Category:-prefix for the sortkey.
[lhc/web/wiklou.git] / includes / SpecialWantedpages.php
1 <?php
2 /**
3 *
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7
8 /**
9 *
10 */
11 require_once ( 'QueryPage.php' ) ;
12
13 /**
14 *
15 * @package MediaWiki
16 * @subpackage SpecialPage
17 */
18 class WantedPagesPage extends QueryPage {
19
20 function getName() {
21 return 'Wantedpages';
22 }
23
24 function isExpensive() {
25 return true;
26 }
27
28 function getSQL() {
29 $dbr =& wfGetDB( DB_SLAVE );
30 $brokenlinks = $dbr->tableName( 'brokenlinks' );
31
32 # We cheat and return the full-text from bl_to in the title.
33 # In the future, a pre-parsed name will be available.
34 return
35 "SELECT 'Wantedpages' as type,
36 0 as namespace,
37 bl_to as title,
38 COUNT(DISTINCT bl_from) as value
39 FROM $brokenlinks
40 GROUP BY bl_to
41 HAVING value > 1";
42 }
43
44 function formatResult( $skin, $result ) {
45 global $wgLang;
46
47 $nt = Title::newFromDBkey( $result->title );
48 if( is_null( $nt ) ) {
49 return "<!-- Bad title '" . htmlspecialchars( $result->title ) . "' -->";
50 }
51 $plink = $skin->makeBrokenLink( $nt->getPrefixedText(), "" );
52 $nl = wfMsg( "nlinks", $result->value );
53 $nlink = $skin->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ), $nl,
54 "target=" . $nt->getPrefixedURL() );
55
56 return "{$plink} ({$nlink})";
57 }
58 }
59
60 /**
61 * constructor
62 */
63 function wfSpecialWantedpages() {
64 list( $limit, $offset ) = wfCheckLimits();
65
66 $wpp = new WantedPagesPage();
67
68 $wpp->doQuery( $offset, $limit );
69 }
70
71 ?>