dcb2444e18b8a9310b0d3ac0d523eddff50a4e42
3 * Implements Special:AutoblockList
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
25 * A special page that lists autoblocks
28 * @ingroup SpecialPage
30 class SpecialAutoblockList
extends SpecialPage
{
32 function __construct() {
33 parent
::__construct( 'AutoblockList' );
37 * Main execution point
39 * @param string $par Title fragment
41 public function execute( $par ) {
43 $this->outputHeader();
44 $out = $this->getOutput();
45 $lang = $this->getLanguage();
46 $out->setPageTitle( $this->msg( 'autoblocklist' ) );
47 $this->addHelpLink( 'Autoblock' );
48 $out->addModuleStyles( [ 'mediawiki.special' ] );
50 # setup BlockListPager here to get the actual default Limit
51 $pager = $this->getBlockListPager();
53 # Just show the block list
56 'type' => 'limitselect',
57 'label-message' => 'table_pager_limit_label',
59 $lang->formatNum( 20 ) => 20,
60 $lang->formatNum( 50 ) => 50,
61 $lang->formatNum( 100 ) => 100,
62 $lang->formatNum( 250 ) => 250,
63 $lang->formatNum( 500 ) => 500,
66 'default' => $pager->getLimit(),
70 $context = new DerivativeContext( $this->getContext() );
71 $context->setTitle( $this->getPageTitle() ); // Remove subpage
72 $form = HTMLForm
::factory( 'ooui', $fields, $context );
73 $form->setMethod( 'get' )
74 ->setFormIdentifier( 'blocklist' )
75 ->setWrapperLegendMsg( 'autoblocklist-legend' )
76 ->setSubmitTextMsg( 'autoblocklist-submit' )
77 ->setSubmitProgressive()
79 ->displayForm( false );
81 $this->showList( $pager );
85 * Setup a new BlockListPager instance.
86 * @return BlockListPager
88 protected function getBlockListPager() {
90 'ipb_parent_block_id IS NOT NULL'
92 # Is the user allowed to see hidden blocks?
93 if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
94 $conds['ipb_deleted'] = 0;
97 return new BlockListPager( $this, $conds );
101 * Show the list of blocked accounts matching the actual filter.
102 * @param BlockListPager $pager The BlockListPager instance for this page
104 protected function showList( BlockListPager
$pager ) {
105 $out = $this->getOutput();
107 # Check for other blocks, i.e. global/tor blocks
108 $otherAutoblockLink = [];
109 Hooks
::run( 'OtherAutoblockLogLink', [ &$otherAutoblockLink ] );
111 # Show additional header for the local block only when other blocks exists.
112 # Not necessary in a standard installation without such extensions enabled
113 if ( count( $otherAutoblockLink ) ) {
115 Html
::element( 'h2', [], $this->msg( 'autoblocklist-localblocks',
116 $pager->getNumRows() )->parse() )
121 if ( $pager->getNumRows() ) {
122 $out->addParserOutputContent( $pager->getFullOutput() );
124 $out->addWikiMsg( 'autoblocklist-empty' );
127 if ( count( $otherAutoblockLink ) ) {
132 $this->msg( 'autoblocklist-otherblocks', count( $otherAutoblockLink ) )->parse()
136 foreach ( $otherAutoblockLink as $link ) {
137 $list .= Html
::rawElement( 'li', [], $link ) . "\n";
142 [ 'class' => 'mw-autoblocklist-otherblocks' ],
149 protected function getGroupName() {