MediaWiki  1.34.0
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 }
SpecialMostLinked\preprocessResults
preprocessResults( $db, $res)
Pre-fill the link cache.
Definition: SpecialMostLinked.php:83
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:792
SpecialMostLinked\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialMostLinked.php:49
SpecialPage\getTitleFor
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,...
Definition: SpecialPage.php:83
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:749
Linker\getInvalidTitleDescription
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition: Linker.php:187
$res
$res
Definition: testCompression.php:52
QueryPage
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
QueryPage\executeLBFromResultWrapper
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
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
SpecialMostLinked\formatResult
formatResult( $skin, $result)
Make links to the page corresponding to the item, and the "what links here" page for it.
Definition: SpecialMostLinked.php:109
$title
$title
Definition: testCompression.php:34
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:692
SpecialMostLinked
A special page to show pages ordered by the number of pages linking to them.
Definition: SpecialMostLinked.php:36
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:613
SpecialMostLinked\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialMostLinked.php:132
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:904
SpecialMostLinked\isSyndicated
isSyndicated()
Sometime we don't want to build rss / atom feeds.
Definition: SpecialMostLinked.php:45
SpecialMostLinked\isExpensive
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
Definition: SpecialMostLinked.php:41
SpecialMostLinked\__construct
__construct( $name='Mostlinked')
Definition: SpecialMostLinked.php:37
SpecialPage\$linkRenderer
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:67
SpecialMostLinked\makeWlhLink
makeWlhLink( $title, $caption)
Make a link to "what links here" for the specified title.
Definition: SpecialMostLinked.php:94