MediaWiki master
SpecialFewestRevisions.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Specials;
22
23use HtmlArmor;
32use Skin;
33use stdClass;
37
45
46 private NamespaceInfo $namespaceInfo;
47 private ILanguageConverter $languageConverter;
48
55 public function __construct(
56 NamespaceInfo $namespaceInfo,
57 IConnectionProvider $dbProvider,
58 LinkBatchFactory $linkBatchFactory,
59 LanguageConverterFactory $languageConverterFactory
60 ) {
61 parent::__construct( 'Fewestrevisions' );
62 $this->namespaceInfo = $namespaceInfo;
63 $this->setDatabaseProvider( $dbProvider );
64 $this->setLinkBatchFactory( $linkBatchFactory );
65 $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
66 }
67
68 public function isExpensive() {
69 return true;
70 }
71
72 public function isSyndicated() {
73 return false;
74 }
75
76 public function getQueryInfo() {
77 return [
78 'tables' => [ 'revision', 'page' ],
79 'fields' => [
80 'namespace' => 'page_namespace',
81 'title' => 'page_title',
82 'value' => 'COUNT(*)',
83 ],
84 'conds' => [
85 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
86 'page_id = rev_page',
87 'page_is_redirect' => 0,
88 ],
89 'options' => [
90 'GROUP BY' => [ 'page_namespace', 'page_title' ]
91 ]
92 ];
93 }
94
95 protected function sortDescending() {
96 return false;
97 }
98
104 public function formatResult( $skin, $result ) {
105 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
106 if ( !$nt ) {
107 return Html::element(
108 'span',
109 [ 'class' => 'mw-invalidtitle' ],
110 Linker::getInvalidTitleDescription(
111 $this->getContext(),
112 $result->namespace,
113 $result->title
114 )
115 );
116 }
117 $linkRenderer = $this->getLinkRenderer();
118
119 $text = $this->languageConverter->convertHtml( $nt->getPrefixedText() );
120 $plink = $linkRenderer->makeLink( $nt, new HtmlArmor( $text ) );
121
122 $nl = $this->msg( 'nrevisions' )->numParams( $result->value )->text();
123 $redirect = isset( $result->redirect ) && $result->redirect ?
124 ' - ' . $this->msg( 'isredirect' )->escaped() : '';
125 $nlink = $linkRenderer->makeKnownLink(
126 $nt,
127 $nl,
128 [],
129 [ 'action' => 'history' ]
130 ) . $redirect;
131
132 return $this->getLanguage()->specialList( $plink, $nlink );
133 }
134
141 protected function preprocessResults( $db, $res ) {
142 $this->executeLBFromResultWrapper( $res );
143 }
144
145 protected function getGroupName() {
146 return 'maintenance';
147 }
148}
149
151class_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:63
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:87
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.
List 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:64
The shared interface for all language converters.
Provide primary and replica IDatabase connections.
Interface to a relational database.
Definition IDatabase.php:48
Result wrapper for grabbing data queried from an IDatabase object.
element(SerializerNode $parent, SerializerNode $node, $contents)