MediaWiki REL1_31
SpecialProtectedpages.php
Go to the documentation of this file.
1<?php
30 protected $IdLevel = 'level';
31 protected $IdType = 'type';
32
33 public function __construct() {
34 parent::__construct( 'Protectedpages' );
35 }
36
37 public function execute( $par ) {
38 $this->setHeaders();
39 $this->outputHeader();
40 $this->getOutput()->addModuleStyles( 'mediawiki.special' );
41
42 $request = $this->getRequest();
43 $type = $request->getVal( $this->IdType );
44 $level = $request->getVal( $this->IdLevel );
45 $sizetype = $request->getVal( 'size-mode' );
46 $size = $request->getIntOrNull( 'size' );
47 $ns = $request->getIntOrNull( 'namespace' );
48 $indefOnly = $request->getBool( 'indefonly' ) ? 1 : 0;
49 $cascadeOnly = $request->getBool( 'cascadeonly' ) ? 1 : 0;
50 $noRedirect = $request->getBool( 'noredirect' ) ? 1 : 0;
51
52 $pager = new ProtectedPagesPager(
53 $this,
54 [],
55 $type,
56 $level,
57 $ns,
58 $sizetype,
59 $size,
60 $indefOnly,
61 $cascadeOnly,
62 $noRedirect,
63 $this->getLinkRenderer()
64 );
65
66 $this->getOutput()->addHTML( $this->showOptions(
67 $ns,
68 $type,
69 $level,
70 $sizetype,
71 $size,
72 $indefOnly,
73 $cascadeOnly,
74 $noRedirect
75 ) );
76
77 if ( $pager->getNumRows() ) {
78 $this->getOutput()->addParserOutputContent( $pager->getFullOutput() );
79 } else {
80 $this->getOutput()->addWikiMsg( 'protectedpagesempty' );
81 }
82 }
83
95 protected function showOptions( $namespace, $type = 'edit', $level, $sizetype,
96 $size, $indefOnly, $cascadeOnly, $noRedirect
97 ) {
98 $formDescriptor = [
99 'namespace' => [
100 'class' => HTMLSelectNamespace::class,
101 'name' => 'namespace',
102 'id' => 'namespace',
103 'cssclass' => 'namespaceselector',
104 'all' => '',
105 'label' => $this->msg( 'namespace' )->text(),
106 ],
107 'typemenu' => $this->getTypeMenu( $type ),
108 'levelmenu' => $this->getLevelMenu( $level ),
109 'expirycheck' => [
110 'type' => 'check',
111 'label' => $this->msg( 'protectedpages-indef' )->text(),
112 'name' => 'indefonly',
113 'id' => 'indefonly',
114 ],
115 'cascadecheck' => [
116 'type' => 'check',
117 'label' => $this->msg( 'protectedpages-cascade' )->text(),
118 'name' => 'cascadeonly',
119 'id' => 'cascadeonly',
120 ],
121 'redirectcheck' => [
122 'type' => 'check',
123 'label' => $this->msg( 'protectedpages-noredirect' )->text(),
124 'name' => 'noredirect',
125 'id' => 'noredirect',
126 ],
127 'sizelimit' => [
128 'class' => HTMLSizeFilterField::class,
129 'name' => 'size',
130 ]
131 ];
132 $htmlForm = new HTMLForm( $formDescriptor, $this->getContext() );
133 $htmlForm
134 ->setMethod( 'get' )
135 ->setWrapperLegendMsg( 'protectedpages' )
136 ->setSubmitText( $this->msg( 'protectedpages-submit' )->text() );
137
138 return $htmlForm->prepareForm()->getHTML( false );
139 }
140
146 protected function getTypeMenu( $pr_type ) {
147 $m = []; // Temporary array
148 $options = [];
149
150 // First pass to load the log names
151 foreach ( Title::getFilteredRestrictionTypes( true ) as $type ) {
152 // Messages: restriction-edit, restriction-move, restriction-create, restriction-upload
153 $text = $this->msg( "restriction-$type" )->text();
154 $m[$text] = $type;
155 }
156
157 // Third pass generates sorted XHTML content
158 foreach ( $m as $text => $type ) {
159 $options[$text] = $type;
160 }
161
162 return [
163 'type' => 'select',
164 'options' => $options,
165 'label' => $this->msg( 'restriction-type' )->text(),
166 'name' => $this->IdType,
167 'id' => $this->IdType,
168 ];
169 }
170
176 protected function getLevelMenu( $pr_level ) {
177 // Temporary array
178 $m = [ $this->msg( 'restriction-level-all' )->text() => 0 ];
179 $options = [];
180
181 // First pass to load the log names
182 foreach ( $this->getConfig()->get( 'RestrictionLevels' ) as $type ) {
183 // Messages used can be 'restriction-level-sysop' and 'restriction-level-autoconfirmed'
184 if ( $type != '' && $type != '*' ) {
185 $text = $this->msg( "restriction-level-$type" )->text();
186 $m[$text] = $type;
187 }
188 }
189
190 // Third pass generates sorted XHTML content
191 foreach ( $m as $text => $type ) {
192 $options[$text] = $type;
193 }
194
195 return [
196 'type' => 'select',
197 'options' => $options,
198 'label' => $this->msg( 'restriction-level' )->text(),
199 'name' => $this->IdLevel,
200 'id' => $this->IdLevel
201 ];
202 }
203
204 protected function getGroupName() {
205 return 'maintenance';
206 }
207}
Object handling generic submission, CSRF protection, layout and other logic for UI forms.
Definition HTMLForm.php:130
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
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)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
A special page that lists protected pages.
getLevelMenu( $pr_level)
Creates the input label of the restriction level.
showOptions( $namespace, $type='edit', $level, $sizetype, $size, $indefOnly, $cascadeOnly, $noRedirect)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
getTypeMenu( $pr_type)
Creates the input label of the restriction type.
execute( $par)
Default execute method Checks user permissions.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition design.txt:18
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
Definition hooks.txt:2806
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition hooks.txt:2001
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:37