MediaWiki  1.34.0
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->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  protected 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 
153  function getCacheOrderFields() {
154  return $this->getOrderFields();
155  }
156 
157 }
WantedQueryPage\existenceCheck
existenceCheck(Title $title)
Does the Title currently exists.
Definition: WantedQueryPage.php:108
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:792
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:749
WantedQueryPage\getOrderFields
getOrderFields()
Order by title for pages with the same number of links to them.
Definition: WantedQueryPage.php:131
$res
$res
Definition: testCompression.php:52
WantedQueryPage\getCacheOrderFields
getCacheOrderFields()
Also use the order fields returned by getOrderFields when fetching from the cache.
Definition: WantedQueryPage.php:153
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:800
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:34
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:613
WantedQueryPage\makeWlhLink
makeWlhLink( $title, $result)
Make a "what links here" link for a given title.
Definition: WantedQueryPage.php:119
WantedQueryPage\sortDescending
sortDescending()
Do not order descending for all order fields.
Definition: WantedQueryPage.php:144
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:904
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