MediaWiki  1.33.1
SpecialAutoblockList.php
Go to the documentation of this file.
1 <?php
31 
32  function __construct() {
33  parent::__construct( 'AutoblockList' );
34  }
35 
39  public function execute( $par ) {
40  $this->setHeaders();
41  $this->outputHeader();
42  $out = $this->getOutput();
43  $out->setPageTitle( $this->msg( 'autoblocklist' ) );
44  $this->addHelpLink( 'Autoblock' );
45  $out->addModuleStyles( [ 'mediawiki.special' ] );
46 
47  # setup BlockListPager here to get the actual default Limit
48  $pager = $this->getBlockListPager();
49 
50  # Just show the block list
51  $fields = [
52  'Limit' => [
53  'type' => 'limitselect',
54  'label-message' => 'table_pager_limit_label',
55  'options' => $pager->getLimitSelectList(),
56  'name' => 'limit',
57  'default' => $pager->getLimit(),
58  ]
59  ];
60 
61  $context = new DerivativeContext( $this->getContext() );
62  $context->setTitle( $this->getPageTitle() ); // Remove subpage
63  $form = HTMLForm::factory( 'ooui', $fields, $context );
64  $form->setMethod( 'get' )
65  ->setFormIdentifier( 'blocklist' )
66  ->setWrapperLegendMsg( 'autoblocklist-legend' )
67  ->setSubmitTextMsg( 'autoblocklist-submit' )
68  ->prepareForm()
69  ->displayForm( false );
70 
71  $this->showTotal( $pager );
72  $this->showList( $pager );
73  }
74 
79  protected function getBlockListPager() {
80  $conds = [
81  'ipb_parent_block_id IS NOT NULL'
82  ];
83  # Is the user allowed to see hidden blocks?
84  if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
85  $conds['ipb_deleted'] = 0;
86  }
87 
88  return new BlockListPager( $this, $conds );
89  }
90 
96  protected function showTotal( BlockListPager $pager ) {
97  $out = $this->getOutput();
98  $out->addHTML(
99  Html::rawElement( 'div', [ 'style' => 'font-weight: bold;' ],
100  $this->msg( 'autoblocklist-total-autoblocks', $pager->getTotalAutoblocks() )->parse() )
101  . "\n"
102  );
103  }
104 
109  protected function showList( BlockListPager $pager ) {
110  $out = $this->getOutput();
111 
112  # Check for other blocks, i.e. global/tor blocks
113  $otherAutoblockLink = [];
114  Hooks::run( 'OtherAutoblockLogLink', [ &$otherAutoblockLink ] );
115 
116  # Show additional header for the local block only when other blocks exists.
117  # Not necessary in a standard installation without such extensions enabled
118  if ( count( $otherAutoblockLink ) ) {
119  $out->addHTML(
120  Html::rawElement( 'h2', [], $this->msg( 'autoblocklist-localblocks',
121  $pager->getNumRows() )->parse() )
122  . "\n"
123  );
124  }
125 
126  if ( $pager->getNumRows() ) {
127  $out->addParserOutputContent( $pager->getFullOutput() );
128  } else {
129  $out->addWikiMsg( 'autoblocklist-empty' );
130  }
131 
132  if ( count( $otherAutoblockLink ) ) {
133  $out->addHTML(
134  Html::rawElement(
135  'h2',
136  [],
137  $this->msg( 'autoblocklist-otherblocks', count( $otherAutoblockLink ) )->parse()
138  ) . "\n"
139  );
140  $list = '';
141  foreach ( $otherAutoblockLink as $link ) {
142  $list .= Html::rawElement( 'li', [], $link ) . "\n";
143  }
144  $out->addHTML(
145  Html::rawElement(
146  'ul',
147  [ 'class' => 'mw-autoblocklist-otherblocks' ],
148  $list
149  ) . "\n"
150  );
151  }
152  }
153 
154  protected function getGroupName() {
155  return 'users';
156  }
157 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:678
SpecialPage\msg
msg( $key)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:796
$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:2644
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:725
captcha-old.count
count
Definition: captcha-old.py:249
BlockListPager
Definition: BlockListPager.php:31
$out
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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:780
TablePager\getFullOutput
getFullOutput()
Get the formatted result list, with navigation bars.
Definition: TablePager.php:101
SpecialAutoblockList
A special page that lists autoblocks.
Definition: SpecialAutoblockList.php:30
SpecialAutoblockList\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialAutoblockList.php:154
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
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition: DerivativeContext.php:30
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:832
HTMLForm\factory
static factory( $displayFormat)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:286
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:531
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:735
SpecialAutoblockList\showTotal
showTotal(BlockListPager $pager)
Show total number of autoblocks on top of the table.
Definition: SpecialAutoblockList.php:96
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:698
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:36
SpecialAutoblockList\showList
showList(BlockListPager $pager)
Show the list of blocked accounts matching the actual filter.
Definition: SpecialAutoblockList.php:109
BlockListPager\getTotalAutoblocks
getTotalAutoblocks()
Get total number of autoblocks at any given time.
Definition: BlockListPager.php:363
SpecialAutoblockList\execute
execute( $par)
Definition: SpecialAutoblockList.php:39
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
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:3061
SpecialAutoblockList\__construct
__construct()
Definition: SpecialAutoblockList.php:32
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
SpecialAutoblockList\getBlockListPager
getBlockListPager()
Setup a new BlockListPager instance.
Definition: SpecialAutoblockList.php:79
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:633
IndexPager\getNumRows
getNumRows()
Get the number of rows in the result set.
Definition: IndexPager.php:600