MediaWiki REL1_40
SpecialMostLinked.php
Go to the documentation of this file.
1<?php
35
42
47 public function __construct(
48 ILoadBalancer $loadBalancer,
49 LinkBatchFactory $linkBatchFactory
50 ) {
51 parent::__construct( 'Mostlinked' );
52 $this->setDBLoadBalancer( $loadBalancer );
53 $this->setLinkBatchFactory( $linkBatchFactory );
54 }
55
56 public function isExpensive() {
57 return true;
58 }
59
60 public function isSyndicated() {
61 return false;
62 }
63
64 public function getQueryInfo() {
65 return [
66 'tables' => [ 'pagelinks', 'page' ],
67 'fields' => [
68 'namespace' => 'pl_namespace',
69 'title' => 'pl_title',
70 'value' => 'COUNT(*)',
71 'page_namespace'
72 ],
73 'options' => [
74 'HAVING' => 'COUNT(*) > 1',
75 'GROUP BY' => [
76 'pl_namespace', 'pl_title',
77 'page_namespace'
78 ]
79 ],
80 'join_conds' => [
81 'page' => [
82 'LEFT JOIN',
83 [
84 'page_namespace = pl_namespace',
85 'page_title = pl_title'
86 ]
87 ]
88 ]
89 ];
90 }
91
98 public function preprocessResults( $db, $res ) {
100 }
101
109 private function makeWlhLink( $title, $caption ) {
110 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedDBkey() );
111
112 $linkRenderer = $this->getLinkRenderer();
113 return $linkRenderer->makeKnownLink( $wlh, $caption );
114 }
115
124 public function formatResult( $skin, $result ) {
125 $title = Title::makeTitleSafe( $result->namespace, $result->title );
126 if ( !$title ) {
127 return Html::element(
128 'span',
129 [ 'class' => 'mw-invalidtitle' ],
130 Linker::getInvalidTitleDescription(
131 $this->getContext(),
132 $result->namespace,
133 $result->title )
134 );
135 }
136
137 $linkRenderer = $this->getLinkRenderer();
138 $link = $linkRenderer->makeLink( $title );
139 $wlh = $this->makeWlhLink(
140 $title,
141 $this->msg( 'nlinks' )->numParams( $result->value )->text()
142 );
143
144 return $this->getLanguage()->specialList( $link, $wlh );
145 }
146
147 protected function getGroupName() {
148 return 'highuse';
149 }
150}
This class is a collection of static functions that serve two purposes:
Definition Html.php:55
Some internal bits split of from Skin.php.
Definition Linker.php:67
Represents a title within MediaWiki.
Definition Title.php:82
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:45
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:36
This class is a delegate to ILBFactory for a given database cluster.
Result wrapper for grabbing data queried from an IDatabase object.