MediaWiki  master
SpecialAllMessages.php
Go to the documentation of this file.
1 <?php
26 
34 
36  private $loadBalancer;
37 
40 
45  public function __construct(
48  ) {
49  parent::__construct( 'Allmessages' );
50  $this->localisationCache = $localisationCache;
51  $this->loadBalancer = $loadBalancer;
52  }
53 
57  public function execute( $par ) {
58  $out = $this->getOutput();
59 
60  $this->setHeaders();
61 
62  if ( !$this->getConfig()->get( MainConfigNames::UseDatabaseMessages ) ) {
63  $out->addWikiMsg( 'allmessages-not-supported-database' );
64 
65  return;
66  }
67 
68  $out->addModuleStyles( 'mediawiki.special' );
69  $this->addHelpLink( 'Help:System message' );
70 
71  $contLangCode = $this->getContentLanguage()->getCode();
72  $lang = $this->getLanguage();
73 
74  $opts = new FormOptions();
75 
76  $opts->add( 'prefix', '' );
77  $opts->add( 'filter', 'all' );
78  $opts->add( 'lang', $contLangCode );
79  $opts->add( 'limit', 50 );
80 
81  $opts->fetchValuesFromRequest( $this->getRequest() );
82  $opts->validateIntBounds( 'limit', 0, 5000 );
83 
84  $pager = new AllMessagesTablePager(
85  $this->getContext(),
86  $this->getContentLanguage(),
87  $this->getLinkRenderer(),
88  $this->loadBalancer,
89  $this->localisationCache,
90  $opts
91  );
92 
93  $formDescriptor = [
94  'prefix' => [
95  'type' => 'text',
96  'name' => 'prefix',
97  'label-message' => 'allmessages-prefix',
98  ],
99 
100  'filter' => [
101  'type' => 'radio',
102  'name' => 'filter',
103  'label-message' => 'allmessages-filter',
104  'options-messages' => [
105  'allmessages-filter-unmodified' => 'unmodified',
106  'allmessages-filter-all' => 'all',
107  'allmessages-filter-modified' => 'modified',
108  ],
109  'default' => 'all',
110  'flatlist' => true,
111  ],
112 
113  'lang' => [
114  'type' => 'language',
115  'name' => 'lang',
116  'label-message' => 'allmessages-language',
117  'default' => $opts->getValue( 'lang' ),
118  ],
119 
120  'limit' => [
121  'type' => 'limitselect',
122  'name' => 'limit',
123  'label-message' => 'table_pager_limit_label',
124  'options' => [
125  $lang->formatNum( 20 ) => 20,
126  $lang->formatNum( 50 ) => 50,
127  $lang->formatNum( 100 ) => 100,
128  $lang->formatNum( 250 ) => 250,
129  $lang->formatNum( 500 ) => 500,
130  $lang->formatNum( 5000 ) => 5000,
131  ],
132  'default' => $opts->getValue( 'limit' ),
133  ],
134  ];
135 
136  $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
137  $htmlForm
138  ->setMethod( 'get' )
139  ->setIntro( $this->msg( 'allmessagestext' ) )
140  ->setWrapperLegendMsg( 'allmessages' )
141  ->setSubmitTextMsg( 'allmessages-filter-submit' )
142  ->prepareForm()
143  ->displayForm( false );
144 
145  $out->addParserOutputContent( $pager->getFullOutput() );
146  }
147 
148  protected function getGroupName() {
149  return 'wiki';
150  }
151 }
Use TablePager for prettified output.
Helper class to keep track of options when mixing links and form elements.
Definition: FormOptions.php:35
static factory( $displayFormat, $descriptor, IContextSource $context, $messagePrefix='')
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:338
Class for caching the contents of localisation files, Messages*.php and *.i18n.php.
A class containing constants representing the names of configuration variables.
LocalisationCache $localisationCache
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
ILoadBalancer $loadBalancer
__construct(LocalisationCache $localisationCache, ILoadBalancer $loadBalancer)
Parent class for all special pages.
Definition: SpecialPage.php:44
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.
getContentLanguage()
Shortcut to get content language.
Database cluster connection, tracking, load balancing, and transaction manager interface.
if(!isset( $args[0])) $lang