MediaWiki REL1_34
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
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
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 getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition Linker.php:187
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
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
A special page to show pages ordered by the number of pages linking to them.
preprocessResults( $db, $res)
Pre-fill the link cache.
formatResult( $skin, $result)
Make links to the page corresponding to the item, and the "what links here" page for it.
makeWlhLink( $title, $caption)
Make a link to "what links here" for the specified title.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
__construct( $name='Mostlinked')
isSyndicated()
Sometime we don't want to build rss / atom feeds.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
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,...
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getLanguage()
Shortcut to get user's language.
MediaWiki Linker LinkRenderer null $linkRenderer
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38
Result wrapper for grabbing data queried from an IDatabase object.