Merge "Make DBAccessBase use DBConnRef, rename $wiki, and hide getLoadBalancer()"
[lhc/web/wiklou.git] / includes / specials / SpecialAllMessages.php
1 <?php
2 /**
3 * Implements Special:Allmessages
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup SpecialPage
22 */
23 use MediaWiki\MediaWikiServices;
24
25 /**
26 * Use this special page to get a list of the MediaWiki system messages.
27 *
28 * @file
29 * @ingroup SpecialPage
30 */
31 class SpecialAllMessages extends SpecialPage {
32
33 public function __construct() {
34 parent::__construct( 'Allmessages' );
35 }
36
37 /**
38 * @param string|null $par Parameter passed to the page or null
39 */
40 public function execute( $par ) {
41 $out = $this->getOutput();
42
43 $this->setHeaders();
44
45 if ( !$this->getConfig()->get( 'UseDatabaseMessages' ) ) {
46 $out->addWikiMsg( 'allmessages-not-supported-database' );
47
48 return;
49 }
50
51 $out->addModuleStyles( 'mediawiki.special' );
52 $this->addHelpLink( 'Help:System message' );
53
54 $contLang = MediaWikiServices::getInstance()->getContentLanguage()->getCode();
55 $lang = $this->getLanguage();
56
57 $opts = new FormOptions();
58
59 $opts->add( 'prefix', '' );
60 $opts->add( 'filter', 'all' );
61 $opts->add( 'lang', $contLang );
62 $opts->add( 'limit', 50 );
63
64 $opts->fetchValuesFromRequest( $this->getRequest() );
65 $opts->validateIntBounds( 'limit', 0, 5000 );
66
67 $pager = new AllMessagesTablePager( $this->getContext(), $opts, $this->getLinkRenderer() );
68
69 $formDescriptor = [
70 'prefix' => [
71 'type' => 'text',
72 'name' => 'prefix',
73 'label-message' => 'allmessages-prefix',
74 ],
75
76 'filter' => [
77 'type' => 'radio',
78 'name' => 'filter',
79 'label-message' => 'allmessages-filter',
80 'options-messages' => [
81 'allmessages-filter-unmodified' => 'unmodified',
82 'allmessages-filter-all' => 'all',
83 'allmessages-filter-modified' => 'modified',
84 ],
85 'default' => 'all',
86 'flatlist' => true,
87 ],
88
89 'lang' => [
90 'type' => 'language',
91 'name' => 'lang',
92 'label-message' => 'allmessages-language',
93 'default' => $opts->getValue( 'lang' ),
94 ],
95
96 'limit' => [
97 'type' => 'limitselect',
98 'name' => 'limit',
99 'label-message' => 'table_pager_limit_label',
100 'options' => [
101 $lang->formatNum( 20 ) => 20,
102 $lang->formatNum( 50 ) => 50,
103 $lang->formatNum( 100 ) => 100,
104 $lang->formatNum( 250 ) => 250,
105 $lang->formatNum( 500 ) => 500,
106 $lang->formatNum( 5000 ) => 5000,
107 ],
108 'default' => $opts->getValue( 'limit' ),
109 ],
110 ];
111
112 $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
113 $htmlForm
114 ->setMethod( 'get' )
115 ->setIntro( $this->msg( 'allmessagestext' ) )
116 ->setWrapperLegendMsg( 'allmessages' )
117 ->setSubmitTextMsg( 'allmessages-filter-submit' )
118 ->prepareForm()
119 ->displayForm( false );
120
121 $out->addParserOutputContent( $pager->getFullOutput() );
122 }
123
124 protected function getGroupName() {
125 return 'wiki';
126 }
127 }