MediaWiki REL1_39
SpecialMostLinked.php
Go to the documentation of this file.
1<?php
32
39
44 public function __construct(
45 ILoadBalancer $loadBalancer,
46 LinkBatchFactory $linkBatchFactory
47 ) {
48 parent::__construct( 'Mostlinked' );
49 $this->setDBLoadBalancer( $loadBalancer );
50 $this->setLinkBatchFactory( $linkBatchFactory );
51 }
52
53 public function isExpensive() {
54 return true;
55 }
56
57 public function isSyndicated() {
58 return false;
59 }
60
61 public function getQueryInfo() {
62 return [
63 'tables' => [ 'pagelinks', 'page' ],
64 'fields' => [
65 'namespace' => 'pl_namespace',
66 'title' => 'pl_title',
67 'value' => 'COUNT(*)',
68 'page_namespace'
69 ],
70 'options' => [
71 'HAVING' => 'COUNT(*) > 1',
72 'GROUP BY' => [
73 'pl_namespace', 'pl_title',
74 'page_namespace'
75 ]
76 ],
77 'join_conds' => [
78 'page' => [
79 'LEFT JOIN',
80 [
81 'page_namespace = pl_namespace',
82 'page_title = pl_title'
83 ]
84 ]
85 ]
86 ];
87 }
88
95 public function preprocessResults( $db, $res ) {
97 }
98
106 private function makeWlhLink( $title, $caption ) {
107 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedDBkey() );
108
109 $linkRenderer = $this->getLinkRenderer();
110 return $linkRenderer->makeKnownLink( $wlh, $caption );
111 }
112
121 public function formatResult( $skin, $result ) {
122 $title = Title::makeTitleSafe( $result->namespace, $result->title );
123 if ( !$title ) {
124 return Html::element(
125 'span',
126 [ 'class' => 'mw-invalidtitle' ],
128 $this->getContext(),
129 $result->namespace,
130 $result->title )
131 );
132 }
133
134 $linkRenderer = $this->getLinkRenderer();
135 $link = $linkRenderer->makeLink( $title );
136 $wlh = $this->makeWlhLink(
137 $title,
138 $this->msg( 'nlinks' )->numParams( $result->value )->text()
139 );
140
141 return $this->getLanguage()->specialList( $link, $wlh );
142 }
143
144 protected function getGroupName() {
145 return 'highuse';
146 }
147}
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition Linker.php:189
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:42
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
setDBLoadBalancer(ILoadBalancer $loadBalancer)
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
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.
__construct(ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
isSyndicated()
Sometimes 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()
Should this query page only be updated offline on large wikis?
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.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:39
Create and track the database connections and transactions for a given database cluster.
Result wrapper for grabbing data queried from an IDatabase object.