MediaWiki  master
SpecialMostLinkedTemplates.php
Go to the documentation of this file.
1 <?php
27 
35  public function __construct( $name = 'Mostlinkedtemplates' ) {
36  parent::__construct( $name );
37  }
38 
44  public function isExpensive() {
45  return true;
46  }
47 
53  public function isSyndicated() {
54  return false;
55  }
56 
62  public function sortDescending() {
63  return true;
64  }
65 
66  public function getQueryInfo() {
67  return [
68  'tables' => [ 'templatelinks' ],
69  'fields' => [
70  'namespace' => 'tl_namespace',
71  'title' => 'tl_title',
72  'value' => 'COUNT(*)'
73  ],
74  'options' => [ 'GROUP BY' => [ 'tl_namespace', 'tl_title' ] ]
75  ];
76  }
77 
84  public function preprocessResults( $db, $res ) {
86  }
87 
95  public function formatResult( $skin, $result ) {
96  $title = Title::makeTitleSafe( $result->namespace, $result->title );
97  if ( !$title ) {
98  return Html::element(
99  'span',
100  [ 'class' => 'mw-invalidtitle' ],
102  $this->getContext(),
103  $result->namespace,
104  $result->title
105  )
106  );
107  }
108 
109  return $this->getLanguage()->specialList(
110  $this->getLinkRenderer()->makeLink( $title ),
111  $this->makeWlhLink( $title, $result )
112  );
113  }
114 
122  private function makeWlhLink( $title, $result ) {
123  $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
124  $label = $this->msg( 'ntransclusions' )->numParams( $result->value )->text();
125 
126  return $this->getLinkRenderer()->makeLink( $wlh, $label );
127  }
128 
129  protected function getGroupName() {
130  return 'highuse';
131  }
132 }
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:800
SpecialMostLinkedTemplates\preprocessResults
preprocessResults( $db, $res)
Pre-cache page existence to speed up link generation.
Definition: SpecialMostLinkedTemplates.php:84
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:90
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:746
Linker\getInvalidTitleDescription
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition: Linker.php:188
$res
$res
Definition: testCompression.php:57
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:798
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
SpecialMostLinkedTemplates\isExpensive
isExpensive()
Is this report expensive, i.e should it be cached?
Definition: SpecialMostLinkedTemplates.php:44
SpecialMostLinkedTemplates\makeWlhLink
makeWlhLink( $title, $result)
Make a "what links here" link for a given title.
Definition: SpecialMostLinkedTemplates.php:122
SpecialMostLinkedTemplates\formatResult
formatResult( $skin, $result)
Format a result row.
Definition: SpecialMostLinkedTemplates.php:95
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
SpecialMostLinkedTemplates\sortDescending
sortDescending()
Sort the results in descending order?
Definition: SpecialMostLinkedTemplates.php:62
SpecialMostLinkedTemplates\__construct
__construct( $name='Mostlinkedtemplates')
Definition: SpecialMostLinkedTemplates.php:35
$title
$title
Definition: testCompression.php:38
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:689
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:618
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:912
SpecialMostLinkedTemplates
Special page lists templates with a large number of transclusion links, i.e.
Definition: SpecialMostLinkedTemplates.php:34
SpecialMostLinkedTemplates\isSyndicated
isSyndicated()
Is there a feed available?
Definition: SpecialMostLinkedTemplates.php:53
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
SpecialMostLinkedTemplates\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialMostLinkedTemplates.php:129
SpecialMostLinkedTemplates\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialMostLinkedTemplates.php:66