Some documentation. Let's talk about it in wikitech-l.
[mediawiki.git] / includes / SpecialWantedpages.php
blob6369e16c5bd5d3843bcd93dbca14b9fe180279c5
1 <?php
2 /**
4 */
6 /**
8 */
9 require_once ( 'QueryPage.php' ) ;
11 /**
14 class WantedPagesPage extends QueryPage {
16 function getName() {
17 return 'Wantedpages';
20 function isExpensive() {
21 return true;
24 function getSQL() {
25 $dbr =& wfGetDB( DB_SLAVE );
26 $brokenlinks = $dbr->tableName( 'brokenlinks' );
28 # We cheat and return the full-text from bl_to in the title.
29 # In the future, a pre-parsed name will be available.
30 return
31 "SELECT 'Wantedpages' as type,
32 0 as namespace,
33 bl_to as title,
34 COUNT(DISTINCT bl_from) as value
35 FROM $brokenlinks
36 GROUP BY bl_to
37 HAVING value > 1";
40 function formatResult( $skin, $result ) {
41 global $wgLang;
43 $nt = Title::newFromDBkey( $result->title );
44 if( is_null( $nt ) ) {
45 return "<!-- Bad title '" . htmlspecialchars( $result->title ) . "' -->";
47 $plink = $skin->makeBrokenLink( $nt->getPrefixedText(), "" );
48 $nl = wfMsg( "nlinks", $result->value );
49 $nlink = $skin->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ), $nl,
50 "target=" . $nt->getPrefixedURL() );
52 return "{$plink} ({$nlink})";
56 /**
57 * constructor
59 function wfSpecialWantedpages() {
60 list( $limit, $offset ) = wfCheckLimits();
62 $wpp = new WantedPagesPage();
64 $wpp->doQuery( $offset, $limit );