MediaWiki REL1_37
SpecialAutoblockList.php
Go to the documentation of this file.
1<?php
29
37
40
43
46
49
51 private $blockUtils;
52
55
64 public function __construct(
71 ) {
72 parent::__construct( 'AutoblockList' );
73
74 $this->linkBatchFactory = $linkBatchFactory;
75 $this->blockRestrictionStore = $blockRestrictionStore;
76 $this->loadBalancer = $loadBalancer;
77 $this->commentStore = $commentStore;
78 $this->blockUtils = $blockUtils;
79 $this->blockActionInfo = $blockActionInfo;
80 }
81
85 public function execute( $par ) {
86 $this->setHeaders();
87 $this->outputHeader();
88 $out = $this->getOutput();
89 $out->setPageTitle( $this->msg( 'autoblocklist' ) );
90 $this->addHelpLink( 'Autoblock' );
91 $out->addModuleStyles( [ 'mediawiki.special' ] );
92
93 # setup BlockListPager here to get the actual default Limit
94 $pager = $this->getBlockListPager();
95
96 # Just show the block list
97 $fields = [
98 'Limit' => [
99 'type' => 'limitselect',
100 'label-message' => 'table_pager_limit_label',
101 'options' => $pager->getLimitSelectList(),
102 'name' => 'limit',
103 'default' => $pager->getLimit(),
104 ]
105 ];
106
107 $context = new DerivativeContext( $this->getContext() );
108 $context->setTitle( $this->getPageTitle() ); // Remove subpage
109 $form = HTMLForm::factory( 'ooui', $fields, $context );
110 $form->setMethod( 'get' )
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 ];
129 # Is the user allowed to see hidden blocks?
130 if ( !$this->getAuthority()->isAllowed( 'hideuser' ) ) {
131 $conds['ipb_deleted'] = 0;
132 }
133
134 return new BlockListPager(
135 $this,
136 $conds,
137 $this->linkBatchFactory,
138 $this->blockRestrictionStore,
139 $this->loadBalancer,
140 $this->getSpecialPageFactory(),
141 $this->commentStore,
142 $this->blockUtils,
143 $this->blockActionInfo
144 );
145 }
146
152 protected function showTotal( BlockListPager $pager ) {
153 $out = $this->getOutput();
154 $out->addHTML(
155 Html::rawElement( 'div', [ 'style' => 'font-weight: bold;' ],
156 $this->msg( 'autoblocklist-total-autoblocks', $pager->getTotalAutoblocks() )->parse() )
157 . "\n"
158 );
159 }
160
165 protected function showList( BlockListPager $pager ) {
166 $out = $this->getOutput();
167
168 # Check for other blocks, i.e. global/tor blocks
169 $otherAutoblockLink = [];
170 $this->getHookRunner()->onOtherAutoblockLogLink( $otherAutoblockLink );
171
172 # Show additional header for the local block only when other blocks exists.
173 # Not necessary in a standard installation without such extensions enabled
174 if ( count( $otherAutoblockLink ) ) {
175 $out->addHTML(
176 Html::rawElement( 'h2', [], $this->msg( 'autoblocklist-localblocks',
177 $pager->getNumRows() )->parse() )
178 . "\n"
179 );
180 }
181
182 if ( $pager->getNumRows() ) {
183 $out->addParserOutputContent( $pager->getFullOutput() );
184 } else {
185 $out->addWikiMsg( 'autoblocklist-empty' );
186 }
187
188 if ( count( $otherAutoblockLink ) ) {
189 $out->addHTML(
190 Html::rawElement(
191 'h2',
192 [],
193 $this->msg( 'autoblocklist-otherblocks', count( $otherAutoblockLink ) )->parse()
194 ) . "\n"
195 );
196 $list = '';
197 foreach ( $otherAutoblockLink as $link ) {
198 $list .= Html::rawElement( 'li', [], $link ) . "\n";
199 }
200 $out->addHTML(
201 Html::rawElement(
202 'ul',
203 [ 'class' => 'mw-autoblocklist-otherblocks' ],
204 $list
205 ) . "\n"
206 );
207 }
208 }
209
210 protected function getGroupName() {
211 return 'users';
212 }
213}
getTotalAutoblocks()
Get total number of autoblocks at any given time.
Handle database storage of comments such as edit summaries and log reasons.
An IContextSource implementation which will inherit context from another source but allow individual ...
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.
A special page that lists autoblocks.
__construct(LinkBatchFactory $linkBatchFactory, BlockRestrictionStore $blockRestrictionStore, ILoadBalancer $loadBalancer, CommentStore $commentStore, BlockUtils $blockUtils, BlockActionInfo $blockActionInfo)
getBlockListPager()
Setup a new BlockListPager instance.
showList(BlockListPager $pager)
Show the list of blocked accounts matching the actual filter.
BlockActionInfo $blockActionInfo
BlockRestrictionStore $blockRestrictionStore
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...
LinkBatchFactory $linkBatchFactory
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.
Database cluster connection, tracking, load balancing, and transaction manager interface.