MediaWiki  master
SpecialAutoblockList.php
Go to the documentation of this file.
1 <?php
29 
37 
40 
43 
45  private $loadBalancer;
46 
48  private $commentStore;
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(
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(
202  'ul',
203  [ 'class' => 'mw-autoblocklist-otherblocks' ],
204  $list
205  ) . "\n"
206  );
207  }
208  }
209 
210  protected function getGroupName() {
211  return 'users';
212  }
213 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:743
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:911
SpecialAutoblockList\$linkBatchFactory
LinkBatchFactory $linkBatchFactory
Definition: SpecialAutoblockList.php:39
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:789
BlockListPager
Definition: BlockListPager.php:39
SpecialAutoblockList\$blockUtils
BlockUtils $blockUtils
Definition: SpecialAutoblockList.php:51
MediaWiki\Block\BlockUtils
Backend class for blocking utils.
Definition: BlockUtils.php:45
SpecialAutoblockList\$blockRestrictionStore
BlockRestrictionStore $blockRestrictionStore
Definition: SpecialAutoblockList.php:42
CommentStore
Handle database storage of comments such as edit summaries and log reasons.
Definition: CommentStore.php:42
TablePager\getFullOutput
getFullOutput()
Get the formatted result list, with navigation bars.
Definition: TablePager.php:111
SpecialAutoblockList
A special page that lists autoblocks.
Definition: SpecialAutoblockList.php:36
SpecialPage\getAuthority
getAuthority()
Shortcut to get the Authority executing this instance.
Definition: SpecialPage.php:809
SpecialAutoblockList\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialAutoblockList.php:210
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition: DerivativeContext.php:33
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:947
SpecialPage\getHookRunner
getHookRunner()
Definition: SpecialPage.php:1094
MediaWiki\Cache\LinkBatchFactory
Definition: LinkBatchFactory.php:39
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:617
SpecialAutoblockList\showTotal
showTotal(BlockListPager $pager)
Show total number of autoblocks on top of the table.
Definition: SpecialAutoblockList.php:152
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:763
SpecialAutoblockList\$blockActionInfo
BlockActionInfo $blockActionInfo
Definition: SpecialAutoblockList.php:54
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:43
SpecialAutoblockList\showList
showList(BlockListPager $pager)
Show the list of blocked accounts matching the actual filter.
Definition: SpecialAutoblockList.php:165
BlockListPager\getTotalAutoblocks
getTotalAutoblocks()
Get total number of autoblocks at any given time.
Definition: BlockListPager.php:440
MediaWiki\Block\BlockActionInfo
Defines the actions that can be blocked by a partial block.
Definition: BlockActionInfo.php:40
SpecialAutoblockList\__construct
__construct(LinkBatchFactory $linkBatchFactory, BlockRestrictionStore $blockRestrictionStore, ILoadBalancer $loadBalancer, CommentStore $commentStore, BlockUtils $blockUtils, BlockActionInfo $blockActionInfo)
Definition: SpecialAutoblockList.php:64
SpecialAutoblockList\execute
execute( $par)
Definition: SpecialAutoblockList.php:85
SpecialPage\getSpecialPageFactory
getSpecialPageFactory()
Definition: SpecialPage.php:1114
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:212
SpecialAutoblockList\$loadBalancer
ILoadBalancer $loadBalancer
Definition: SpecialAutoblockList.php:45
SpecialAutoblockList\$commentStore
CommentStore $commentStore
Definition: SpecialAutoblockList.php:48
SpecialAutoblockList\getBlockListPager
getBlockListPager()
Setup a new BlockListPager instance.
Definition: SpecialAutoblockList.php:125
HTMLForm\factory
static factory( $displayFormat,... $arguments)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:327
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:708
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81
IndexPager\getNumRows
getNumRows()
Get the number of rows in the result set.
Definition: IndexPager.php:731
MediaWiki\Block\BlockRestrictionStore
Definition: BlockRestrictionStore.php:35