MediaWiki master
WantedQueryPage.php
Go to the documentation of this file.
1<?php
8
11use stdClass;
14
21abstract class WantedQueryPage extends QueryPage {
23 public function isExpensive() {
24 return true;
25 }
26
28 public function isSyndicated() {
29 return false;
30 }
31
38 protected function preprocessResults( $db, $res ) {
39 $this->executeLBFromResultWrapper( $res );
40 }
41
51 protected function forceExistenceCheck() {
52 return false;
53 }
54
64 public function formatResult( $skin, $result ) {
65 $linkRenderer = $this->getLinkRenderer();
66 $title = Title::makeTitleSafe( $result->namespace, $result->title );
67 if ( $title instanceof Title ) {
68 if ( $this->isCached() || $this->forceExistenceCheck() ) {
69 $pageLink = $this->existenceCheck( $title )
70 ? '<del>' . $linkRenderer->makeLink( $title ) . '</del>'
71 : $linkRenderer->makeLink( $title );
72 } else {
73 $pageLink = $linkRenderer->makeBrokenLink( $title );
74 }
75 return $this->getLanguage()->specialList( $pageLink, $this->makeWlhLink( $title, $result ) );
76 } else {
77 return $this->msg( 'wantedpages-badtitle', $result->title )->escaped();
78 }
79 }
80
99 protected function existenceCheck( Title $title ) {
100 return $title->isKnown();
101 }
102
110 protected function makeWlhLink( $title, $result ) {
111 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
112 $label = $this->msg( 'nlinks' )->numParams( $result->value )->text();
113 return $this->getLinkRenderer()->makeLink( $wlh, $label );
114 }
115
123 protected function getOrderFields() {
124 return [ 'value DESC', 'namespace', 'title' ];
125 }
126
137 protected function sortDescending() {
138 return false;
139 }
140
147 protected function getCacheOrderFields() {
148 return $this->getOrderFields();
149 }
150
151}
152
154class_alias( WantedQueryPage::class, 'WantedQueryPage' );
The base class for all skins.
Definition Skin.php:52
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:77
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?If the query for this page is considere...
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.to override bool
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:70
isKnown()
Does this title refer to a page that can (or might) be meaningfully viewed? In particular,...
Definition Title.php:3196
A database connection without write operations.
Result wrapper for grabbing data queried from an IDatabase object.