5 * @subpackage SpecialPage
11 require_once 'QueryPage.php';
16 * @subpackage SpecialPage
18 class WantedPagesPage
extends QueryPage
{
21 function WantedPagesPage( $inc = false, $nlinks = true ) {
22 $this->setListoutput( $inc );
23 $this->nlinks
= $nlinks;
30 function isExpensive() {
33 function isSyndicated() { return false; }
36 global $wgWantedPagesThreshold;
37 $count = $wgWantedPagesThreshold - 1;
38 $dbr =& wfGetDB( DB_SLAVE
);
39 $pagelinks = $dbr->tableName( 'pagelinks' );
40 $page = $dbr->tableName( 'page' );
42 "SELECT 'Wantedpages' AS type,
43 pl_namespace AS namespace,
48 ON pl_namespace=page_namespace AND pl_title=page_title
49 WHERE page_namespace IS NULL
50 GROUP BY pl_namespace,pl_title
51 HAVING COUNT(*) > $count";
55 * Cache page existence for performance
57 function preprocessResults( &$db, &$res ) {
58 $batch = new LinkBatch
;
59 while ( $row = $db->fetchObject( $res ) )
60 $batch->addObj( Title
::makeTitleSafe( $row->namespace, $row->title
) );
63 // Back to start for display
64 if ( $db->numRows( $res ) > 0 )
65 // If there are no rows we get an error seeking.
66 $db->dataSeek( $res, 0 );
70 function formatResult( $skin, $result ) {
73 $title = Title
::makeTitleSafe( $result->namespace, $result->title
);
75 if( $this->isCached() ) {
76 # Check existence; which is stored in the link cache
77 if( !$title->exists() ) {
79 $pageLink = $skin->makeBrokenLinkObj( $title );
81 # Make a struck-out blue link
82 $pageLink = "<s>" . $skin->makeKnownLinkObj( $title ) . "</s>";
85 # Not cached? Don't bother checking existence; it can't
86 $pageLink = $skin->makeBrokenLinkObj( $title );
89 # Make a link to "what links here" if it's required
90 $wlhLink = $this->nlinks
91 ?
" (" . $this->makeWlhLink( $title, $skin, wfMsgHtml( 'nlinks', $result->value
) ) . ")"
94 return "{$pageLink}{$wlhLink}";
98 * Make a "what links here" link for a specified title
99 * @param $title Title to make the link for
100 * @param $skin Skin to use
101 * @param $text Link text
104 function makeWlhLink( &$title, &$skin, $text ) {
105 $wlhTitle = Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' );
106 return $skin->makeKnownLinkObj( $wlhTitle, $text, 'target=' . $title->getPrefixedUrl() );
114 function wfSpecialWantedpages( $par = null, $specialPage ) {
115 $inc = $specialPage->including();
118 @list
( $limit, $nlinks ) = explode( '/', $par, 2 );
119 $limit = (int)$limit;
120 $nlinks = $nlinks === 'nlinks';
123 list( $limit, $offset ) = wfCheckLimits();
127 $wpp = new WantedPagesPage( $inc, $nlinks );
129 $wpp->doQuery( $offset, $limit, !$inc );