MediaWiki master
SpecialFewestRevisions.php
Go to the documentation of this file.
1<?php
24namespace MediaWiki\Specials;
25
26use HtmlArmor;
35use Skin;
36use stdClass;
40
48
49 private NamespaceInfo $namespaceInfo;
50 private ILanguageConverter $languageConverter;
51
58 public function __construct(
59 NamespaceInfo $namespaceInfo,
60 IConnectionProvider $dbProvider,
61 LinkBatchFactory $linkBatchFactory,
62 LanguageConverterFactory $languageConverterFactory
63 ) {
64 parent::__construct( 'Fewestrevisions' );
65 $this->namespaceInfo = $namespaceInfo;
66 $this->setDatabaseProvider( $dbProvider );
67 $this->setLinkBatchFactory( $linkBatchFactory );
68 $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
69 }
70
71 public function isExpensive() {
72 return true;
73 }
74
75 public function isSyndicated() {
76 return false;
77 }
78
79 public function getQueryInfo() {
80 return [
81 'tables' => [ 'revision', 'page' ],
82 'fields' => [
83 'namespace' => 'page_namespace',
84 'title' => 'page_title',
85 'value' => 'COUNT(*)',
86 ],
87 'conds' => [
88 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
89 'page_id = rev_page',
90 'page_is_redirect = 0',
91 ],
92 'options' => [
93 'GROUP BY' => [ 'page_namespace', 'page_title' ]
94 ]
95 ];
96 }
97
98 protected function sortDescending() {
99 return false;
100 }
101
107 public function formatResult( $skin, $result ) {
108 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
109 if ( !$nt ) {
110 return Html::element(
111 'span',
112 [ 'class' => 'mw-invalidtitle' ],
113 Linker::getInvalidTitleDescription(
114 $this->getContext(),
115 $result->namespace,
116 $result->title
117 )
118 );
119 }
120 $linkRenderer = $this->getLinkRenderer();
121
122 $text = $this->languageConverter->convertHtml( $nt->getPrefixedText() );
123 $plink = $linkRenderer->makeLink( $nt, new HtmlArmor( $text ) );
124
125 $nl = $this->msg( 'nrevisions' )->numParams( $result->value )->text();
126 $redirect = isset( $result->redirect ) && $result->redirect ?
127 ' - ' . $this->msg( 'isredirect' )->escaped() : '';
128 $nlink = $linkRenderer->makeKnownLink(
129 $nt,
130 $nl,
131 [],
132 [ 'action' => 'history' ]
133 ) . $redirect;
134
135 return $this->getLanguage()->specialList( $plink, $nlink );
136 }
137
144 protected function preprocessResults( $db, $res ) {
145 $this->executeLBFromResultWrapper( $res );
146 }
147
148 protected function getGroupName() {
149 return 'maintenance';
150 }
151}
152
154class_alias( SpecialFewestRevisions::class, 'SpecialFewestRevisions' );
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:30
This class is a collection of static functions that serve two purposes:
Definition Html.php:56
An interface for creating language converters.
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
Some internal bits split of from Skin.php.
Definition Linker.php:65
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:89
setDatabaseProvider(IConnectionProvider $databaseProvider)
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getContentLanguage()
Shortcut to get content language.
getLanguage()
Shortcut to get user's language.
Special page for listing the articles with the fewest revisions.
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.
preprocessResults( $db, $res)
Cache page existence for performance.
__construct(NamespaceInfo $namespaceInfo, IConnectionProvider $dbProvider, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
sortDescending()
Override to sort by increasing values.
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?
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Represents a title within MediaWiki.
Definition Title.php:78
The base class for all skins.
Definition Skin.php:58
The shared interface for all language converters.
Provide primary and replica IDatabase connections.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:36
Result wrapper for grabbing data queried from an IDatabase object.
element(SerializerNode $parent, SerializerNode $node, $contents)
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...