MediaWiki master
WantedQueryPage.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\SpecialPage;
22
24use Skin;
25use stdClass;
28
35abstract class WantedQueryPage extends QueryPage {
36 public function isExpensive() {
37 return true;
38 }
39
40 public function isSyndicated() {
41 return false;
42 }
43
50 protected function preprocessResults( $db, $res ) {
51 $this->executeLBFromResultWrapper( $res );
52 }
53
63 protected function forceExistenceCheck() {
64 return false;
65 }
66
76 public function formatResult( $skin, $result ) {
77 $linkRenderer = $this->getLinkRenderer();
78 $title = Title::makeTitleSafe( $result->namespace, $result->title );
79 if ( $title instanceof Title ) {
80 if ( $this->isCached() || $this->forceExistenceCheck() ) {
81 $pageLink = $this->existenceCheck( $title )
82 ? '<del>' . $linkRenderer->makeLink( $title ) . '</del>'
83 : $linkRenderer->makeLink( $title );
84 } else {
85 $pageLink = $linkRenderer->makeBrokenLink( $title );
86 }
87 return $this->getLanguage()->specialList( $pageLink, $this->makeWlhLink( $title, $result ) );
88 } else {
89 return $this->msg( 'wantedpages-badtitle', $result->title )->escaped();
90 }
91 }
92
111 protected function existenceCheck( Title $title ) {
112 return $title->isKnown();
113 }
114
122 protected function makeWlhLink( $title, $result ) {
123 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
124 $label = $this->msg( 'nlinks' )->numParams( $result->value )->text();
125 return $this->getLinkRenderer()->makeLink( $wlh, $label );
126 }
127
135 protected function getOrderFields() {
136 return [ 'value DESC', 'namespace', 'title' ];
137 }
138
149 protected function sortDescending() {
150 return false;
151 }
152
159 protected function getCacheOrderFields() {
160 return $this->getOrderFields();
161 }
162
163}
164
166class_alias( WantedQueryPage::class, 'WantedQueryPage' );
This is a class for doing query pages; since they're almost all the same, we factor out some of the f...
Definition QueryPage.php:89
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getLanguage()
Shortcut to get user's language.
Base class for a "wanted" query page like WantedPages, WantedTemplates, etc.
forceExistenceCheck()
Should formatResult() always check page existence, even if the results are fresh? This is a (hopefull...
existenceCheck(Title $title)
Does the Title currently exists.
isExpensive()
Should this query page only be updated offline on large wikis?
getOrderFields()
Order by title for pages with the same number of links to them.
preprocessResults( $db, $res)
Cache page existence for performance.
getCacheOrderFields()
Also use the order fields returned by getOrderFields when fetching from the cache.
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
formatResult( $skin, $result)
Format an individual result.
sortDescending()
Do not order descending for all order fields.
makeWlhLink( $title, $result)
Make a "what links here" link for a given title.
Represents a title within MediaWiki.
Definition Title.php:79
isKnown()
Does this title refer to a page that can (or might) be meaningfully viewed? In particular,...
Definition Title.php:3216
The base class for all skins.
Definition Skin.php:59
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:39
Result wrapper for grabbing data queried from an IDatabase object.