MediaWiki  master
SpecialMostLinked.php
Go to the documentation of this file.
1 <?php
30 
37  function __construct( $name = 'Mostlinked' ) {
38  parent::__construct( $name );
39  }
40 
41  public function isExpensive() {
42  return true;
43  }
44 
45  function isSyndicated() {
46  return false;
47  }
48 
49  public function getQueryInfo() {
50  return [
51  'tables' => [ 'pagelinks', 'page' ],
52  'fields' => [
53  'namespace' => 'pl_namespace',
54  'title' => 'pl_title',
55  'value' => 'COUNT(*)',
56  'page_namespace'
57  ],
58  'options' => [
59  'HAVING' => 'COUNT(*) > 1',
60  'GROUP BY' => [
61  'pl_namespace', 'pl_title',
62  'page_namespace'
63  ]
64  ],
65  'join_conds' => [
66  'page' => [
67  'LEFT JOIN',
68  [
69  'page_namespace = pl_namespace',
70  'page_title = pl_title'
71  ]
72  ]
73  ]
74  ];
75  }
76 
83  function preprocessResults( $db, $res ) {
85  }
86 
94  function makeWlhLink( $title, $caption ) {
95  $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedDBkey() );
96 
97  $linkRenderer = $this->getLinkRenderer();
98  return $linkRenderer->makeKnownLink( $wlh, $caption );
99  }
100 
109  function formatResult( $skin, $result ) {
110  $title = Title::makeTitleSafe( $result->namespace, $result->title );
111  if ( !$title ) {
112  return Html::element(
113  'span',
114  [ 'class' => 'mw-invalidtitle' ],
116  $this->getContext(),
117  $result->namespace,
118  $result->title )
119  );
120  }
121 
122  $linkRenderer = $this->getLinkRenderer();
123  $link = $linkRenderer->makeLink( $title );
124  $wlh = $this->makeWlhLink(
125  $title,
126  $this->msg( 'nlinks' )->numParams( $result->value )->text()
127  );
128 
129  return $this->getLanguage()->specialList( $link, $wlh );
130  }
131 
132  protected function getGroupName() {
133  return 'highuse';
134  }
135 }
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.
A special page to show pages ordered by the number of pages linking to them.
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
makeWlhLink( $title, $caption)
Make a link to "what links here" for the specified title.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
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
preprocessResults( $db, $res)
Pre-fill the link cache.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:612
formatResult( $skin, $result)
Make links to the page corresponding to the item, and the "what links here" page for it...
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
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:67
__construct( $name='Mostlinked')