MediaWiki  master
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 
49  $filters = $request->getArray( 'wpfilters' );
50  $filters = is_null( $filters ) ? [] : $filters;
51  $indefOnly = in_array( 'indefonly', $filters );
52  $cascadeOnly = in_array( 'cascadeonly', $filters );
53  $noRedirect = in_array( 'noredirect', $filters );
54 
55  $pager = new ProtectedPagesPager(
56  $this,
57  [],
58  $type,
59  $level,
60  $ns,
61  $sizetype,
62  $size,
63  $indefOnly,
64  $cascadeOnly,
65  $noRedirect,
66  $this->getLinkRenderer()
67  );
68 
69  $this->getOutput()->addHTML( $this->showOptions(
70  $ns,
71  $type,
72  $level,
73  $sizetype,
74  $size,
75  $filters
76  ) );
77 
78  if ( $pager->getNumRows() ) {
79  $this->getOutput()->addParserOutputContent( $pager->getFullOutput() );
80  } else {
81  $this->getOutput()->addWikiMsg( 'protectedpagesempty' );
82  }
83  }
84 
95  protected function showOptions( $namespace, $type, $level, $sizetype,
96  $size, $filters
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  'filters' => [
110  'class' => 'HTMLMultiSelectField',
111  'label' => $this->msg( 'protectedpages-filters' )->text(),
112  'flatlist' => true,
113  'options' => [
114  $this->msg( 'protectedpages-indef' )->text() => 'indefonly',
115  $this->msg( 'protectedpages-cascade' )->text() => 'cascadeonly',
116  $this->msg( 'protectedpages-noredirect' )->text() => 'noredirect',
117  ],
118  'default' => $filters,
119  ],
120  'sizelimit' => [
121  'class' => HTMLSizeFilterField::class,
122  'name' => 'size',
123  ]
124  ];
125  $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
126  $htmlForm
127  ->setMethod( 'get' )
128  ->setWrapperLegendMsg( 'protectedpages' )
129  ->setSubmitText( $this->msg( 'protectedpages-submit' )->text() );
130 
131  return $htmlForm->prepareForm()->getHTML( false );
132  }
133 
139  protected function getTypeMenu( $pr_type ) {
140  $m = []; // Temporary array
141  $options = [];
142 
143  // First pass to load the log names
144  foreach ( Title::getFilteredRestrictionTypes( true ) as $type ) {
145  // Messages: restriction-edit, restriction-move, restriction-create, restriction-upload
146  $text = $this->msg( "restriction-$type" )->text();
147  $m[$text] = $type;
148  }
149 
150  // Third pass generates sorted XHTML content
151  foreach ( $m as $text => $type ) {
152  $options[$text] = $type;
153  }
154 
155  return [
156  'type' => 'select',
157  'options' => $options,
158  'label' => $this->msg( 'restriction-type' )->text(),
159  'name' => $this->IdType,
160  'id' => $this->IdType,
161  ];
162  }
163 
169  protected function getLevelMenu( $pr_level ) {
170  // Temporary array
171  $m = [ $this->msg( 'restriction-level-all' )->text() => 0 ];
172  $options = [];
173 
174  // First pass to load the log names
175  foreach ( $this->getConfig()->get( 'RestrictionLevels' ) as $type ) {
176  // Messages used can be 'restriction-level-sysop' and 'restriction-level-autoconfirmed'
177  if ( $type != '' && $type != '*' ) {
178  $text = $this->msg( "restriction-level-$type" )->text();
179  $m[$text] = $type;
180  }
181  }
182 
183  // Third pass generates sorted XHTML content
184  foreach ( $m as $text => $type ) {
185  $options[$text] = $type;
186  }
187 
188  return [
189  'type' => 'select',
190  'options' => $options,
191  'label' => $this->msg( 'restriction-level' )->text(),
192  'name' => $this->IdLevel,
193  'id' => $this->IdLevel
194  ];
195  }
196 
197  protected function getGroupName() {
198  return 'maintenance';
199  }
200 }
static getFilteredRestrictionTypes( $exists=true)
Get a filtered list of all restriction types supported by this wiki.
Definition: Title.php:2879
getContext()
Gets the context this SpecialPage is executed in.
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:2075
showOptions( $namespace, $type, $level, $sizetype, $size, $filters)
getLevelMenu( $pr_level)
Creates the input label of the restriction level.
getOutput()
Get the OutputPage being used for this instance.
static factory( $displayFormat)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:284
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
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:1996
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
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
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
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
getTypeMenu( $pr_type)
Creates the input label of the restriction type.
getConfig()
Shortcut to get main config object.
msg( $key)
Wrapper around wfMessage that sets the current context.
getRequest()
Get the WebRequest being used for this instance.
A special page that lists protected pages.
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:2626
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...