fix a problem by not inserting __MWTEMPLATESECTION for section titles that don't...
[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 $agrvalue=$dbr->aggregateValue('COUNT(DISTINCT bl_from)');
35 return
36 "SELECT 'Wantedpages' as type,
37 0 as namespace,
38 bl_to as title,
39 COUNT(DISTINCT bl_from) as value
40 FROM $brokenlinks
41 GROUP BY bl_to
42 HAVING $agrvalue > 1
43 ORDER BY $agrvalue ".
44 ($this->sortDescending() ? 'DESC' : '');
45 }
46
47 function getOrder() {
48 return '';
49 }
50
51 function formatResult( $skin, $result ) {
52 global $wgLang;
53
54 $nt = Title::newFromDBkey( $result->title );
55 if( is_null( $nt ) ) {
56 return "<!-- Bad title '" . htmlspecialchars( $result->title ) . "' -->";
57 }
58 $plink = $skin->makeBrokenLink( $nt->getPrefixedText(), "" );
59 $nl = wfMsg( "nlinks", $result->value );
60 $nlink = $skin->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ), $nl,
61 "target=" . $nt->getPrefixedURL() );
62
63 return "{$plink} ({$nlink})";
64 }
65 }
66
67 /**
68 * constructor
69 */
70 function wfSpecialWantedpages() {
71 list( $limit, $offset ) = wfCheckLimits();
72
73 $wpp = new WantedPagesPage();
74
75 $wpp->doQuery( $offset, $limit );
76 }
77
78 ?>