MediaWiki master
SpecialAutoblockList.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Specials;
8
18use MediaWiki\Pager\BlockListPager;
22
30
31 public function __construct(
32 private readonly LinkBatchFactory $linkBatchFactory,
33 private readonly BlockRestrictionStore $blockRestrictionStore,
34 private readonly IConnectionProvider $dbProvider,
35 private readonly CommentStore $commentStore,
36 private readonly BlockTargetFactory $blockTargetFactory,
37 private readonly HideUserUtils $hideUserUtils,
38 private readonly BlockActionInfo $blockActionInfo,
39 private readonly RowCommentFormatter $rowCommentFormatter
40 ) {
41 parent::__construct( 'AutoblockList' );
42 }
43
47 public function execute( $par ) {
48 $this->setHeaders();
49 $this->outputHeader();
50 $out = $this->getOutput();
51 $out->setPageTitleMsg( $this->msg( 'autoblocklist' ) );
52 $this->addHelpLink( 'Autoblock' );
53 $out->addModuleStyles( [ 'mediawiki.special' ] );
54
55 # setup BlockListPager here to get the actual default Limit
56 $pager = $this->getBlockListPager();
57
58 # Just show the block list
59 $fields = [
60 'Limit' => [
61 'type' => 'limitselect',
62 'label-message' => 'table_pager_limit_label',
63 'options' => $pager->getLimitSelectList(),
64 'name' => 'limit',
65 'default' => $pager->getLimit(),
66 ]
67 ];
68
69 $form = HTMLForm::factory( 'ooui', $fields, $this->getContext() );
70 $form->setMethod( 'get' )
71 ->setTitle( $this->getPageTitle() ) // Remove subpage
72 ->setFormIdentifier( 'blocklist' )
73 ->setWrapperLegendMsg( 'autoblocklist-legend' )
74 ->setSubmitTextMsg( 'autoblocklist-submit' )
75 ->prepareForm()
76 ->displayForm( false );
77
78 $this->showList( $pager );
79 }
80
85 protected function getBlockListPager() {
86 $conds = [
87 $this->dbProvider->getReplicaDatabase()->expr( 'bl_parent_block_id', '!=', null ),
88 ];
89 # Is the user allowed to see hidden blocks?
90 if ( !$this->getAuthority()->isAllowed( 'hideuser' ) ) {
91 $conds['bl_deleted'] = 0;
92 }
93
94 return new BlockListPager(
95 $this->getContext(),
96 $this->blockActionInfo,
97 $this->blockRestrictionStore,
98 $this->blockTargetFactory,
99 $this->hideUserUtils,
100 $this->commentStore,
101 $this->linkBatchFactory,
102 $this->getLinkRenderer(),
103 $this->dbProvider,
104 $this->rowCommentFormatter,
105 $this->getSpecialPageFactory(),
106 $conds
107 );
108 }
109
114 protected function showList( BlockListPager $pager ) {
115 $out = $this->getOutput();
116
117 # Check for other blocks, i.e. global/tor blocks
118 $otherAutoblockLink = [];
119 $this->getHookRunner()->onOtherAutoblockLogLink( $otherAutoblockLink );
120
121 # Show additional header for the local block only when other blocks exists.
122 # Not necessary in a standard installation without such extensions enabled
123 if ( count( $otherAutoblockLink ) ) {
124 $out->addHTML(
125 Html::rawElement( 'h2', [], $this->msg( 'autoblocklist-localblocks',
126 $pager->getNumRows() )->parse() )
127 . "\n"
128 );
129 }
130
131 if ( $pager->getNumRows() ) {
132 $out->addParserOutputContent(
133 $pager->getFullOutput(),
134 ParserOptions::newFromContext( $this->getContext() )
135 );
136 } else {
137 $out->addWikiMsg( 'autoblocklist-empty' );
138 }
139
140 if ( count( $otherAutoblockLink ) ) {
141 $out->addHTML(
142 Html::rawElement(
143 'h2',
144 [],
145 $this->msg( 'autoblocklist-otherblocks', count( $otherAutoblockLink ) )->parse()
146 ) . "\n"
147 );
148 $list = '';
149 foreach ( $otherAutoblockLink as $link ) {
150 $list .= Html::rawElement( 'li', [], $link ) . "\n";
151 }
152 $out->addHTML(
153 Html::rawElement(
154 'ul',
155 [ 'class' => 'mw-autoblocklist-otherblocks' ],
156 $list
157 ) . "\n"
158 );
159 }
160 }
161
163 protected function getGroupName() {
164 return 'users';
165 }
166}
167
169class_alias( SpecialAutoblockList::class, 'SpecialAutoblockList' );
Defines the actions that can be blocked by a partial block.
Factory for BlockTarget objects.
Helpers for building queries that determine whether a user is hidden.
This is basically a CommentFormatter with a CommentStore dependency, allowing it to retrieve comment ...
Handle database storage of comments such as edit summaries and log reasons.
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition HTMLForm.php:207
This class is a collection of static functions that serve two purposes:
Definition Html.php:43
Factory for LinkBatch objects to batch query page metadata.
Set options of the Parser.
Parent class for all special pages.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getPageTitle( $subpage=false)
Get a self-referential title object.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
getAuthority()
Shortcut to get the Authority executing this instance.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages By default the message key is the canonical name of...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
getBlockListPager()
Setup a new BlockListPager instance.
showList(BlockListPager $pager)
Show the list of blocked accounts matching the actual filter.
__construct(private readonly LinkBatchFactory $linkBatchFactory, private readonly BlockRestrictionStore $blockRestrictionStore, private readonly IConnectionProvider $dbProvider, private readonly CommentStore $commentStore, private readonly BlockTargetFactory $blockTargetFactory, private readonly HideUserUtils $hideUserUtils, private readonly BlockActionInfo $blockActionInfo, private readonly RowCommentFormatter $rowCommentFormatter)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Provide primary and replica IDatabase connections.