MediaWiki master
WantedQueryPage.php
Go to the documentation of this file.
1<?php
24namespace MediaWiki\SpecialPage;
25
27use Skin;
28use stdClass;
31
38abstract class WantedQueryPage extends QueryPage {
39 public function isExpensive() {
40 return true;
41 }
42
43 public function isSyndicated() {
44 return false;
45 }
46
53 protected function preprocessResults( $db, $res ) {
54 $this->executeLBFromResultWrapper( $res );
55 }
56
66 protected function forceExistenceCheck() {
67 return false;
68 }
69
79 public function formatResult( $skin, $result ) {
80 $linkRenderer = $this->getLinkRenderer();
81 $title = Title::makeTitleSafe( $result->namespace, $result->title );
82 if ( $title instanceof Title ) {
83 if ( $this->isCached() || $this->forceExistenceCheck() ) {
84 $pageLink = $this->existenceCheck( $title )
85 ? '<del>' . $linkRenderer->makeLink( $title ) . '</del>'
86 : $linkRenderer->makeLink( $title );
87 } else {
88 $pageLink = $linkRenderer->makeBrokenLink( $title );
89 }
90 return $this->getLanguage()->specialList( $pageLink, $this->makeWlhLink( $title, $result ) );
91 } else {
92 return $this->msg( 'wantedpages-badtitle', $result->title )->escaped();
93 }
94 }
95
114 protected function existenceCheck( Title $title ) {
115 return $title->isKnown();
116 }
117
125 protected function makeWlhLink( $title, $result ) {
126 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
127 $label = $this->msg( 'nlinks' )->numParams( $result->value )->text();
128 return $this->getLinkRenderer()->makeLink( $wlh, $label );
129 }
130
138 protected function getOrderFields() {
139 return [ 'value DESC', 'namespace', 'title' ];
140 }
141
152 protected function sortDescending() {
153 return false;
154 }
155
162 protected function getCacheOrderFields() {
163 return $this->getOrderFields();
164 }
165
166}
167
169class_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:88
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.
Class definition 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:78
isKnown()
Does this title refer to a page that can (or might) be meaningfully viewed? In particular,...
Definition Title.php:3280
The base class for all skins.
Definition Skin.php:58
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:36
Result wrapper for grabbing data queried from an IDatabase object.