MediaWiki master
SpecialAutoblockList.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Specials;
8
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 ->setId( 'mw-autoblock-list-form' )
76 ->prepareForm()
77 ->displayForm( false );
78
79 $this->showList( $pager );
80 }
81
86 protected function getBlockListPager() {
87 $conds = [
88 $this->dbProvider->getReplicaDatabase()->expr( 'bl_parent_block_id', '!=', null ),
89 ];
90 # Is the user allowed to see hidden blocks?
91 if ( !$this->getAuthority()->isAllowed( 'hideuser' ) ) {
92 $conds['bl_deleted'] = 0;
93 }
94
95 return new BlockListPager(
96 $this->getContext(),
97 $this->blockActionInfo,
98 $this->blockRestrictionStore,
99 $this->blockTargetFactory,
100 $this->hideUserUtils,
101 $this->commentStore,
102 $this->linkBatchFactory,
103 $this->getLinkRenderer(),
104 $this->dbProvider,
105 $this->rowCommentFormatter,
106 $this->getSpecialPageFactory(),
107 $conds
108 );
109 }
110
115 protected function showList( BlockListPager $pager ) {
116 $out = $this->getOutput();
117
118 # Check for other blocks, i.e. global/tor blocks
119 $otherAutoblockLink = [];
120 $this->getHookRunner()->onOtherAutoblockLogLink( $otherAutoblockLink );
121
122 # Show additional header for the local block only when other blocks exists.
123 # Not necessary in a standard installation without such extensions enabled
124 if ( count( $otherAutoblockLink ) ) {
125 $out->addHTML(
126 Html::rawElement( 'h2', [], $this->msg( 'autoblocklist-localblocks',
127 $pager->getNumRows() )->parse() )
128 . "\n"
129 );
130 }
131
132 if ( $pager->getNumRows() ) {
133 $out->addParserOutputContent(
134 $pager->getFullOutput(),
135 ParserOptions::newFromContext( $this->getContext() )
136 );
137 } else {
138 $out->addWikiMsg( 'autoblocklist-empty' );
139 }
140
141 if ( count( $otherAutoblockLink ) ) {
142 $out->addHTML(
143 Html::rawElement(
144 'h2',
145 [],
146 $this->msg( 'autoblocklist-otherblocks', count( $otherAutoblockLink ) )->parse()
147 ) . "\n"
148 );
149 $list = '';
150 foreach ( $otherAutoblockLink as $link ) {
151 $list .= Html::rawElement( 'li', [], $link ) . "\n";
152 }
153 $out->addHTML(
154 Html::rawElement(
155 'ul',
156 [ 'class' => 'mw-autoblocklist-otherblocks' ],
157 $list
158 ) . "\n"
159 );
160 }
161 }
162
167 protected function getGroupName() {
168 return 'users';
169 }
170}
171
172// @codeCoverageIgnoreStart
174class_alias( SpecialAutoblockList::class, 'SpecialAutoblockList' );
175// @codeCoverageIgnoreEnd
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:214
This class is a collection of static functions that serve two purposes:
Definition Html.php:44
Factory for LinkBatch objects to batch query page metadata.
getNumRows()
Get the number of rows in the result set.
getFullOutput()
Get the formatted result list, with navigation bars.
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.