Reject titles with %XX hex codes (since these have special meaning in URL links and...
[mediawiki.git] / includes / SpecialWantedpages.php
blob6171022431ce8b0a43415f47f4f097a5fdb22e2d
1 <?php
2 /**
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
8 /**
11 require_once ( 'QueryPage.php' ) ;
13 /**
15 * @package MediaWiki
16 * @subpackage SpecialPage
18 class WantedPagesPage extends QueryPage {
20 function getName() {
21 return 'Wantedpages';
24 function isExpensive() {
25 return true;
28 function getSQL() {
29 $dbr =& wfGetDB( DB_SLAVE );
30 $brokenlinks = $dbr->tableName( 'brokenlinks' );
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' : '');
47 function getOrder() {
48 return '';
51 function formatResult( $skin, $result ) {
52 global $wgContLang;
54 $nt = Title::newFromDBkey( $result->title );
55 if( is_null( $nt ) ) {
56 return "<!-- Bad title '" . htmlspecialchars( $result->title ) . "' -->";
58 $plink = $skin->makeBrokenLink( $nt->getPrefixedText(), "" );
59 $nl = wfMsg( "nlinks", $result->value );
60 $nlink = $skin->makeKnownLink( $wgContLang->specialPage( "Whatlinkshere" ), $nl,
61 "target=" . $nt->getPrefixedURL() );
63 return "{$plink} ({$nlink})";
67 /**
68 * constructor
70 function wfSpecialWantedpages() {
71 list( $limit, $offset ) = wfCheckLimits();
73 $wpp = new WantedPagesPage();
75 $wpp->doQuery( $offset, $limit );