MediaWiki REL1_35
SpecialAllMessages.php
Go to the documentation of this file.
1<?php
24
32
33 public function __construct() {
34 parent::__construct( 'Allmessages' );
35 }
36
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}
Use TablePager for prettified output.
Helper class to keep track of options when mixing links and form elements.
MediaWikiServices is the service locator for the application scope of MediaWiki.
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.
if(!isset( $args[0])) $lang