MediaWiki  master
SpecialMostLinkedTemplates.php
Go to the documentation of this file.
1 <?php
27 
35  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 }
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
getContext()
Gets the context this SpecialPage is executed in.
formatResult( $skin, $result)
Format a result row.
Special page lists templates with a large number of transclusion links, i.e.
isExpensive()
Is this report expensive, i.e should it be cached?
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
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
makeWlhLink( $title, $result)
Make a "what links here" link for a given title.
isSyndicated()
Is there a feed available?
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
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:612
preprocessResults( $db, $res)
Pre-cache page existence to speed up link generation.
getLanguage()
Shortcut to get user&#39;s language.
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition: Linker.php:187
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
sortDescending()
Sort the results in descending order?
__construct( $name='Mostlinkedtemplates')