MediaWiki  master
WantedQueryPage.php
Go to the documentation of this file.
1 <?php
27 
34 abstract class WantedQueryPage extends QueryPage {
35  public function isExpensive() {
36  return true;
37  }
38 
39  public function isSyndicated() {
40  return false;
41  }
42 
49  protected function preprocessResults( $db, $res ) {
51  }
52 
62  protected function forceExistenceCheck() {
63  return false;
64  }
65 
75  public function formatResult( $skin, $result ) {
76  $linkRenderer = $this->getLinkRenderer();
77  $title = Title::makeTitleSafe( $result->namespace, $result->title );
78  if ( $title instanceof Title ) {
79  if ( $this->isCached() || $this->forceExistenceCheck() ) {
80  $pageLink = $this->existenceCheck( $title )
81  ? '<del>' . $linkRenderer->makeLink( $title ) . '</del>'
82  : $linkRenderer->makeLink( $title );
83  } else {
84  $pageLink = $linkRenderer->makeBrokenLink( $title );
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 
110  protected function existenceCheck( Title $title ) {
111  return $title->isKnown();
112  }
113 
121  protected function makeWlhLink( $title, $result ) {
122  $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
123  $label = $this->msg( 'nlinks' )->numParams( $result->value )->text();
124  return $this->getLinkRenderer()->makeLink( $wlh, $label );
125  }
126 
134  protected function getOrderFields() {
135  return [ 'value DESC', 'namespace', 'title' ];
136  }
137 
148  protected function sortDescending() {
149  return false;
150  }
151 
158  protected function getCacheOrderFields() {
159  return $this->getOrderFields();
160  }
161 
162 }
Represents a title within MediaWiki.
Definition: Title.php:82
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:65
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:925
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
Definition: QueryPage.php:337
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.
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:36
Result wrapper for grabbing data queried from an IDatabase object.