MediaWiki  master
SpecialAutoblockList.php
Go to the documentation of this file.
1 <?php
31 
32  function __construct() {
33  parent::__construct( 'AutoblockList' );
34  }
35 
41  public function execute( $par ) {
42  $this->setHeaders();
43  $this->outputHeader();
44  $out = $this->getOutput();
45  $out->setPageTitle( $this->msg( 'autoblocklist' ) );
46  $this->addHelpLink( 'Autoblock' );
47  $out->addModuleStyles( [ 'mediawiki.special' ] );
48 
49  # setup BlockListPager here to get the actual default Limit
50  $pager = $this->getBlockListPager();
51 
52  # Just show the block list
53  $fields = [
54  'Limit' => [
55  'type' => 'limitselect',
56  'label-message' => 'table_pager_limit_label',
57  'options' => $pager->getLimitSelectList(),
58  'name' => 'limit',
59  'default' => $pager->getLimit(),
60  ]
61  ];
62 
63  $context = new DerivativeContext( $this->getContext() );
64  $context->setTitle( $this->getPageTitle() ); // Remove subpage
65  $form = HTMLForm::factory( 'ooui', $fields, $context );
66  $form->setMethod( 'get' )
67  ->setFormIdentifier( 'blocklist' )
68  ->setWrapperLegendMsg( 'autoblocklist-legend' )
69  ->setSubmitTextMsg( 'autoblocklist-submit' )
70  ->prepareForm()
71  ->displayForm( false );
72 
73  $this->showTotal( $pager );
74  $this->showList( $pager );
75  }
76 
81  protected function getBlockListPager() {
82  $conds = [
83  'ipb_parent_block_id IS NOT NULL'
84  ];
85  # Is the user allowed to see hidden blocks?
86  if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
87  $conds['ipb_deleted'] = 0;
88  }
89 
90  return new BlockListPager( $this, $conds );
91  }
92 
98  protected function showTotal( BlockListPager $pager ) {
99  $out = $this->getOutput();
100  $out->addHTML(
101  Html::rawElement( 'div', [ 'style' => 'font-weight: bold;' ],
102  $this->msg( 'autoblocklist-total-autoblocks', $pager->getTotalAutoblocks() )->parse() )
103  . "\n"
104  );
105  }
106 
111  protected function showList( BlockListPager $pager ) {
112  $out = $this->getOutput();
113 
114  # Check for other blocks, i.e. global/tor blocks
115  $otherAutoblockLink = [];
116  Hooks::run( 'OtherAutoblockLogLink', [ &$otherAutoblockLink ] );
117 
118  # Show additional header for the local block only when other blocks exists.
119  # Not necessary in a standard installation without such extensions enabled
120  if ( count( $otherAutoblockLink ) ) {
121  $out->addHTML(
122  Html::rawElement( 'h2', [], $this->msg( 'autoblocklist-localblocks',
123  $pager->getNumRows() )->parse() )
124  . "\n"
125  );
126  }
127 
128  if ( $pager->getNumRows() ) {
129  $out->addParserOutputContent( $pager->getFullOutput() );
130  } else {
131  $out->addWikiMsg( 'autoblocklist-empty' );
132  }
133 
134  if ( count( $otherAutoblockLink ) ) {
135  $out->addHTML(
137  'h2',
138  [],
139  $this->msg( 'autoblocklist-otherblocks', count( $otherAutoblockLink ) )->parse()
140  ) . "\n"
141  );
142  $list = '';
143  foreach ( $otherAutoblockLink as $link ) {
144  $list .= Html::rawElement( 'li', [], $link ) . "\n";
145  }
146  $out->addHTML(
148  'ul',
149  [ 'class' => 'mw-autoblocklist-otherblocks' ],
150  $list
151  ) . "\n"
152  );
153  }
154  }
155 
156  protected function getGroupName() {
157  return 'users';
158  }
159 }
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:785
getContext()
Gets the context this SpecialPage is executed in.
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:210
An IContextSource implementation which will inherit context from another source but allow individual ...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
getOutput()
Get the OutputPage being used for this instance.
static factory( $displayFormat)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:284
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:3043
A special page that lists autoblocks.
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
execute( $par)
Main execution point.
showList(BlockListPager $pager)
Show the list of blocked accounts matching the actual filter.
getUser()
Shortcut to get the User executing this instance.
msg( $key)
Wrapper around wfMessage that sets the current context.
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 and they can depend only on the ResourceLoaderContext $context
Definition: hooks.txt:2626
getFullOutput()
Get the formatted result list, with navigation bars.
Definition: TablePager.php:99
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
getPageTitle( $subpage=false)
Get a self-referential title object.
getBlockListPager()
Setup a new BlockListPager instance.
showTotal(BlockListPager $pager)
Show total number of autoblocks on top of the table.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
getTotalAutoblocks()
Get total number of autoblocks at any given time.
getNumRows()
Get the number of rows in the result set.
Definition: IndexPager.php:556