MediaWiki  master
WantedQueryPage.php
Go to the documentation of this file.
1 <?php
26 
33 abstract class WantedQueryPage extends QueryPage {
34  public function isExpensive() {
35  return true;
36  }
37 
38  public function isSyndicated() {
39  return false;
40  }
41 
48  protected function preprocessResults( $db, $res ) {
50  }
51 
61  protected function forceExistenceCheck() {
62  return false;
63  }
64 
74  public function formatResult( $skin, $result ) {
75  $linkRenderer = $this->getLinkRenderer();
76  $title = Title::makeTitleSafe( $result->namespace, $result->title );
77  if ( $title instanceof Title ) {
78  if ( $this->isCached() || $this->forceExistenceCheck() ) {
79  $pageLink = $this->existenceCheck( $title )
80  ? '<del>' . $linkRenderer->makeLink( $title ) . '</del>'
81  : $linkRenderer->makeLink( $title );
82  } else {
83  $pageLink = $linkRenderer->makeBrokenLink( $title );
84  }
85  return $this->getLanguage()->specialList( $pageLink, $this->makeWlhLink( $title, $result ) );
86  } else {
87  return $this->msg( 'wantedpages-badtitle', $result->title )->escaped();
88  }
89  }
90 
109  protected function existenceCheck( Title $title ) {
110  return $title->isKnown();
111  }
112 
120  protected function makeWlhLink( $title, $result ) {
121  $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
122  $label = $this->msg( 'nlinks' )->numParams( $result->value )->text();
123  return $this->getLinkRenderer()->makeLink( $wlh, $label );
124  }
125 
133  protected function getOrderFields() {
134  return [ 'value DESC', 'namespace', 'title' ];
135  }
136 
147  protected function sortDescending() {
148  return false;
149  }
150 
157  protected function getCacheOrderFields() {
158  return $this->getOrderFields();
159  }
160 
161 }
WantedQueryPage\existenceCheck
existenceCheck(Title $title)
Does the Title currently exists.
Definition: WantedQueryPage.php:109
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:828
WantedQueryPage\forceExistenceCheck
forceExistenceCheck()
Should formatResult() always check page existence, even if the results are fresh? This is a (hopefull...
Definition: WantedQueryPage.php:61
WantedQueryPage\preprocessResults
preprocessResults( $db, $res)
Cache page existence for performance Stable to override.
Definition: WantedQueryPage.php:48
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:92
WantedQueryPage\formatResult
formatResult( $skin, $result)
Format an individual result.
Definition: WantedQueryPage.php:74
WantedQueryPage\isSyndicated
isSyndicated()
Sometime we don't want to build rss / atom feeds.
Definition: WantedQueryPage.php:38
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:34
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:774
WantedQueryPage\getOrderFields
getOrderFields()
Order by title for pages with the same number of links to them.
Definition: WantedQueryPage.php:133
$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:157
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:39
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:823
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:268
$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:618
WantedQueryPage\makeWlhLink
makeWlhLink( $title, $result)
Make a "what links here" link for a given title.
Definition: WantedQueryPage.php:120
WantedQueryPage\sortDescending
sortDescending()
Do not order descending for all order fields.
Definition: WantedQueryPage.php:147
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:944
Title
Represents a title within MediaWiki.
Definition: Title.php:42
SpecialPage\$linkRenderer
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:71
WantedQueryPage
Class definition for a wanted query page like WantedPages, WantedTemplates, etc Stable to extend.
Definition: WantedQueryPage.php:33