MediaWiki  master
SpecialAutoblockList.php
Go to the documentation of this file.
1 <?php
30 
38 
41 
44 
46  private $loadBalancer;
47 
49  private $commentStore;
50 
52  private $blockUtils;
53 
56 
59 
69  public function __construct(
77  ) {
78  parent::__construct( 'AutoblockList' );
79 
80  $this->linkBatchFactory = $linkBatchFactory;
81  $this->blockRestrictionStore = $blockRestrictionStore;
82  $this->loadBalancer = $loadBalancer;
83  $this->commentStore = $commentStore;
84  $this->blockUtils = $blockUtils;
85  $this->blockActionInfo = $blockActionInfo;
86  $this->rowCommentFormatter = $rowCommentFormatter;
87  }
88 
92  public function execute( $par ) {
93  $this->setHeaders();
94  $this->outputHeader();
95  $out = $this->getOutput();
96  $out->setPageTitle( $this->msg( 'autoblocklist' ) );
97  $this->addHelpLink( 'Autoblock' );
98  $out->addModuleStyles( [ 'mediawiki.special' ] );
99 
100  # setup BlockListPager here to get the actual default Limit
101  $pager = $this->getBlockListPager();
102 
103  # Just show the block list
104  $fields = [
105  'Limit' => [
106  'type' => 'limitselect',
107  'label-message' => 'table_pager_limit_label',
108  'options' => $pager->getLimitSelectList(),
109  'name' => 'limit',
110  'default' => $pager->getLimit(),
111  ]
112  ];
113 
114  $context = new DerivativeContext( $this->getContext() );
115  $context->setTitle( $this->getPageTitle() ); // Remove subpage
116  $form = HTMLForm::factory( 'ooui', $fields, $context );
117  $form->setMethod( 'get' )
118  ->setFormIdentifier( 'blocklist' )
119  ->setWrapperLegendMsg( 'autoblocklist-legend' )
120  ->setSubmitTextMsg( 'autoblocklist-submit' )
121  ->prepareForm()
122  ->displayForm( false );
123 
124  $this->showTotal( $pager );
125  $this->showList( $pager );
126  }
127 
132  protected function getBlockListPager() {
133  $conds = [
134  'ipb_parent_block_id IS NOT NULL'
135  ];
136  # Is the user allowed to see hidden blocks?
137  if ( !$this->getAuthority()->isAllowed( 'hideuser' ) ) {
138  $conds['ipb_deleted'] = 0;
139  }
140 
141  return new BlockListPager(
142  $this,
143  $conds,
144  $this->linkBatchFactory,
145  $this->blockRestrictionStore,
146  $this->loadBalancer,
147  $this->getSpecialPageFactory(),
148  $this->commentStore,
149  $this->blockUtils,
150  $this->blockActionInfo,
151  $this->rowCommentFormatter
152  );
153  }
154 
160  protected function showTotal( BlockListPager $pager ) {
161  $out = $this->getOutput();
162  $out->addHTML(
163  Html::rawElement( 'div', [ 'style' => 'font-weight: bold;' ],
164  $this->msg( 'autoblocklist-total-autoblocks', $pager->getTotalAutoblocks() )->parse() )
165  . "\n"
166  );
167  }
168 
173  protected function showList( BlockListPager $pager ) {
174  $out = $this->getOutput();
175 
176  # Check for other blocks, i.e. global/tor blocks
177  $otherAutoblockLink = [];
178  $this->getHookRunner()->onOtherAutoblockLogLink( $otherAutoblockLink );
179 
180  # Show additional header for the local block only when other blocks exists.
181  # Not necessary in a standard installation without such extensions enabled
182  if ( count( $otherAutoblockLink ) ) {
183  $out->addHTML(
184  Html::rawElement( 'h2', [], $this->msg( 'autoblocklist-localblocks',
185  $pager->getNumRows() )->parse() )
186  . "\n"
187  );
188  }
189 
190  if ( $pager->getNumRows() ) {
191  $out->addParserOutputContent( $pager->getFullOutput() );
192  } else {
193  $out->addWikiMsg( 'autoblocklist-empty' );
194  }
195 
196  if ( count( $otherAutoblockLink ) ) {
197  $out->addHTML(
199  'h2',
200  [],
201  $this->msg( 'autoblocklist-otherblocks', count( $otherAutoblockLink ) )->parse()
202  ) . "\n"
203  );
204  $list = '';
205  foreach ( $otherAutoblockLink as $link ) {
206  $list .= Html::rawElement( 'li', [], $link ) . "\n";
207  }
208  $out->addHTML(
210  'ul',
211  [ 'class' => 'mw-autoblocklist-otherblocks' ],
212  $list
213  ) . "\n"
214  );
215  }
216  }
217 
218  protected function getGroupName() {
219  return 'users';
220  }
221 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:744
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:912
SpecialAutoblockList\$linkBatchFactory
LinkBatchFactory $linkBatchFactory
Definition: SpecialAutoblockList.php:40
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:790
BlockListPager
Definition: BlockListPager.php:40
SpecialAutoblockList\$blockUtils
BlockUtils $blockUtils
Definition: SpecialAutoblockList.php:52
MediaWiki\Block\BlockUtils
Backend class for blocking utils.
Definition: BlockUtils.php:45
SpecialAutoblockList\$blockRestrictionStore
BlockRestrictionStore $blockRestrictionStore
Definition: SpecialAutoblockList.php:43
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:37
SpecialPage\getAuthority
getAuthority()
Shortcut to get the Authority executing this instance.
Definition: SpecialPage.php:810
SpecialAutoblockList\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialAutoblockList.php:218
SpecialAutoblockList\__construct
__construct(LinkBatchFactory $linkBatchFactory, BlockRestrictionStore $blockRestrictionStore, ILoadBalancer $loadBalancer, CommentStore $commentStore, BlockUtils $blockUtils, BlockActionInfo $blockActionInfo, RowCommentFormatter $rowCommentFormatter)
Definition: SpecialAutoblockList.php:69
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition: DerivativeContext.php:32
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:948
SpecialPage\getHookRunner
getHookRunner()
Definition: SpecialPage.php:1095
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:618
SpecialAutoblockList\showTotal
showTotal(BlockListPager $pager)
Show total number of autoblocks on top of the table.
Definition: SpecialAutoblockList.php:160
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:764
SpecialAutoblockList\$blockActionInfo
BlockActionInfo $blockActionInfo
Definition: SpecialAutoblockList.php:55
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:173
BlockListPager\getTotalAutoblocks
getTotalAutoblocks()
Get total number of autoblocks at any given time.
Definition: BlockListPager.php:449
MediaWiki\Block\BlockActionInfo
Defines the actions that can be blocked by a partial block.
Definition: BlockActionInfo.php:40
SpecialAutoblockList\execute
execute( $par)
Definition: SpecialAutoblockList.php:92
MediaWiki\CommentFormatter\RowCommentFormatter
This is basically a CommentFormatter with a CommentStore dependency, allowing it to retrieve comment ...
Definition: RowCommentFormatter.php:15
SpecialAutoblockList\$rowCommentFormatter
RowCommentFormatter $rowCommentFormatter
Definition: SpecialAutoblockList.php:58
SpecialPage\getSpecialPageFactory
getSpecialPageFactory()
Definition: SpecialPage.php:1115
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:210
SpecialAutoblockList\$loadBalancer
ILoadBalancer $loadBalancer
Definition: SpecialAutoblockList.php:46
SpecialAutoblockList\$commentStore
CommentStore $commentStore
Definition: SpecialAutoblockList.php:49
SpecialAutoblockList\getBlockListPager
getBlockListPager()
Setup a new BlockListPager instance.
Definition: SpecialAutoblockList.php:132
HTMLForm\factory
static factory( $displayFormat,... $arguments)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:326
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:709
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:742
MediaWiki\Block\BlockRestrictionStore
Definition: BlockRestrictionStore.php:35