MediaWiki  master
SpecialAllMessages.php
Go to the documentation of this file.
1 <?php
25 
33 
36 
38  private $loadBalancer;
39 
44  public function __construct(
47  ) {
48  parent::__construct( 'Allmessages' );
49  $this->localisationCache = $localisationCache;
50  $this->loadBalancer = $loadBalancer;
51  }
52 
56  public function execute( $par ) {
57  $out = $this->getOutput();
58 
59  $this->setHeaders();
60 
61  if ( !$this->getConfig()->get( 'UseDatabaseMessages' ) ) {
62  $out->addWikiMsg( 'allmessages-not-supported-database' );
63 
64  return;
65  }
66 
67  $out->addModuleStyles( 'mediawiki.special' );
68  $this->addHelpLink( 'Help:System message' );
69 
70  $contLangCode = $this->getContentLanguage()->getCode();
71  $lang = $this->getLanguage();
72 
73  $opts = new FormOptions();
74 
75  $opts->add( 'prefix', '' );
76  $opts->add( 'filter', 'all' );
77  $opts->add( 'lang', $contLangCode );
78  $opts->add( 'limit', 50 );
79 
80  $opts->fetchValuesFromRequest( $this->getRequest() );
81  $opts->validateIntBounds( 'limit', 0, 5000 );
82 
83  $pager = new AllMessagesTablePager(
84  $this->getContext(),
85  $opts,
86  $this->getLinkRenderer(),
87  $this->getContentLanguage(),
88  $this->localisationCache,
89  $this->loadBalancer
90  );
91 
92  $formDescriptor = [
93  'prefix' => [
94  'type' => 'text',
95  'name' => 'prefix',
96  'label-message' => 'allmessages-prefix',
97  ],
98 
99  'filter' => [
100  'type' => 'radio',
101  'name' => 'filter',
102  'label-message' => 'allmessages-filter',
103  'options-messages' => [
104  'allmessages-filter-unmodified' => 'unmodified',
105  'allmessages-filter-all' => 'all',
106  'allmessages-filter-modified' => 'modified',
107  ],
108  'default' => 'all',
109  'flatlist' => true,
110  ],
111 
112  'lang' => [
113  'type' => 'language',
114  'name' => 'lang',
115  'label-message' => 'allmessages-language',
116  'default' => $opts->getValue( 'lang' ),
117  ],
118 
119  'limit' => [
120  'type' => 'limitselect',
121  'name' => 'limit',
122  'label-message' => 'table_pager_limit_label',
123  'options' => [
124  $lang->formatNum( 20 ) => 20,
125  $lang->formatNum( 50 ) => 50,
126  $lang->formatNum( 100 ) => 100,
127  $lang->formatNum( 250 ) => 250,
128  $lang->formatNum( 500 ) => 500,
129  $lang->formatNum( 5000 ) => 5000,
130  ],
131  'default' => $opts->getValue( 'limit' ),
132  ],
133  ];
134 
135  $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
136  $htmlForm
137  ->setMethod( 'get' )
138  ->setIntro( $this->msg( 'allmessagestext' ) )
139  ->setWrapperLegendMsg( 'allmessages' )
140  ->setSubmitTextMsg( 'allmessages-filter-submit' )
141  ->prepareForm()
142  ->displayForm( false );
143 
144  $out->addParserOutputContent( $pager->getFullOutput() );
145  }
146 
147  protected function getGroupName() {
148  return 'wiki';
149  }
150 }
AllMessagesTablePager
Use TablePager for prettified output.
Definition: AllMessagesTablePager.php:34
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:912
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:790
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:37
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:830
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:948
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:878
SpecialAllMessages\$loadBalancer
ILoadBalancer $loadBalancer
Definition: SpecialAllMessages.php:38
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:618
SpecialAllMessages
Definition: SpecialAllMessages.php:32
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:764
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:43
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:780
LocalisationCache
Class for caching the contents of localisation files, Messages*.php and *.i18n.php.
Definition: LocalisationCache.php:43
SpecialAllMessages\__construct
__construct(LocalisationCache $localisationCache, ILoadBalancer $loadBalancer)
Definition: SpecialAllMessages.php:44
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:1028
SpecialAllMessages\$localisationCache
LocalisationCache $localisationCache
Definition: SpecialAllMessages.php:35
FormOptions
Helper class to keep track of options when mixing links and form elements.
Definition: FormOptions.php:35
SpecialPage\getContentLanguage
getContentLanguage()
Shortcut to get content language.
Definition: SpecialPage.php:840
SpecialAllMessages\execute
execute( $par)
Definition: SpecialAllMessages.php:56
HTMLForm\factory
static factory( $displayFormat,... $arguments)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:326
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81
SpecialAllMessages\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialAllMessages.php:147