MediaWiki  master
WantedQueryPage.php
Go to the documentation of this file.
1 <?php
26 
32 abstract class WantedQueryPage extends QueryPage {
33  public function isExpensive() {
34  return true;
35  }
36 
37  public function isSyndicated() {
38  return false;
39  }
40 
46  protected function preprocessResults( $db, $res ) {
48  }
49 
58  protected function forceExistenceCheck() {
59  return false;
60  }
61 
69  public function formatResult( $skin, $result ) {
70  $linkRenderer = $this->getLinkRenderer();
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->makeBrokenLink( $title );
79  }
80  return $this->getLanguage()->specialList( $pageLink, $this->makeWlhLink( $title, $result ) );
81  } else {
82  return $this->msg( 'wantedpages-badtitle', $result->title )->escaped();
83  }
84  }
85 
102  protected function existenceCheck( Title $title ) {
103  return $title->isKnown();
104  }
105 
113  protected function makeWlhLink( $title, $result ) {
114  $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
115  $label = $this->msg( 'nlinks' )->numParams( $result->value )->text();
116  return $this->getLinkRenderer()->makeLink( $wlh, $label );
117  }
118 
125  protected function getOrderFields() {
126  return [ 'value DESC', 'namespace', 'title' ];
127  }
128 
138  protected function sortDescending() {
139  return false;
140  }
141 
147  protected function getCacheOrderFields() {
148  return $this->getOrderFields();
149  }
150 
151 }
WantedQueryPage\existenceCheck
existenceCheck(Title $title)
Does the Title currently exists.
Definition: WantedQueryPage.php:102
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:810
WantedQueryPage\forceExistenceCheck
forceExistenceCheck()
Should formatResult() always check page existence, even if the results are fresh? This is a (hopefull...
Definition: WantedQueryPage.php:58
WantedQueryPage\preprocessResults
preprocessResults( $db, $res)
Cache page existence for performance.
Definition: WantedQueryPage.php:46
SpecialPage\getTitleFor
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,...
Definition: SpecialPage.php:83
WantedQueryPage\formatResult
formatResult( $skin, $result)
Format an individual result.
Definition: WantedQueryPage.php:69
WantedQueryPage\isSyndicated
isSyndicated()
Sometime we don't want to build rss / atom feeds.
Definition: WantedQueryPage.php:37
WantedQueryPage\isExpensive
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
Definition: WantedQueryPage.php:33
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:756
WantedQueryPage\getOrderFields
getOrderFields()
Order by title for pages with the same number of links to them.
Definition: WantedQueryPage.php:125
$res
$res
Definition: testCompression.php:57
WantedQueryPage\getCacheOrderFields
getCacheOrderFields()
Also use the order fields returned by getOrderFields when fetching from the cache.
Definition: WantedQueryPage.php:147
QueryPage
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:36
QueryPage\executeLBFromResultWrapper
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
Definition: QueryPage.php:801
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
QueryPage\isCached
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
Definition: QueryPage.php:258
$title
$title
Definition: testCompression.php:38
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:621
WantedQueryPage\makeWlhLink
makeWlhLink( $title, $result)
Make a "what links here" link for a given title.
Definition: WantedQueryPage.php:113
WantedQueryPage\sortDescending
sortDescending()
Do not order descending for all order fields.
Definition: WantedQueryPage.php:138
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:922
Title
Represents a title within MediaWiki.
Definition: Title.php:42
SpecialPage\$linkRenderer
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:67
WantedQueryPage
Class definition for a wanted query page like WantedPages, WantedTemplates, etc.
Definition: WantedQueryPage.php:32