MediaWiki REL1_40
SpecialAutoblockList.php
Go to the documentation of this file.
1<?php
32
40
42 private $linkBatchFactory;
43
45 private $blockRestrictionStore;
46
48 private $loadBalancer;
49
51 private $commentStore;
52
54 private $blockUtils;
55
57 private $blockActionInfo;
58
60 private $rowCommentFormatter;
61
71 public function __construct(
72 LinkBatchFactory $linkBatchFactory,
73 BlockRestrictionStore $blockRestrictionStore,
74 ILoadBalancer $loadBalancer,
75 CommentStore $commentStore,
76 BlockUtils $blockUtils,
77 BlockActionInfo $blockActionInfo,
78 RowCommentFormatter $rowCommentFormatter
79 ) {
80 parent::__construct( 'AutoblockList' );
81
82 $this->linkBatchFactory = $linkBatchFactory;
83 $this->blockRestrictionStore = $blockRestrictionStore;
84 $this->loadBalancer = $loadBalancer;
85 $this->commentStore = $commentStore;
86 $this->blockUtils = $blockUtils;
87 $this->blockActionInfo = $blockActionInfo;
88 $this->rowCommentFormatter = $rowCommentFormatter;
89 }
90
94 public function execute( $par ) {
95 $this->setHeaders();
96 $this->outputHeader();
97 $out = $this->getOutput();
98 $out->setPageTitle( $this->msg( 'autoblocklist' ) );
99 $this->addHelpLink( 'Autoblock' );
100 $out->addModuleStyles( [ 'mediawiki.special' ] );
101
102 # setup BlockListPager here to get the actual default Limit
103 $pager = $this->getBlockListPager();
104
105 # Just show the block list
106 $fields = [
107 'Limit' => [
108 'type' => 'limitselect',
109 'label-message' => 'table_pager_limit_label',
110 'options' => $pager->getLimitSelectList(),
111 'name' => 'limit',
112 'default' => $pager->getLimit(),
113 ]
114 ];
115
116 $form = HTMLForm::factory( 'ooui', $fields, $this->getContext() );
117 $form->setMethod( 'get' )
118 ->setTitle( $this->getPageTitle() ) // Remove subpage
119 ->setFormIdentifier( 'blocklist' )
120 ->setWrapperLegendMsg( 'autoblocklist-legend' )
121 ->setSubmitTextMsg( 'autoblocklist-submit' )
122 ->prepareForm()
123 ->displayForm( false );
124
125 $this->showTotal( $pager );
126 $this->showList( $pager );
127 }
128
133 protected function getBlockListPager() {
134 $conds = [
135 'ipb_parent_block_id IS NOT NULL',
136 // ipb_parent_block_id <> 0 because of T282890
137 'ipb_parent_block_id <> 0',
138 ];
139 # Is the user allowed to see hidden blocks?
140 if ( !$this->getAuthority()->isAllowed( 'hideuser' ) ) {
141 $conds['ipb_deleted'] = 0;
142 }
143
144 return new BlockListPager(
145 $this->getContext(),
146 $this->blockActionInfo,
147 $this->blockRestrictionStore,
148 $this->blockUtils,
149 $this->commentStore,
150 $this->linkBatchFactory,
151 $this->getLinkRenderer(),
152 $this->loadBalancer,
153 $this->rowCommentFormatter,
154 $this->getSpecialPageFactory(),
155 $conds
156 );
157 }
158
164 protected function showTotal( BlockListPager $pager ) {
165 $out = $this->getOutput();
166 $out->addHTML(
167 Html::rawElement( 'div', [ 'style' => 'font-weight: bold;' ],
168 $this->msg( 'autoblocklist-total-autoblocks', $pager->getTotalAutoblocks() )->parse() )
169 . "\n"
170 );
171 }
172
177 protected function showList( BlockListPager $pager ) {
178 $out = $this->getOutput();
179
180 # Check for other blocks, i.e. global/tor blocks
181 $otherAutoblockLink = [];
182 $this->getHookRunner()->onOtherAutoblockLogLink( $otherAutoblockLink );
183
184 # Show additional header for the local block only when other blocks exists.
185 # Not necessary in a standard installation without such extensions enabled
186 if ( count( $otherAutoblockLink ) ) {
187 $out->addHTML(
188 Html::rawElement( 'h2', [], $this->msg( 'autoblocklist-localblocks',
189 $pager->getNumRows() )->parse() )
190 . "\n"
191 );
192 }
193
194 if ( $pager->getNumRows() ) {
195 $out->addParserOutputContent( $pager->getFullOutput() );
196 } else {
197 $out->addWikiMsg( 'autoblocklist-empty' );
198 }
199
200 if ( count( $otherAutoblockLink ) ) {
201 $out->addHTML(
202 Html::rawElement(
203 'h2',
204 [],
205 $this->msg( 'autoblocklist-otherblocks', count( $otherAutoblockLink ) )->parse()
206 ) . "\n"
207 );
208 $list = '';
209 foreach ( $otherAutoblockLink as $link ) {
210 $list .= Html::rawElement( 'li', [], $link ) . "\n";
211 }
212 $out->addHTML(
213 Html::rawElement(
214 'ul',
215 [ 'class' => 'mw-autoblocklist-otherblocks' ],
216 $list
217 ) . "\n"
218 );
219 }
220 }
221
222 protected function getGroupName() {
223 return 'users';
224 }
225}
getTotalAutoblocks()
Get total number of autoblocks at any given time.
getNumRows()
Get the number of rows in the result set.
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:55
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.
__construct(LinkBatchFactory $linkBatchFactory, BlockRestrictionStore $blockRestrictionStore, ILoadBalancer $loadBalancer, CommentStore $commentStore, BlockUtils $blockUtils, BlockActionInfo $blockActionInfo, RowCommentFormatter $rowCommentFormatter)
showTotal(BlockListPager $pager)
Show total number of autoblocks on top of the table.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getAuthority()
Shortcut to get the Authority executing this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
getFullOutput()
Get the formatted result list, with navigation bars.
This class is a delegate to ILBFactory for a given database cluster.