Second part of bug 4083: Special:Validation doesn't check wpEditToken
[mediawiki.git] / includes / SpecialWantedpages.php
blob742113e4323d0e2c9f6be6c4cb320e2df6a16f43
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 {
19 var $nlinks;
21 function WantedPagesPage( $inc = false, $nlinks = true ) {
22 $this->setListoutput( $inc );
23 $this->nlinks = $nlinks;
26 function getName() {
27 return 'Wantedpages';
30 function isExpensive() {
31 return true;
33 function isSyndicated() { return false; }
35 function getSQL() {
36 $dbr =& wfGetDB( DB_SLAVE );
37 $pagelinks = $dbr->tableName( 'pagelinks' );
38 $page = $dbr->tableName( 'page' );
39 return
40 "SELECT 'Wantedpages' AS type,
41 pl_namespace AS namespace,
42 pl_title AS title,
43 COUNT(*) AS value
44 FROM $pagelinks
45 LEFT JOIN $page
46 ON pl_namespace=page_namespace AND pl_title=page_title
47 WHERE page_namespace IS NULL
48 GROUP BY pl_namespace,pl_title
49 HAVING COUNT(*) > 1";
52 /**
53 * Fetch user page links and cache their existence
55 function preprocessResults( &$db, &$res ) {
56 $batch = new LinkBatch;
57 while ( $row = $db->fetchObject( $res ) )
58 $batch->addObj( Title::makeTitleSafe( $row->namespace, $row->title ) );
59 $batch->execute();
61 // Back to start for display
62 if ( $db->numRows( $res ) > 0 )
63 // If there are no rows we get an error seeking.
64 $db->dataSeek( $res, 0 );
68 function formatResult( $skin, $result ) {
69 global $wgContLang;
71 $nt = Title::makeTitle( $result->namespace, $result->title );
72 $text = $wgContLang->convert( $nt->getPrefixedText() );
73 $plink = $this->isCached() ?
74 $skin->makeLinkObj( $nt, $text ) :
75 $skin->makeBrokenLink( $nt->getPrefixedText(), $text );
77 $nl = wfMsg( 'nlinks', $result->value );
78 $nlink = $skin->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ), $nl, 'target=' . $nt->getPrefixedURL() );
80 return $this->nlinks ? "$plink ($nlink)" : $plink;
84 /**
85 * constructor
87 function wfSpecialWantedpages( $par = null, $specialPage ) {
88 $inc = $specialPage->including();
90 if ( $inc ) {
91 @list( $limit, $nlinks ) = explode( '/', $par, 2 );
92 $limit = (int)$limit;
93 $nlinks = $nlinks === 'nlinks';
94 $offset = 0;
95 } else {
96 list( $limit, $offset ) = wfCheckLimits();
97 $nlinks = true;
100 $wpp = new WantedPagesPage( $inc, $nlinks );
102 $wpp->doQuery( $offset, $limit, !$inc );