MediaWiki REL1_39
WantedQueryPage.php
Go to the documentation of this file.
1<?php
26
33abstract class WantedQueryPage extends QueryPage {
34 public function isExpensive() {
35 return true;
36 }
37
38 public function isSyndicated() {
39 return false;
40 }
41
48 protected function preprocessResults( $db, $res ) {
50 }
51
61 protected function forceExistenceCheck() {
62 return false;
63 }
64
74 public function formatResult( $skin, $result ) {
75 $linkRenderer = $this->getLinkRenderer();
76 $title = Title::makeTitleSafe( $result->namespace, $result->title );
77 if ( $title instanceof Title ) {
78 if ( $this->isCached() || $this->forceExistenceCheck() ) {
79 $pageLink = $this->existenceCheck( $title )
80 ? '<del>' . $linkRenderer->makeLink( $title ) . '</del>'
81 : $linkRenderer->makeLink( $title );
82 } else {
83 $pageLink = $linkRenderer->makeBrokenLink( $title );
84 }
85 return $this->getLanguage()->specialList( $pageLink, $this->makeWlhLink( $title, $result ) );
86 } else {
87 return $this->msg( 'wantedpages-badtitle', $result->title )->escaped();
88 }
89 }
90
109 protected function existenceCheck( Title $title ) {
110 return $title->isKnown();
111 }
112
120 protected function makeWlhLink( $title, $result ) {
121 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
122 $label = $this->msg( 'nlinks' )->numParams( $result->value )->text();
123 return $this->getLinkRenderer()->makeLink( $wlh, $label );
124 }
125
133 protected function getOrderFields() {
134 return [ 'value DESC', 'namespace', 'title' ];
135 }
136
147 protected function sortDescending() {
148 return false;
149 }
150
157 protected function getCacheOrderFields() {
158 return $this->getOrderFields();
159 }
160
161}
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:42
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
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.
Represents a title within MediaWiki.
Definition Title.php:49
Class definition for a wanted query page like WantedPages, WantedTemplates, etc.
existenceCheck(Title $title)
Does the Title currently exists.
getCacheOrderFields()
Also use the order fields returned by getOrderFields when fetching from the cache.
sortDescending()
Do not order descending for all order fields.
forceExistenceCheck()
Should formatResult() always check page existence, even if the results are fresh? This is a (hopefull...
preprocessResults( $db, $res)
Cache page existence for performance.
getOrderFields()
Order by title for pages with the same number of links to them.
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
isExpensive()
Should this query page only be updated offline on large wikis?
formatResult( $skin, $result)
Format an individual result.
makeWlhLink( $title, $result)
Make a "what links here" link for a given title.
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.