MediaWiki  master
SpecialAllMessages.php
Go to the documentation of this file.
1 <?php
24 
32 
33  public function __construct() {
34  parent::__construct( 'Allmessages' );
35  }
36 
42  public function execute( $par ) {
43  $out = $this->getOutput();
44 
45  $this->setHeaders();
46 
47  if ( !$this->getConfig()->get( 'UseDatabaseMessages' ) ) {
48  $out->addWikiMsg( 'allmessagesnotsupportedDB' );
49 
50  return;
51  }
52 
53  $out->addModuleStyles( 'mediawiki.special' );
54  $this->addHelpLink( 'Help:System message' );
55 
56  $contLang = MediaWikiServices::getInstance()->getContentLanguage()->getCode();
57  $lang = $this->getLanguage();
58 
59  $opts = new FormOptions();
60 
61  $opts->add( 'prefix', '' );
62  $opts->add( 'filter', 'all' );
63  $opts->add( 'lang', $contLang );
64  $opts->add( 'limit', 50 );
65 
66  $opts->fetchValuesFromRequest( $this->getRequest() );
67  $opts->validateIntBounds( 'limit', 0, 5000 );
68 
69  $pager = new AllMessagesTablePager( $this->getContext(), $opts );
70 
71  $formDescriptor = [
72  'prefix' => [
73  'type' => 'text',
74  'name' => 'prefix',
75  'label-message' => 'allmessages-prefix',
76  ],
77 
78  'filter' => [
79  'type' => 'radio',
80  'name' => 'filter',
81  'label-message' => 'allmessages-filter',
82  'options' => [
83  $this->msg( 'allmessages-filter-unmodified' )->text() => 'unmodified',
84  $this->msg( 'allmessages-filter-all' )->text() => 'all',
85  $this->msg( 'allmessages-filter-modified' )->text() => 'modified',
86  ],
87  'default' => 'all',
88  'flatlist' => true,
89  ],
90 
91  'lang' => [
92  'type' => 'language',
93  'name' => 'lang',
94  'label-message' => 'allmessages-language',
95  'default' => $opts->getValue( 'lang' ),
96  ],
97 
98  'limit' => [
99  'type' => 'limitselect',
100  'name' => 'limit',
101  'label-message' => 'table_pager_limit_label',
102  'options' => [
103  $lang->formatNum( 20 ) => 20,
104  $lang->formatNum( 50 ) => 50,
105  $lang->formatNum( 100 ) => 100,
106  $lang->formatNum( 250 ) => 250,
107  $lang->formatNum( 500 ) => 500,
108  $lang->formatNum( 5000 ) => 5000,
109  ],
110  'default' => $opts->getValue( 'limit' ),
111  ],
112  ];
113 
114  $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
115  $htmlForm
116  ->setMethod( 'get' )
117  ->setIntro( $this->msg( 'allmessagestext' ) )
118  ->setWrapperLegendMsg( 'allmessages' )
119  ->setSubmitTextMsg( 'allmessages-filter-submit' )
120  ->prepareForm()
121  ->displayForm( false );
122 
123  $out->addParserOutputContent( $pager->getFullOutput() );
124  }
125 
126  protected function getGroupName() {
127  return 'wiki';
128  }
129 }
Helper class to keep track of options when mixing links and form elements.
Definition: FormOptions.php:35
execute( $par)
Show the special page.
getContext()
Gets the context this SpecialPage is executed in.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead & $formDescriptor
Definition: hooks.txt:2074
if(!isset( $args[0])) $lang
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
getOutput()
Get the OutputPage being used for this instance.
static factory( $displayFormat)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:286
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:780
getConfig()
Shortcut to get main config object.
getLanguage()
Shortcut to get user&#39;s language.
msg( $key)
Wrapper around wfMessage that sets the current context.
getRequest()
Get the WebRequest being used for this instance.
Use TablePager for prettified output.