MediaWiki REL1_33
WantedQueryPage.php
Go to the documentation of this file.
1<?php
26
32abstract class WantedQueryPage extends QueryPage {
33 function isExpensive() {
34 return true;
35 }
36
37 function isSyndicated() {
38 return false;
39 }
40
46 function preprocessResults( $db, $res ) {
48 }
49
59 return false;
60 }
61
69 public function formatResult( $skin, $result ) {
71 $title = Title::makeTitleSafe( $result->namespace, $result->title );
72 if ( $title instanceof Title ) {
73 if ( $this->isCached() || $this->forceExistenceCheck() ) {
74 $pageLink = $this->existenceCheck( $title )
75 ? '<del>' . $linkRenderer->makeLink( $title ) . '</del>'
76 : $linkRenderer->makeLink( $title );
77 } else {
78 $pageLink = $linkRenderer->makeLink(
79 $title,
80 null,
81 [],
82 [],
83 [ 'broken' ]
84 );
85 }
86 return $this->getLanguage()->specialList( $pageLink, $this->makeWlhLink( $title, $result ) );
87 } else {
88 return $this->msg( 'wantedpages-badtitle', $result->title )->escaped();
89 }
90 }
91
108 protected function existenceCheck( Title $title ) {
109 return $title->isKnown();
110 }
111
119 private function makeWlhLink( $title, $result ) {
120 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
121 $label = $this->msg( 'nlinks' )->numParams( $result->value )->text();
122 return $this->getLinkRenderer()->makeLink( $wlh, $label );
123 }
124
131 function getOrderFields() {
132 return [ 'value DESC', 'namespace', 'title' ];
133 }
134
144 function sortDescending() {
145 return false;
146 }
147
154 return $this->getOrderFields();
155 }
156
157}
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:35
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed ResultWrapper (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)
Wrapper around wfMessage that sets the current context.
getLanguage()
Shortcut to get user's language.
MediaWiki Linker LinkRenderer null $linkRenderer
Represents a title within MediaWiki.
Definition Title.php:40
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()
Sometime we don't want to build rss / atom feeds.
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
formatResult( $skin, $result)
Format an individual result.
makeWlhLink( $title, $result)
Make a "what links here" link for a given title.
$res
Definition database.txt:21
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38
Result wrapper for grabbing data queried from an IDatabase object.