MediaWiki  master
SpecialAllMessages.php
Go to the documentation of this file.
1 <?php
31 
33  private $contentLang;
34 
38  public function __construct( Language $contentLang ) {
39  parent::__construct( 'Allmessages' );
40 
41  $this->contentLang = $contentLang;
42  }
43 
47  public function execute( $par ) {
48  $out = $this->getOutput();
49 
50  $this->setHeaders();
51 
52  if ( !$this->getConfig()->get( 'UseDatabaseMessages' ) ) {
53  $out->addWikiMsg( 'allmessages-not-supported-database' );
54 
55  return;
56  }
57 
58  $out->addModuleStyles( 'mediawiki.special' );
59  $this->addHelpLink( 'Help:System message' );
60 
61  $contLangCode = $this->contentLang->getCode();
62  $lang = $this->getLanguage();
63 
64  $opts = new FormOptions();
65 
66  $opts->add( 'prefix', '' );
67  $opts->add( 'filter', 'all' );
68  $opts->add( 'lang', $contLangCode );
69  $opts->add( 'limit', 50 );
70 
71  $opts->fetchValuesFromRequest( $this->getRequest() );
72  $opts->validateIntBounds( 'limit', 0, 5000 );
73 
74  $pager = new AllMessagesTablePager( $this->getContext(), $opts, $this->getLinkRenderer() );
75 
76  $formDescriptor = [
77  'prefix' => [
78  'type' => 'text',
79  'name' => 'prefix',
80  'label-message' => 'allmessages-prefix',
81  ],
82 
83  'filter' => [
84  'type' => 'radio',
85  'name' => 'filter',
86  'label-message' => 'allmessages-filter',
87  'options-messages' => [
88  'allmessages-filter-unmodified' => 'unmodified',
89  'allmessages-filter-all' => 'all',
90  'allmessages-filter-modified' => 'modified',
91  ],
92  'default' => 'all',
93  'flatlist' => true,
94  ],
95 
96  'lang' => [
97  'type' => 'language',
98  'name' => 'lang',
99  'label-message' => 'allmessages-language',
100  'default' => $opts->getValue( 'lang' ),
101  ],
102 
103  'limit' => [
104  'type' => 'limitselect',
105  'name' => 'limit',
106  'label-message' => 'table_pager_limit_label',
107  'options' => [
108  $lang->formatNum( 20 ) => 20,
109  $lang->formatNum( 50 ) => 50,
110  $lang->formatNum( 100 ) => 100,
111  $lang->formatNum( 250 ) => 250,
112  $lang->formatNum( 500 ) => 500,
113  $lang->formatNum( 5000 ) => 5000,
114  ],
115  'default' => $opts->getValue( 'limit' ),
116  ],
117  ];
118 
119  $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
120  $htmlForm
121  ->setMethod( 'get' )
122  ->setIntro( $this->msg( 'allmessagestext' ) )
123  ->setWrapperLegendMsg( 'allmessages' )
124  ->setSubmitTextMsg( 'allmessages-filter-submit' )
125  ->prepareForm()
126  ->displayForm( false );
127 
128  $out->addParserOutputContent( $pager->getFullOutput() );
129  }
130 
131  protected function getGroupName() {
132  return 'wiki';
133  }
134 }
AllMessagesTablePager
Use TablePager for prettified output.
Definition: AllMessagesTablePager.php:33
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:828
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:744
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:37
SpecialAllMessages\$contentLang
Language $contentLang
Definition: SpecialAllMessages.php:33
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:774
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:864
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:794
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!...
Definition: SpecialPage.php:571
SpecialAllMessages
Definition: SpecialAllMessages.php:30
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:717
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:41
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:734
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:944
SpecialAllMessages\__construct
__construct(Language $contentLang)
Definition: SpecialAllMessages.php:38
FormOptions
Helper class to keep track of options when mixing links and form elements.
Definition: FormOptions.php:35
SpecialAllMessages\execute
execute( $par)
Definition: SpecialAllMessages.php:47
HTMLForm\factory
static factory( $displayFormat,... $arguments)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:315
Language
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Definition: Language.php:41
SpecialAllMessages\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialAllMessages.php:131