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