MediaWiki  master
SpecialAutoblockList.php
Go to the documentation of this file.
1 <?php
29 
37 
39  private $permManager;
40 
43 
46 
48  private $loadBalancer;
49 
52 
54  private $actorMigration;
55 
57  private $commentStore;
58 
68  public function __construct(
76  ) {
77  parent::__construct( 'AutoblockList' );
78 
79  $this->permManager = $permManager;
80  $this->linkBatchFactory = $linkBatchFactory;
81  $this->blockRestrictionStore = $blockRestrictionStore;
82  $this->loadBalancer = $loadBalancer;
83  $this->specialPageFactory = $specialPageFactory;
84  $this->actorMigration = $actorMigration;
85  $this->commentStore = $commentStore;
86  }
87 
91  public function execute( $par ) {
92  $this->setHeaders();
93  $this->outputHeader();
94  $out = $this->getOutput();
95  $out->setPageTitle( $this->msg( 'autoblocklist' ) );
96  $this->addHelpLink( 'Autoblock' );
97  $out->addModuleStyles( [ 'mediawiki.special' ] );
98 
99  # setup BlockListPager here to get the actual default Limit
100  $pager = $this->getBlockListPager();
101 
102  # Just show the block list
103  $fields = [
104  'Limit' => [
105  'type' => 'limitselect',
106  'label-message' => 'table_pager_limit_label',
107  'options' => $pager->getLimitSelectList(),
108  'name' => 'limit',
109  'default' => $pager->getLimit(),
110  ]
111  ];
112 
113  $context = new DerivativeContext( $this->getContext() );
114  $context->setTitle( $this->getPageTitle() ); // Remove subpage
115  $form = HTMLForm::factory( 'ooui', $fields, $context );
116  $form->setMethod( 'get' )
117  ->setFormIdentifier( 'blocklist' )
118  ->setWrapperLegendMsg( 'autoblocklist-legend' )
119  ->setSubmitTextMsg( 'autoblocklist-submit' )
120  ->prepareForm()
121  ->displayForm( false );
122 
123  $this->showTotal( $pager );
124  $this->showList( $pager );
125  }
126 
131  protected function getBlockListPager() {
132  $conds = [
133  'ipb_parent_block_id IS NOT NULL'
134  ];
135  # Is the user allowed to see hidden blocks?
136  if ( !$this->permManager->userHasRight( $this->getUser(), 'hideuser' ) ) {
137  $conds['ipb_deleted'] = 0;
138  }
139 
140  return new BlockListPager(
141  $this,
142  $conds,
143  $this->linkBatchFactory,
144  $this->blockRestrictionStore,
145  $this->permManager,
146  $this->loadBalancer,
147  $this->specialPageFactory,
148  $this->actorMigration,
149  $this->commentStore
150  );
151  }
152 
158  protected function showTotal( BlockListPager $pager ) {
159  $out = $this->getOutput();
160  $out->addHTML(
161  Html::rawElement( 'div', [ 'style' => 'font-weight: bold;' ],
162  $this->msg( 'autoblocklist-total-autoblocks', $pager->getTotalAutoblocks() )->parse() )
163  . "\n"
164  );
165  }
166 
171  protected function showList( BlockListPager $pager ) {
172  $out = $this->getOutput();
173 
174  # Check for other blocks, i.e. global/tor blocks
175  $otherAutoblockLink = [];
176  $this->getHookRunner()->onOtherAutoblockLogLink( $otherAutoblockLink );
177 
178  # Show additional header for the local block only when other blocks exists.
179  # Not necessary in a standard installation without such extensions enabled
180  if ( count( $otherAutoblockLink ) ) {
181  $out->addHTML(
182  Html::rawElement( 'h2', [], $this->msg( 'autoblocklist-localblocks',
183  $pager->getNumRows() )->parse() )
184  . "\n"
185  );
186  }
187 
188  if ( $pager->getNumRows() ) {
189  $out->addParserOutputContent( $pager->getFullOutput() );
190  } else {
191  $out->addWikiMsg( 'autoblocklist-empty' );
192  }
193 
194  if ( count( $otherAutoblockLink ) ) {
195  $out->addHTML(
197  'h2',
198  [],
199  $this->msg( 'autoblocklist-otherblocks', count( $otherAutoblockLink ) )->parse()
200  ) . "\n"
201  );
202  $list = '';
203  foreach ( $otherAutoblockLink as $link ) {
204  $list .= Html::rawElement( 'li', [], $link ) . "\n";
205  }
206  $out->addHTML(
208  'ul',
209  [ 'class' => 'mw-autoblocklist-otherblocks' ],
210  $list
211  ) . "\n"
212  );
213  }
214  }
215 
216  protected function getGroupName() {
217  return 'users';
218  }
219 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:697
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:827
SpecialAutoblockList\$linkBatchFactory
LinkBatchFactory $linkBatchFactory
Definition: SpecialAutoblockList.php:42
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:743
BlockListPager
Definition: BlockListPager.php:38
MediaWiki\SpecialPage\SpecialPageFactory
Factory for handling the special page list and generating SpecialPage objects.
Definition: SpecialPageFactory.php:61
SpecialAutoblockList\$blockRestrictionStore
BlockRestrictionStore $blockRestrictionStore
Definition: SpecialAutoblockList.php:45
SpecialAutoblockList\$specialPageFactory
SpecialPageFactory $specialPageFactory
Definition: SpecialAutoblockList.php:51
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
SpecialAutoblockList\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialAutoblockList.php:216
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:31
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:863
SpecialPage\getHookRunner
getHookRunner()
Definition: SpecialPage.php:1010
SpecialAutoblockList\__construct
__construct(PermissionManager $permManager, LinkBatchFactory $linkBatchFactory, BlockRestrictionStore $blockRestrictionStore, ILoadBalancer $loadBalancer, SpecialPageFactory $specialPageFactory, ActorMigration $actorMigration, CommentStore $commentStore)
Definition: SpecialAutoblockList.php:68
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:571
SpecialAutoblockList\showTotal
showTotal(BlockListPager $pager)
Show total number of autoblocks on top of the table.
Definition: SpecialAutoblockList.php:158
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:717
MediaWiki\Permissions\PermissionManager
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
Definition: PermissionManager.php:50
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:41
SpecialAutoblockList\$actorMigration
ActorMigration $actorMigration
Definition: SpecialAutoblockList.php:54
SpecialAutoblockList\showList
showList(BlockListPager $pager)
Show the list of blocked accounts matching the actual filter.
Definition: SpecialAutoblockList.php:171
BlockListPager\getTotalAutoblocks
getTotalAutoblocks()
Get total number of autoblocks at any given time.
Definition: BlockListPager.php:426
SpecialAutoblockList\$permManager
PermissionManager $permManager
Definition: SpecialAutoblockList.php:39
SpecialAutoblockList\execute
execute( $par)
Definition: SpecialAutoblockList.php:91
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
SpecialAutoblockList\$loadBalancer
ILoadBalancer $loadBalancer
Definition: SpecialAutoblockList.php:48
SpecialAutoblockList\$commentStore
CommentStore $commentStore
Definition: SpecialAutoblockList.php:57
SpecialAutoblockList\getBlockListPager
getBlockListPager()
Setup a new BlockListPager instance.
Definition: SpecialAutoblockList.php:131
HTMLForm\factory
static factory( $displayFormat,... $arguments)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:315
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:662
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