MediaWiki  master
SpecialAutoblockList.php
Go to the documentation of this file.
1 <?php
28 
36 
39 
42 
44  private $loadBalancer;
45 
47  private $actorMigration;
48 
50  private $commentStore;
51 
53  private $blockUtils;
54 
63  public function __construct(
70  ) {
71  parent::__construct( 'AutoblockList' );
72 
73  $this->linkBatchFactory = $linkBatchFactory;
74  $this->blockRestrictionStore = $blockRestrictionStore;
75  $this->loadBalancer = $loadBalancer;
76  $this->actorMigration = $actorMigration;
77  $this->commentStore = $commentStore;
78  $this->blockUtils = $blockUtils;
79  }
80 
84  public function execute( $par ) {
85  $this->setHeaders();
86  $this->outputHeader();
87  $out = $this->getOutput();
88  $out->setPageTitle( $this->msg( 'autoblocklist' ) );
89  $this->addHelpLink( 'Autoblock' );
90  $out->addModuleStyles( [ 'mediawiki.special' ] );
91 
92  # setup BlockListPager here to get the actual default Limit
93  $pager = $this->getBlockListPager();
94 
95  # Just show the block list
96  $fields = [
97  'Limit' => [
98  'type' => 'limitselect',
99  'label-message' => 'table_pager_limit_label',
100  'options' => $pager->getLimitSelectList(),
101  'name' => 'limit',
102  'default' => $pager->getLimit(),
103  ]
104  ];
105 
106  $context = new DerivativeContext( $this->getContext() );
107  $context->setTitle( $this->getPageTitle() ); // Remove subpage
108  $form = HTMLForm::factory( 'ooui', $fields, $context );
109  $form->setMethod( 'get' )
110  ->setFormIdentifier( 'blocklist' )
111  ->setWrapperLegendMsg( 'autoblocklist-legend' )
112  ->setSubmitTextMsg( 'autoblocklist-submit' )
113  ->prepareForm()
114  ->displayForm( false );
115 
116  $this->showTotal( $pager );
117  $this->showList( $pager );
118  }
119 
124  protected function getBlockListPager() {
125  $conds = [
126  'ipb_parent_block_id IS NOT NULL'
127  ];
128  # Is the user allowed to see hidden blocks?
129  if ( !$this->getAuthority()->isAllowed( 'hideuser' ) ) {
130  $conds['ipb_deleted'] = 0;
131  }
132 
133  return new BlockListPager(
134  $this,
135  $conds,
136  $this->linkBatchFactory,
137  $this->blockRestrictionStore,
138  $this->loadBalancer,
139  $this->getSpecialPageFactory(),
140  $this->actorMigration,
141  $this->commentStore,
142  $this->blockUtils
143  );
144  }
145 
151  protected function showTotal( BlockListPager $pager ) {
152  $out = $this->getOutput();
153  $out->addHTML(
154  Html::rawElement( 'div', [ 'style' => 'font-weight: bold;' ],
155  $this->msg( 'autoblocklist-total-autoblocks', $pager->getTotalAutoblocks() )->parse() )
156  . "\n"
157  );
158  }
159 
164  protected function showList( BlockListPager $pager ) {
165  $out = $this->getOutput();
166 
167  # Check for other blocks, i.e. global/tor blocks
168  $otherAutoblockLink = [];
169  $this->getHookRunner()->onOtherAutoblockLogLink( $otherAutoblockLink );
170 
171  # Show additional header for the local block only when other blocks exists.
172  # Not necessary in a standard installation without such extensions enabled
173  if ( count( $otherAutoblockLink ) ) {
174  $out->addHTML(
175  Html::rawElement( 'h2', [], $this->msg( 'autoblocklist-localblocks',
176  $pager->getNumRows() )->parse() )
177  . "\n"
178  );
179  }
180 
181  if ( $pager->getNumRows() ) {
182  $out->addParserOutputContent( $pager->getFullOutput() );
183  } else {
184  $out->addWikiMsg( 'autoblocklist-empty' );
185  }
186 
187  if ( count( $otherAutoblockLink ) ) {
188  $out->addHTML(
190  'h2',
191  [],
192  $this->msg( 'autoblocklist-otherblocks', count( $otherAutoblockLink ) )->parse()
193  ) . "\n"
194  );
195  $list = '';
196  foreach ( $otherAutoblockLink as $link ) {
197  $list .= Html::rawElement( 'li', [], $link ) . "\n";
198  }
199  $out->addHTML(
201  'ul',
202  [ 'class' => 'mw-autoblocklist-otherblocks' ],
203  $list
204  ) . "\n"
205  );
206  }
207  }
208 
209  protected function getGroupName() {
210  return 'users';
211  }
212 }
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:38
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:789
BlockListPager
Definition: BlockListPager.php:37
SpecialAutoblockList\$blockUtils
BlockUtils $blockUtils
Definition: SpecialAutoblockList.php:53
MediaWiki\Block\BlockUtils
Backend class for blocking utils.
Definition: BlockUtils.php:44
SpecialAutoblockList\$blockRestrictionStore
BlockRestrictionStore $blockRestrictionStore
Definition: SpecialAutoblockList.php:41
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\__construct
__construct(LinkBatchFactory $linkBatchFactory, BlockRestrictionStore $blockRestrictionStore, ILoadBalancer $loadBalancer, ActorMigration $actorMigration, CommentStore $commentStore, BlockUtils $blockUtils)
Definition: SpecialAutoblockList.php:63
SpecialAutoblockList
A special page that lists autoblocks.
Definition: SpecialAutoblockList.php:35
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:209
ActorMigration
This class handles the logic for the actor table migration and should always be used in lieu of direc...
Definition: ActorMigration.php:41
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:947
SpecialPage\getHookRunner
getHookRunner()
Definition: SpecialPage.php:1094
MediaWiki\Cache\LinkBatchFactory
Definition: LinkBatchFactory.php:38
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:151
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:763
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:43
SpecialAutoblockList\$actorMigration
ActorMigration $actorMigration
Definition: SpecialAutoblockList.php:47
SpecialAutoblockList\showList
showList(BlockListPager $pager)
Show the list of blocked accounts matching the actual filter.
Definition: SpecialAutoblockList.php:164
BlockListPager\getTotalAutoblocks
getTotalAutoblocks()
Get total number of autoblocks at any given time.
Definition: BlockListPager.php:425
SpecialAutoblockList\execute
execute( $par)
Definition: SpecialAutoblockList.php:84
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:44
SpecialAutoblockList\$commentStore
CommentStore $commentStore
Definition: SpecialAutoblockList.php:50
SpecialAutoblockList\getBlockListPager
getBlockListPager()
Setup a new BlockListPager instance.
Definition: SpecialAutoblockList.php:124
HTMLForm\factory
static factory( $displayFormat,... $arguments)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:322
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:34