Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / specials / SpecialAllMessages.php
blob9645663b38e70aa7f2fdee69e531982411b32233
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
21 namespace MediaWiki\Specials;
23 use LocalisationCache;
24 use MediaWiki\Html\FormOptions;
25 use MediaWiki\Html\Html;
26 use MediaWiki\HTMLForm\HTMLForm;
27 use MediaWiki\Languages\LanguageFactory;
28 use MediaWiki\Languages\LanguageNameUtils;
29 use MediaWiki\MainConfigNames;
30 use MediaWiki\Pager\AllMessagesTablePager;
31 use MediaWiki\SpecialPage\SpecialPage;
32 use Wikimedia\Rdbms\IConnectionProvider;
34 /**
35 * List of the MediaWiki interface messages.
37 * @ingroup SpecialPage
39 class SpecialAllMessages extends SpecialPage {
41 private LanguageFactory $languageFactory;
42 private LanguageNameUtils $languageNameUtils;
43 private IConnectionProvider $dbProvider;
44 private LocalisationCache $localisationCache;
46 /**
47 * @param LanguageFactory $languageFactory
48 * @param LanguageNameUtils $languageNameUtils
49 * @param LocalisationCache $localisationCache
50 * @param IConnectionProvider $dbProvider
52 public function __construct(
53 LanguageFactory $languageFactory,
54 LanguageNameUtils $languageNameUtils,
55 LocalisationCache $localisationCache,
56 IConnectionProvider $dbProvider
57 ) {
58 parent::__construct( 'Allmessages' );
59 $this->languageFactory = $languageFactory;
60 $this->languageNameUtils = $languageNameUtils;
61 $this->localisationCache = $localisationCache;
62 $this->dbProvider = $dbProvider;
65 /**
66 * @param string|null $par Parameter passed to the page or null
68 public function execute( $par ) {
69 $out = $this->getOutput();
71 $this->setHeaders();
73 if ( !$this->getConfig()->get( MainConfigNames::UseDatabaseMessages ) ) {
74 $out->addWikiMsg( 'allmessages-not-supported-database' );
76 return;
79 $out->addModuleStyles( 'mediawiki.special' );
80 $this->addHelpLink( 'Help:System message' );
82 $contLangCode = $this->getContentLanguage()->getCode();
83 $lang = $this->getLanguage();
85 $opts = new FormOptions();
87 $opts->add( 'prefix', '' );
88 $opts->add( 'filter', 'all' );
89 $opts->add( 'lang', $contLangCode );
90 $opts->add( 'limit', 50 );
92 $opts->fetchValuesFromRequest( $this->getRequest() );
93 $opts->validateIntBounds( 'limit', 0, 5000 );
95 if ( !$this->languageNameUtils->isKnownLanguageTag( $opts->getValue( 'lang' ) ) ) {
96 // Show a warning message and fallback to content language
97 $out->addHTML(
98 Html::warningBox(
99 $this->msg( 'allmessages-unknown-language' )
100 ->plaintextParams( $opts->getValue( 'lang' ) )
101 ->parse()
104 $opts->setValue( 'lang', $contLangCode );
107 $pager = new AllMessagesTablePager(
108 $this->getContext(),
109 $this->getContentLanguage(),
110 $this->languageFactory,
111 $this->getLinkRenderer(),
112 $this->dbProvider,
113 $this->localisationCache,
114 $opts
117 $formDescriptor = [
118 'prefix' => [
119 'type' => 'text',
120 'name' => 'prefix',
121 'label-message' => 'allmessages-prefix',
124 'filter' => [
125 'type' => 'radio',
126 'name' => 'filter',
127 'label-message' => 'allmessages-filter',
128 'options-messages' => [
129 'allmessages-filter-unmodified' => 'unmodified',
130 'allmessages-filter-all' => 'all',
131 'allmessages-filter-modified' => 'modified',
133 'default' => 'all',
134 'flatlist' => true,
137 'lang' => [
138 'type' => 'language',
139 'name' => 'lang',
140 'label-message' => 'allmessages-language',
141 'default' => $opts->getValue( 'lang' ),
144 'limit' => [
145 'type' => 'limitselect',
146 'name' => 'limit',
147 'label-message' => 'table_pager_limit_label',
148 'options' => [
149 $lang->formatNum( 20 ) => 20,
150 $lang->formatNum( 50 ) => 50,
151 $lang->formatNum( 100 ) => 100,
152 $lang->formatNum( 250 ) => 250,
153 $lang->formatNum( 500 ) => 500,
154 $lang->formatNum( 5000 ) => 5000,
156 'default' => $opts->getValue( 'limit' ),
160 $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
161 $htmlForm
162 ->setMethod( 'get' )
163 ->setPreHtml( $this->msg( 'allmessagestext' )->parse() )
164 ->setWrapperLegendMsg( 'allmessages' )
165 ->setSubmitTextMsg( 'allmessages-filter-submit' )
166 ->prepareForm()
167 ->displayForm( false );
169 $out->addParserOutputContent( $pager->getFullOutput() );
172 protected function getGroupName() {
173 return 'wiki';
177 /** @deprecated class alias since 1.41 */
178 class_alias( SpecialAllMessages::class, 'SpecialAllMessages' );