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  $form = HTMLForm::factory( 'ooui', $fields, $this->getContext() );
115  $form->setMethod( 'get' )
116  ->setTitle( $this->getPageTitle() ) // Remove subpage
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->getAuthority()->isAllowed( 'hideuser' ) ) {
137  $conds['ipb_deleted'] = 0;
138  }
139 
140  return new BlockListPager(
141  $this->getContext(),
142  $this->blockActionInfo,
143  $this->blockRestrictionStore,
144  $this->blockUtils,
145  $this->commentStore,
146  $this->linkBatchFactory,
147  $this->getLinkRenderer(),
148  $this->loadBalancer,
149  $this->rowCommentFormatter,
150  $this->getSpecialPageFactory(),
151  $conds
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 }
getTotalAutoblocks()
Get total number of autoblocks at any given time.
Handle database storage of comments such as edit summaries and log reasons.
static factory( $displayFormat, $descriptor, $context=null, $messagePrefix='')
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:336
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:214
getNumRows()
Get the number of rows in the result set.
Definition: IndexPager.php:776
Defines the actions that can be blocked by a partial block.
Backend class for blocking utils.
Definition: BlockUtils.php:46
This is basically a CommentFormatter with a CommentStore dependency, allowing it to retrieve comment ...
A special page that lists autoblocks.
getBlockListPager()
Setup a new BlockListPager instance.
showList(BlockListPager $pager)
Show the list of blocked accounts matching the actual filter.
BlockActionInfo $blockActionInfo
RowCommentFormatter $rowCommentFormatter
BlockRestrictionStore $blockRestrictionStore
__construct(LinkBatchFactory $linkBatchFactory, BlockRestrictionStore $blockRestrictionStore, ILoadBalancer $loadBalancer, CommentStore $commentStore, BlockUtils $blockUtils, BlockActionInfo $blockActionInfo, RowCommentFormatter $rowCommentFormatter)
showTotal(BlockListPager $pager)
Show total number of autoblocks on top of the table.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
LinkBatchFactory $linkBatchFactory
Parent class for all special pages.
Definition: SpecialPage.php:44
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getAuthority()
Shortcut to get the Authority executing this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
getFullOutput()
Get the formatted result list, with navigation bars.
Definition: TablePager.php:109
Database cluster connection, tracking, load balancing, and transaction manager interface.