MediaWiki REL1_34
SpecialAutoblockList.php
Go to the documentation of this file.
1<?php
25
33
34 function __construct() {
35 parent::__construct( 'AutoblockList' );
36 }
37
41 public function execute( $par ) {
42 $this->setHeaders();
43 $this->outputHeader();
44 $out = $this->getOutput();
45 $out->setPageTitle( $this->msg( 'autoblocklist' ) );
46 $this->addHelpLink( 'Autoblock' );
47 $out->addModuleStyles( [ 'mediawiki.special' ] );
48
49 # setup BlockListPager here to get the actual default Limit
50 $pager = $this->getBlockListPager();
51
52 # Just show the block list
53 $fields = [
54 'Limit' => [
55 'type' => 'limitselect',
56 'label-message' => 'table_pager_limit_label',
57 'options' => $pager->getLimitSelectList(),
58 'name' => 'limit',
59 'default' => $pager->getLimit(),
60 ]
61 ];
62
63 $context = new DerivativeContext( $this->getContext() );
64 $context->setTitle( $this->getPageTitle() ); // Remove subpage
65 $form = HTMLForm::factory( 'ooui', $fields, $context );
66 $form->setMethod( 'get' )
67 ->setFormIdentifier( 'blocklist' )
68 ->setWrapperLegendMsg( 'autoblocklist-legend' )
69 ->setSubmitTextMsg( 'autoblocklist-submit' )
70 ->prepareForm()
71 ->displayForm( false );
72
73 $this->showTotal( $pager );
74 $this->showList( $pager );
75 }
76
81 protected function getBlockListPager() {
82 $conds = [
83 'ipb_parent_block_id IS NOT NULL'
84 ];
85 # Is the user allowed to see hidden blocks?
86 if ( !MediaWikiServices::getInstance()
88 ->userHasRight( $this->getUser(), 'hideuser' )
89 ) {
90 $conds['ipb_deleted'] = 0;
91 }
92
93 return new BlockListPager( $this, $conds );
94 }
95
101 protected function showTotal( BlockListPager $pager ) {
102 $out = $this->getOutput();
103 $out->addHTML(
104 Html::rawElement( 'div', [ 'style' => 'font-weight: bold;' ],
105 $this->msg( 'autoblocklist-total-autoblocks', $pager->getTotalAutoblocks() )->parse() )
106 . "\n"
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 Hooks::run( 'OtherAutoblockLogLink', [ &$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( $pager->getFullOutput() );
133 } else {
134 $out->addWikiMsg( 'autoblocklist-empty' );
135 }
136
137 if ( count( $otherAutoblockLink ) ) {
138 $out->addHTML(
139 Html::rawElement(
140 'h2',
141 [],
142 $this->msg( 'autoblocklist-otherblocks', count( $otherAutoblockLink ) )->parse()
143 ) . "\n"
144 );
145 $list = '';
146 foreach ( $otherAutoblockLink as $link ) {
147 $list .= Html::rawElement( 'li', [], $link ) . "\n";
148 }
149 $out->addHTML(
150 Html::rawElement(
151 'ul',
152 [ 'class' => 'mw-autoblocklist-otherblocks' ],
153 $list
154 ) . "\n"
155 );
156 }
157 }
158
159 protected function getGroupName() {
160 return 'users';
161 }
162}
getPermissionManager()
getTotalAutoblocks()
Get total number of autoblocks at any given time.
An IContextSource implementation which will inherit context from another source but allow individual ...
getNumRows()
Get the number of rows in the result set.
MediaWikiServices is the service locator for the application scope of MediaWiki.
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.
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...
Parent class for all special pages.
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.
getUser()
Shortcut to get the User executing this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
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.
$context
Definition load.php:45