MediaWiki REL1_39
SpecialAllMessages.php
Go to the documentation of this file.
1<?php
28
36
38 private $languageFactory;
39
41 private $languageNameUtils;
42
44 private $loadBalancer;
45
47 private $localisationCache;
48
55 public function __construct(
56 LanguageFactory $languageFactory,
57 LanguageNameUtils $languageNameUtils,
58 LocalisationCache $localisationCache,
59 ILoadBalancer $loadBalancer
60 ) {
61 parent::__construct( 'Allmessages' );
62 $this->languageFactory = $languageFactory;
63 $this->languageNameUtils = $languageNameUtils;
64 $this->localisationCache = $localisationCache;
65 $this->loadBalancer = $loadBalancer;
66 }
67
71 public function execute( $par ) {
72 $out = $this->getOutput();
73
74 $this->setHeaders();
75
76 if ( !$this->getConfig()->get( MainConfigNames::UseDatabaseMessages ) ) {
77 $out->addWikiMsg( 'allmessages-not-supported-database' );
78
79 return;
80 }
81
82 $out->addModuleStyles( 'mediawiki.special' );
83 $this->addHelpLink( 'Help:System message' );
84
85 $contLangCode = $this->getContentLanguage()->getCode();
86 $lang = $this->getLanguage();
87
88 $opts = new FormOptions();
89
90 $opts->add( 'prefix', '' );
91 $opts->add( 'filter', 'all' );
92 $opts->add( 'lang', $contLangCode );
93 $opts->add( 'limit', 50 );
94
95 $opts->fetchValuesFromRequest( $this->getRequest() );
96 $opts->validateIntBounds( 'limit', 0, 5000 );
97
98 $pager = new AllMessagesTablePager(
99 $this->getContext(),
100 $this->getContentLanguage(),
101 $this->languageFactory,
102 $this->languageNameUtils,
103 $this->getLinkRenderer(),
104 $this->loadBalancer,
105 $this->localisationCache,
106 $opts
107 );
108
109 $formDescriptor = [
110 'prefix' => [
111 'type' => 'text',
112 'name' => 'prefix',
113 'label-message' => 'allmessages-prefix',
114 ],
115
116 'filter' => [
117 'type' => 'radio',
118 'name' => 'filter',
119 'label-message' => 'allmessages-filter',
120 'options-messages' => [
121 'allmessages-filter-unmodified' => 'unmodified',
122 'allmessages-filter-all' => 'all',
123 'allmessages-filter-modified' => 'modified',
124 ],
125 'default' => 'all',
126 'flatlist' => true,
127 ],
128
129 'lang' => [
130 'type' => 'language',
131 'name' => 'lang',
132 'label-message' => 'allmessages-language',
133 'default' => $opts->getValue( 'lang' ),
134 ],
135
136 'limit' => [
137 'type' => 'limitselect',
138 'name' => 'limit',
139 'label-message' => 'table_pager_limit_label',
140 'options' => [
141 $lang->formatNum( 20 ) => 20,
142 $lang->formatNum( 50 ) => 50,
143 $lang->formatNum( 100 ) => 100,
144 $lang->formatNum( 250 ) => 250,
145 $lang->formatNum( 500 ) => 500,
146 $lang->formatNum( 5000 ) => 5000,
147 ],
148 'default' => $opts->getValue( 'limit' ),
149 ],
150 ];
151
152 $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
153 $htmlForm
154 ->setMethod( 'get' )
155 ->setIntro( $this->msg( 'allmessagestext' ) )
156 ->setWrapperLegendMsg( 'allmessages' )
157 ->setSubmitTextMsg( 'allmessages-filter-submit' )
158 ->prepareForm()
159 ->displayForm( false );
160
161 $out->addParserOutputContent( $pager->getFullOutput() );
162 }
163
164 protected function getGroupName() {
165 return 'wiki';
166 }
167}
Use TablePager for prettified output.
Helper class to keep track of options when mixing links and form elements.
Caching for the contents of localisation files.
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.
Create and track the database connections and transactions for a given database cluster.
if(!isset( $args[0])) $lang