MediaWiki REL1_41
SpecialAutoblockList.php
Go to the documentation of this file.
1<?php
24namespace MediaWiki\Specials;
25
26use HTMLForm;
37
45
46 private LinkBatchFactory $linkBatchFactory;
47 private BlockRestrictionStore $blockRestrictionStore;
48 private IConnectionProvider $dbProvider;
49 private CommentStore $commentStore;
50 private BlockUtils $blockUtils;
51 private BlockActionInfo $blockActionInfo;
52 private RowCommentFormatter $rowCommentFormatter;
53
63 public function __construct(
64 LinkBatchFactory $linkBatchFactory,
65 BlockRestrictionStore $blockRestrictionStore,
66 IConnectionProvider $dbProvider,
67 CommentStore $commentStore,
68 BlockUtils $blockUtils,
69 BlockActionInfo $blockActionInfo,
70 RowCommentFormatter $rowCommentFormatter
71 ) {
72 parent::__construct( 'AutoblockList' );
73
74 $this->linkBatchFactory = $linkBatchFactory;
75 $this->blockRestrictionStore = $blockRestrictionStore;
76 $this->dbProvider = $dbProvider;
77 $this->commentStore = $commentStore;
78 $this->blockUtils = $blockUtils;
79 $this->blockActionInfo = $blockActionInfo;
80 $this->rowCommentFormatter = $rowCommentFormatter;
81 }
82
86 public function execute( $par ) {
87 $this->setHeaders();
88 $this->outputHeader();
89 $out = $this->getOutput();
90 $out->setPageTitleMsg( $this->msg( 'autoblocklist' ) );
91 $this->addHelpLink( 'Autoblock' );
92 $out->addModuleStyles( [ 'mediawiki.special' ] );
93
94 # setup BlockListPager here to get the actual default Limit
95 $pager = $this->getBlockListPager();
96
97 # Just show the block list
98 $fields = [
99 'Limit' => [
100 'type' => 'limitselect',
101 'label-message' => 'table_pager_limit_label',
102 'options' => $pager->getLimitSelectList(),
103 'name' => 'limit',
104 'default' => $pager->getLimit(),
105 ]
106 ];
107
108 $form = HTMLForm::factory( 'ooui', $fields, $this->getContext() );
109 $form->setMethod( 'get' )
110 ->setTitle( $this->getPageTitle() ) // Remove subpage
111 ->setFormIdentifier( 'blocklist' )
112 ->setWrapperLegendMsg( 'autoblocklist-legend' )
113 ->setSubmitTextMsg( 'autoblocklist-submit' )
114 ->prepareForm()
115 ->displayForm( false );
116
117 $this->showTotal( $pager );
118 $this->showList( $pager );
119 }
120
125 protected function getBlockListPager() {
126 $conds = [
127 'ipb_parent_block_id IS NOT NULL',
128 // ipb_parent_block_id <> 0 because of T282890
129 'ipb_parent_block_id <> 0',
130 ];
131 # Is the user allowed to see hidden blocks?
132 if ( !$this->getAuthority()->isAllowed( 'hideuser' ) ) {
133 $conds['ipb_deleted'] = 0;
134 }
135
136 return new BlockListPager(
137 $this->getContext(),
138 $this->blockActionInfo,
139 $this->blockRestrictionStore,
140 $this->blockUtils,
141 $this->commentStore,
142 $this->linkBatchFactory,
143 $this->getLinkRenderer(),
144 $this->dbProvider,
145 $this->rowCommentFormatter,
146 $this->getSpecialPageFactory(),
147 $conds
148 );
149 }
150
156 protected function showTotal( BlockListPager $pager ) {
157 $out = $this->getOutput();
158 $out->addHTML(
159 Html::rawElement( 'div', [ 'style' => 'font-weight: bold;' ],
160 $this->msg( 'autoblocklist-total-autoblocks', $pager->getTotalAutoblocks() )->parse() )
161 . "\n"
162 );
163 }
164
169 protected function showList( BlockListPager $pager ) {
170 $out = $this->getOutput();
171
172 # Check for other blocks, i.e. global/tor blocks
173 $otherAutoblockLink = [];
174 $this->getHookRunner()->onOtherAutoblockLogLink( $otherAutoblockLink );
175
176 # Show additional header for the local block only when other blocks exists.
177 # Not necessary in a standard installation without such extensions enabled
178 if ( count( $otherAutoblockLink ) ) {
179 $out->addHTML(
180 Html::rawElement( 'h2', [], $this->msg( 'autoblocklist-localblocks',
181 $pager->getNumRows() )->parse() )
182 . "\n"
183 );
184 }
185
186 if ( $pager->getNumRows() ) {
187 $out->addParserOutputContent( $pager->getFullOutput() );
188 } else {
189 $out->addWikiMsg( 'autoblocklist-empty' );
190 }
191
192 if ( count( $otherAutoblockLink ) ) {
193 $out->addHTML(
194 Html::rawElement(
195 'h2',
196 [],
197 $this->msg( 'autoblocklist-otherblocks', count( $otherAutoblockLink ) )->parse()
198 ) . "\n"
199 );
200 $list = '';
201 foreach ( $otherAutoblockLink as $link ) {
202 $list .= Html::rawElement( 'li', [], $link ) . "\n";
203 }
204 $out->addHTML(
205 Html::rawElement(
206 'ul',
207 [ 'class' => 'mw-autoblocklist-otherblocks' ],
208 $list
209 ) . "\n"
210 );
211 }
212 }
213
214 protected function getGroupName() {
215 return 'users';
216 }
217}
218
222class_alias( SpecialAutoblockList::class, 'SpecialAutoblockList' );
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition HTMLForm.php:158
Defines the actions that can be blocked by a partial block.
Backend class for blocking utils.
This is basically a CommentFormatter with a CommentStore dependency, allowing it to retrieve comment ...
Handle database storage of comments such as edit summaries and log reasons.
This class is a collection of static functions that serve two purposes:
Definition Html.php:57
getTotalAutoblocks()
Get total number of autoblocks at any given time.
getNumRows()
Get the number of rows in the result set.
getFullOutput()
Get the formatted result list, with navigation bars.
Parent class for all special pages.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getPageTitle( $subpage=false)
Get a self-referential title object.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
getAuthority()
Shortcut to get the Authority executing this instance.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
A special page that lists autoblocks.
getBlockListPager()
Setup a new BlockListPager instance.
showList(BlockListPager $pager)
Show the list of blocked accounts matching the actual filter.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
__construct(LinkBatchFactory $linkBatchFactory, BlockRestrictionStore $blockRestrictionStore, IConnectionProvider $dbProvider, CommentStore $commentStore, BlockUtils $blockUtils, BlockActionInfo $blockActionInfo, RowCommentFormatter $rowCommentFormatter)
showTotal(BlockListPager $pager)
Show total number of autoblocks on top of the table.
Provide primary and replica IDatabase connections.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...