4 * @addtogroup SpecialPage
9 * @addtogroup SpecialPage
11 class WantedPagesPage
extends QueryPage
{
14 function WantedPagesPage( $inc = false, $nlinks = true ) {
15 $this->setListoutput( $inc );
16 $this->nlinks
= $nlinks;
23 function isExpensive() {
26 function isSyndicated() { return false; }
29 global $wgWantedPagesThreshold;
30 $count = $wgWantedPagesThreshold - 1;
31 $dbr = wfGetDB( DB_SLAVE
);
32 $pagelinks = $dbr->tableName( 'pagelinks' );
33 $page = $dbr->tableName( 'page' );
35 "SELECT 'Wantedpages' AS type,
36 pl_namespace AS namespace,
40 LEFT JOIN $page AS pg1
41 ON pl_namespace = pg1.page_namespace AND pl_title = pg1.page_title
42 LEFT JOIN $page AS pg2
43 ON pl_from = pg2.page_id
44 WHERE pg1.page_namespace IS NULL
45 AND pl_namespace NOT IN ( 2, 3 )
46 AND pg2.page_namespace != 8
48 HAVING COUNT(*) > $count";
52 * Cache page existence for performance
54 function preprocessResults( &$db, &$res ) {
55 $batch = new LinkBatch
;
56 while ( $row = $db->fetchObject( $res ) )
57 $batch->addObj( Title
::makeTitleSafe( $row->namespace, $row->title
) );
60 // Back to start for display
61 if ( $db->numRows( $res ) > 0 )
62 // If there are no rows we get an error seeking.
63 $db->dataSeek( $res, 0 );
67 function formatResult( $skin, $result ) {
70 $title = Title
::makeTitleSafe( $result->namespace, $result->title
);
72 if( $this->isCached() ) {
73 # Check existence; which is stored in the link cache
74 if( !$title->exists() ) {
76 $pageLink = $skin->makeBrokenLinkObj( $title );
78 # Make a a struck-out normal link
79 $pageLink = "<s>" . $skin->makeLinkObj( $title ) . "</s>";
82 # Not cached? Don't bother checking existence; it can't
83 $pageLink = $skin->makeBrokenLinkObj( $title );
86 # Make a link to "what links here" if it's required
87 $wlhLink = $this->nlinks
88 ?
$this->makeWlhLink( $title, $skin,
89 wfMsgExt( 'nlinks', array( 'parsemag', 'escape'),
90 $wgLang->formatNum( $result->value
) ) )
93 return wfSpecialList($pageLink, $wlhLink);
97 * Make a "what links here" link for a specified title
98 * @param $title Title to make the link for
99 * @param $skin Skin to use
100 * @param $text Link text
103 function makeWlhLink( &$title, &$skin, $text ) {
104 $wlhTitle = SpecialPage
::getTitleFor( 'Whatlinkshere' );
105 return $skin->makeKnownLinkObj( $wlhTitle, $text, 'target=' . $title->getPrefixedUrl() );
113 function wfSpecialWantedpages( $par = null, $specialPage ) {
114 $inc = $specialPage->including();
117 @list
( $limit, $nlinks ) = explode( '/', $par, 2 );
118 $limit = (int)$limit;
119 $nlinks = $nlinks === 'nlinks';
122 list( $limit, $offset ) = wfCheckLimits();
126 $wpp = new WantedPagesPage( $inc, $nlinks );
128 $wpp->doQuery( $offset, $limit, !$inc );