MediaWiki 1.40.4
SpecialFewestRevisions.php
Go to the documentation of this file.
1<?php
32
40
42 private $namespaceInfo;
43
45 private $languageConverter;
46
53 public function __construct(
54 NamespaceInfo $namespaceInfo,
55 ILoadBalancer $loadBalancer,
56 LinkBatchFactory $linkBatchFactory,
57 LanguageConverterFactory $languageConverterFactory
58 ) {
59 parent::__construct( 'Fewestrevisions' );
60 $this->namespaceInfo = $namespaceInfo;
61 $this->setDBLoadBalancer( $loadBalancer );
62 $this->setLinkBatchFactory( $linkBatchFactory );
63 $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
64 }
65
66 public function isExpensive() {
67 return true;
68 }
69
70 public function isSyndicated() {
71 return false;
72 }
73
74 public function getQueryInfo() {
75 return [
76 'tables' => [ 'revision', 'page' ],
77 'fields' => [
78 'namespace' => 'page_namespace',
79 'title' => 'page_title',
80 'value' => 'COUNT(*)',
81 ],
82 'conds' => [
83 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
84 'page_id = rev_page',
85 'page_is_redirect = 0',
86 ],
87 'options' => [
88 'GROUP BY' => [ 'page_namespace', 'page_title' ]
89 ]
90 ];
91 }
92
93 protected function sortDescending() {
94 return false;
95 }
96
102 public function formatResult( $skin, $result ) {
103 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
104 if ( !$nt ) {
105 return Html::element(
106 'span',
107 [ 'class' => 'mw-invalidtitle' ],
108 Linker::getInvalidTitleDescription(
109 $this->getContext(),
110 $result->namespace,
111 $result->title
112 )
113 );
114 }
115 $linkRenderer = $this->getLinkRenderer();
116
117 $text = $this->languageConverter->convertHtml( $nt->getPrefixedText() );
118 $plink = $linkRenderer->makeLink( $nt, new HtmlArmor( $text ) );
119
120 $nl = $this->msg( 'nrevisions' )->numParams( $result->value )->text();
121 $redirect = isset( $result->redirect ) && $result->redirect ?
122 ' - ' . $this->msg( 'isredirect' )->escaped() : '';
123 $nlink = $linkRenderer->makeKnownLink(
124 $nt,
125 $nl,
126 [],
127 [ 'action' => 'history' ]
128 ) . $redirect;
129
130 return $this->getLanguage()->specialList( $plink, $nlink );
131 }
132
139 protected function preprocessResults( $db, $res ) {
141 }
142
143 protected function getGroupName() {
144 return 'maintenance';
145 }
146}
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:55
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:67
Represents a title within MediaWiki.
Definition Title.php:82
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
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)
Special page for listing the articles with the fewest revisions.
sortDescending()
Override to sort by increasing values.
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
__construct(NamespaceInfo $namespaceInfo, ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
isExpensive()
Should this query page only be updated offline on large wikis?
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
preprocessResults( $db, $res)
Cache page existence for performance.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
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.
getContentLanguage()
Shortcut to get content language.
The shared interface for all language converters.
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.