MediaWiki REL1_37
SpecialFewestRevisions.php
Go to the documentation of this file.
1<?php
29
37
40
43
50 public function __construct(
54 LanguageConverterFactory $languageConverterFactory
55 ) {
56 parent::__construct( 'Fewestrevisions' );
57 $this->namespaceInfo = $namespaceInfo;
58 $this->setDBLoadBalancer( $loadBalancer );
59 $this->setLinkBatchFactory( $linkBatchFactory );
60 $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
61 }
62
63 public function isExpensive() {
64 return true;
65 }
66
67 public function isSyndicated() {
68 return false;
69 }
70
71 public function getQueryInfo() {
72 return [
73 'tables' => [ 'revision', 'page' ],
74 'fields' => [
75 'namespace' => 'page_namespace',
76 'title' => 'page_title',
77 'value' => 'COUNT(*)',
78 ],
79 'conds' => [
80 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
81 'page_id = rev_page',
82 'page_is_redirect = 0',
83 ],
84 'options' => [
85 'GROUP BY' => [ 'page_namespace', 'page_title' ]
86 ]
87 ];
88 }
89
90 protected function sortDescending() {
91 return false;
92 }
93
99 public function formatResult( $skin, $result ) {
100 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
101 if ( !$nt ) {
102 return Html::element(
103 'span',
104 [ 'class' => 'mw-invalidtitle' ],
106 $this->getContext(),
107 $result->namespace,
108 $result->title
109 )
110 );
111 }
113
114 $text = $this->languageConverter->convertHtml( $nt->getPrefixedText() );
115 $plink = $linkRenderer->makeLink( $nt, new HtmlArmor( $text ) );
116
117 $nl = $this->msg( 'nrevisions' )->numParams( $result->value )->text();
118 $redirect = isset( $result->redirect ) && $result->redirect ?
119 ' - ' . $this->msg( 'isredirect' )->escaped() : '';
121 $nt,
122 $nl,
123 [],
124 [ 'action' => 'history' ]
125 ) . $redirect;
126
127 return $this->getLanguage()->specialList( $plink, $nlink );
128 }
129
136 protected function preprocessResults( $db, $res ) {
138 }
139
140 protected function getGroupName() {
141 return 'maintenance';
142 }
143}
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:30
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition Linker.php:185
An interface for creating language converters.
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
makeKnownLink( $target, $text=null, array $extraAttribs=[], array $query=[])
makeLink( $target, $text=null, array $extraAttribs=[], array $query=[])
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:41
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)
LinkBatchFactory null $linkBatchFactory
Definition QueryPage.php:74
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
ILoadBalancer null $loadBalancer
Definition QueryPage.php:71
Special page for listing the articles with the fewest revisions.
sortDescending()
Override to sort by increasing values.
isSyndicated()
Sometime we don't want to build rss / atom feeds.
ILanguageConverter $languageConverter
__construct(NamespaceInfo $namespaceInfo, ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
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.
LinkRenderer null $linkRenderer
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:38
Database cluster connection, tracking, load balancing, and transaction manager interface.
Result wrapper for grabbing data queried from an IDatabase object.