MediaWiki  1.30.0
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( 'sizetype' );
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  $title = $this->getPageTitle();
99 
100  return Xml::openElement( 'form', [ 'method' => 'get', 'action' => wfScript() ] ) .
101  Xml::openElement( 'fieldset' ) .
102  Xml::element( 'legend', [], $this->msg( 'protectedpages' )->text() ) .
103  Html::hidden( 'title', $title->getPrefixedDBkey() ) . "\n" .
104  $this->getNamespaceMenu( $namespace ) . "\n" .
105  $this->getTypeMenu( $type ) . "\n" .
106  $this->getLevelMenu( $level ) . "\n" .
107  "<br />\n" .
108  $this->getExpiryCheck( $indefOnly ) . "\n" .
109  $this->getCascadeCheck( $cascadeOnly ) . "\n" .
110  $this->getRedirectCheck( $noRedirect ) . "\n" .
111  "<br />\n" .
112  $this->getSizeLimit( $sizetype, $size ) . "\n" .
113  Xml::submitButton( $this->msg( 'protectedpages-submit' )->text() ) . "\n" .
114  Xml::closeElement( 'fieldset' ) .
115  Xml::closeElement( 'form' );
116  }
117 
125  protected function getNamespaceMenu( $namespace = null ) {
126  return Html::rawElement( 'span', [ 'class' => 'mw-input-with-label' ],
128  [
129  'selected' => $namespace,
130  'all' => '',
131  'label' => $this->msg( 'namespace' )->text()
132  ], [
133  'name' => 'namespace',
134  'id' => 'namespace',
135  'class' => 'namespaceselector',
136  ]
137  )
138  );
139  }
140 
145  protected function getExpiryCheck( $indefOnly ) {
146  return '<span class="mw-input-with-label">' . Xml::checkLabel(
147  $this->msg( 'protectedpages-indef' )->text(),
148  'indefonly',
149  'indefonly',
150  $indefOnly
151  ) . "</span>\n";
152  }
153 
158  protected function getCascadeCheck( $cascadeOnly ) {
159  return '<span class="mw-input-with-label">' . Xml::checkLabel(
160  $this->msg( 'protectedpages-cascade' )->text(),
161  'cascadeonly',
162  'cascadeonly',
163  $cascadeOnly
164  ) . "</span>\n";
165  }
166 
171  protected function getRedirectCheck( $noRedirect ) {
172  return '<span class="mw-input-with-label">' . Xml::checkLabel(
173  $this->msg( 'protectedpages-noredirect' )->text(),
174  'noredirect',
175  'noredirect',
176  $noRedirect
177  ) . "</span>\n";
178  }
179 
185  protected function getSizeLimit( $sizetype, $size ) {
186  $max = $sizetype === 'max';
187 
188  return '<span class="mw-input-with-label">' . Xml::radioLabel(
189  $this->msg( 'minimum-size' )->text(),
190  'sizetype',
191  'min',
192  'wpmin',
193  !$max
194  ) .
195  ' ' .
197  $this->msg( 'maximum-size' )->text(),
198  'sizetype',
199  'max',
200  'wpmax',
201  $max
202  ) .
203  ' ' .
204  Xml::input( 'size', 9, $size, [ 'id' => 'wpsize' ] ) .
205  ' ' .
206  Xml::label( $this->msg( 'pagesize' )->text(), 'wpsize' ) . "</span>\n";
207  }
208 
214  protected function getTypeMenu( $pr_type ) {
215  $m = []; // Temporary array
216  $options = [];
217 
218  // First pass to load the log names
219  foreach ( Title::getFilteredRestrictionTypes( true ) as $type ) {
220  // Messages: restriction-edit, restriction-move, restriction-create, restriction-upload
221  $text = $this->msg( "restriction-$type" )->text();
222  $m[$text] = $type;
223  }
224 
225  // Third pass generates sorted XHTML content
226  foreach ( $m as $text => $type ) {
227  $selected = ( $type == $pr_type );
228  $options[] = Xml::option( $text, $type, $selected ) . "\n";
229  }
230 
231  return '<span class="mw-input-with-label">' .
232  Xml::label( $this->msg( 'restriction-type' )->text(), $this->IdType ) . ' ' .
233  Xml::tags( 'select',
234  [ 'id' => $this->IdType, 'name' => $this->IdType ],
235  implode( "\n", $options ) ) . "</span>";
236  }
237 
243  protected function getLevelMenu( $pr_level ) {
244  // Temporary array
245  $m = [ $this->msg( 'restriction-level-all' )->text() => 0 ];
246  $options = [];
247 
248  // First pass to load the log names
249  foreach ( $this->getConfig()->get( 'RestrictionLevels' ) as $type ) {
250  // Messages used can be 'restriction-level-sysop' and 'restriction-level-autoconfirmed'
251  if ( $type != '' && $type != '*' ) {
252  $text = $this->msg( "restriction-level-$type" )->text();
253  $m[$text] = $type;
254  }
255  }
256 
257  // Third pass generates sorted XHTML content
258  foreach ( $m as $text => $type ) {
259  $selected = ( $type == $pr_level );
260  $options[] = Xml::option( $text, $type, $selected );
261  }
262 
263  return '<span class="mw-input-with-label">' .
264  Xml::label( $this->msg( 'restriction-level' )->text(), $this->IdLevel ) . ' ' .
265  Xml::tags( 'select',
266  [ 'id' => $this->IdLevel, 'name' => $this->IdLevel ],
267  implode( "\n", $options ) ) . "</span>";
268  }
269 
270  protected function getGroupName() {
271  return 'maintenance';
272  }
273 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:628
SpecialProtectedpages\execute
execute( $par)
Default execute method Checks user permissions.
Definition: SpecialProtectedpages.php:37
SpecialPage\msg
msg( $key)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:746
Title\getFilteredRestrictionTypes
static getFilteredRestrictionTypes( $exists=true)
Get a filtered list of all restriction types supported by this wiki.
Definition: Title.php:2649
Xml\tags
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:675
Xml\label
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition: Xml.php:358
text
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:12
Xml\option
static option( $text, $value=null, $selected=false, $attribs=[])
Convenience function to build an HTML drop-down list item.
Definition: Xml.php:484
SpecialProtectedpages\getSizeLimit
getSizeLimit( $sizetype, $size)
Definition: SpecialProtectedpages.php:185
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:109
SpecialProtectedpages\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialProtectedpages.php:270
php
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
SpecialProtectedpages\getRedirectCheck
getRedirectCheck( $noRedirect)
Definition: SpecialProtectedpages.php:171
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:714
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:932
wfScript
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
Definition: GlobalFunctions.php:2934
SpecialProtectedpages
A special page that lists protected pages.
Definition: SpecialProtectedpages.php:29
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:39
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:484
SpecialProtectedpages\showOptions
showOptions( $namespace, $type='edit', $level, $sizetype, $size, $indefOnly, $cascadeOnly, $noRedirect)
Definition: SpecialProtectedpages.php:95
SpecialProtectedpages\getLevelMenu
getLevelMenu( $pr_level)
Creates the input label of the restriction level.
Definition: SpecialProtectedpages.php:243
SpecialProtectedpages\getTypeMenu
getTypeMenu( $pr_type)
Creates the input label of the restriction type.
Definition: SpecialProtectedpages.php:214
$request
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:2581
Html\hidden
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:725
Html\namespaceSelector
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
Definition: Html.php:813
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:36
SpecialProtectedpages\getNamespaceMenu
getNamespaceMenu( $namespace=null)
Prepare the namespace filter drop-down; standard namespace selector, sans the MediaWiki namespace.
Definition: SpecialProtectedpages.php:125
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:665
SpecialProtectedpages\$IdType
$IdType
Definition: SpecialProtectedpages.php:31
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:860
Xml\radioLabel
static radioLabel( $label, $name, $value, $id, $checked=false, $attribs=[])
Convenience function to build an HTML radio button with a label.
Definition: Xml.php:444
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:118
$options
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:1965
SpecialProtectedpages\getCascadeCheck
getCascadeCheck( $cascadeOnly)
Definition: SpecialProtectedpages.php:158
as
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
Definition: distributors.txt:9
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
SpecialProtectedpages\__construct
__construct()
Definition: SpecialProtectedpages.php:33
SpecialProtectedpages\$IdLevel
$IdLevel
Definition: SpecialProtectedpages.php:30
Xml\input
static input( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
Definition: Xml.php:274
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:583
ProtectedPagesPager
Definition: ProtectedPagesPager.php:27
SpecialProtectedpages\getExpiryCheck
getExpiryCheck( $indefOnly)
Definition: SpecialProtectedpages.php:145
Xml\submitButton
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:459
Xml\checkLabel
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
Definition: Xml.php:419
$type
$type
Definition: testCompression.php:48