MediaWiki 1.40.4
SpecialAllMessages.php
Go to the documentation of this file.
1<?php
29
37
39 private $languageFactory;
40
42 private $languageNameUtils;
43
45 private $loadBalancer;
46
48 private $localisationCache;
49
56 public function __construct(
57 LanguageFactory $languageFactory,
58 LanguageNameUtils $languageNameUtils,
59 LocalisationCache $localisationCache,
60 ILoadBalancer $loadBalancer
61 ) {
62 parent::__construct( 'Allmessages' );
63 $this->languageFactory = $languageFactory;
64 $this->languageNameUtils = $languageNameUtils;
65 $this->localisationCache = $localisationCache;
66 $this->loadBalancer = $loadBalancer;
67 }
68
72 public function execute( $par ) {
73 $out = $this->getOutput();
74
75 $this->setHeaders();
76
77 if ( !$this->getConfig()->get( MainConfigNames::UseDatabaseMessages ) ) {
78 $out->addWikiMsg( 'allmessages-not-supported-database' );
79
80 return;
81 }
82
83 $out->addModuleStyles( 'mediawiki.special' );
84 $this->addHelpLink( 'Help:System message' );
85
86 $contLangCode = $this->getContentLanguage()->getCode();
87 $lang = $this->getLanguage();
88
89 $opts = new FormOptions();
90
91 $opts->add( 'prefix', '' );
92 $opts->add( 'filter', 'all' );
93 $opts->add( 'lang', $contLangCode );
94 $opts->add( 'limit', 50 );
95
96 $opts->fetchValuesFromRequest( $this->getRequest() );
97 $opts->validateIntBounds( 'limit', 0, 5000 );
98
99 $pager = new AllMessagesTablePager(
100 $this->getContext(),
101 $this->getContentLanguage(),
102 $this->languageFactory,
103 $this->languageNameUtils,
104 $this->getLinkRenderer(),
105 $this->loadBalancer,
106 $this->localisationCache,
107 $opts
108 );
109
110 $formDescriptor = [
111 'prefix' => [
112 'type' => 'text',
113 'name' => 'prefix',
114 'label-message' => 'allmessages-prefix',
115 ],
116
117 'filter' => [
118 'type' => 'radio',
119 'name' => 'filter',
120 'label-message' => 'allmessages-filter',
121 'options-messages' => [
122 'allmessages-filter-unmodified' => 'unmodified',
123 'allmessages-filter-all' => 'all',
124 'allmessages-filter-modified' => 'modified',
125 ],
126 'default' => 'all',
127 'flatlist' => true,
128 ],
129
130 'lang' => [
131 'type' => 'language',
132 'name' => 'lang',
133 'label-message' => 'allmessages-language',
134 'default' => $opts->getValue( 'lang' ),
135 ],
136
137 'limit' => [
138 'type' => 'limitselect',
139 'name' => 'limit',
140 'label-message' => 'table_pager_limit_label',
141 'options' => [
142 $lang->formatNum( 20 ) => 20,
143 $lang->formatNum( 50 ) => 50,
144 $lang->formatNum( 100 ) => 100,
145 $lang->formatNum( 250 ) => 250,
146 $lang->formatNum( 500 ) => 500,
147 $lang->formatNum( 5000 ) => 5000,
148 ],
149 'default' => $opts->getValue( 'limit' ),
150 ],
151 ];
152
153 $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
154 $htmlForm
155 ->setMethod( 'get' )
156 ->setPreHtml( $this->msg( 'allmessagestext' )->parse() )
157 ->setWrapperLegendMsg( 'allmessages' )
158 ->setSubmitTextMsg( 'allmessages-filter-submit' )
159 ->prepareForm()
160 ->displayForm( false );
161
162 $out->addParserOutputContent( $pager->getFullOutput() );
163 }
164
165 protected function getGroupName() {
166 return 'wiki';
167 }
168}
Use TablePager for prettified output.
Caching for the contents of localisation files.
Helper class to keep track of options when mixing links and form elements.
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
A service that provides utilities to do with language names and codes.
A class containing constants representing the names of configuration variables.
__construct(LanguageFactory $languageFactory, LanguageNameUtils $languageNameUtils, LocalisationCache $localisationCache, ILoadBalancer $loadBalancer)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Parent class for all special pages.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
getLanguage()
Shortcut to get user's language.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
getContentLanguage()
Shortcut to get content language.
This class is a delegate to ILBFactory for a given database cluster.
if(!isset( $args[0])) $lang