MediaWiki  master
WantedQueryPage.php
Go to the documentation of this file.
1 <?php
26 
32 abstract 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 
58  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  function getOrderFields() {
126  return [ 'value DESC', 'namespace', 'title' ];
127  }
128 
138  function sortDescending() {
139  return false;
140  }
141 
147  function getCacheOrderFields() {
148  return $this->getOrderFields();
149  }
150 
151 }
Class definition for a wanted query page like WantedPages, WantedTemplates, etc.
preprocessResults( $db, $res)
Cache page existence for performance.
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
Definition: QueryPage.php:258
getOrderFields()
Order by title for pages with the same number of links to them.
This is a class for doing query pages; since they&#39;re almost all the same, we factor out some of the f...
Definition: QueryPage.php:36
sortDescending()
Do not order descending for all order fields.
makeWlhLink( $title, $result)
Make a "what links here" link for a given title.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
forceExistenceCheck()
Should formatResult() always check page existence, even if the results are fresh? This is a (hopefull...
isKnown()
Does this title refer to a page that can (or might) be meaningfully viewed? In particular, this function may be used to determine if links to the title should be rendered as "bluelinks" (as opposed to "redlinks" to non-existent pages).
Definition: Title.php:4208
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don&#39;t need a full Title object...
Definition: SpecialPage.php:83
getCacheOrderFields()
Also use the order fields returned by getOrderFields when fetching from the cache.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:610
getLanguage()
Shortcut to get user&#39;s language.
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:800
formatResult( $skin, $result)
Format an individual result.
existenceCheck(Title $title)
Does the Title currently exists.
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:67