MediaWiki  1.34.0
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 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:672
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:792
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:719
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:117
BlockListPager
Definition: BlockListPager.php:32
TablePager\getFullOutput
getFullOutput()
Get the formatted result list, with navigation bars.
Definition: TablePager.php:104
SpecialAutoblockList
A special page that lists autoblocks.
Definition: SpecialAutoblockList.php:32
SpecialAutoblockList\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialAutoblockList.php:159
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition: DerivativeContext.php:30
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:828
getPermissionManager
getPermissionManager()
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:537
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:729
SpecialAutoblockList\showTotal
showTotal(BlockListPager $pager)
Show total number of autoblocks on top of the table.
Definition: SpecialAutoblockList.php:101
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:692
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:37
SpecialAutoblockList\showList
showList(BlockListPager $pager)
Show the list of blocked accounts matching the actual filter.
Definition: SpecialAutoblockList.php:114
BlockListPager\getTotalAutoblocks
getTotalAutoblocks()
Get total number of autoblocks at any given time.
Definition: BlockListPager.php:379
SpecialAutoblockList\execute
execute( $par)
Definition: SpecialAutoblockList.php:41
$context
$context
Definition: load.php:45
SpecialAutoblockList\__construct
__construct()
Definition: SpecialAutoblockList.php:34
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
SpecialAutoblockList\getBlockListPager
getBlockListPager()
Setup a new BlockListPager instance.
Definition: SpecialAutoblockList.php:81
HTMLForm\factory
static factory( $displayFormat,... $arguments)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:303
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:639
IndexPager\getNumRows
getNumRows()
Get the number of rows in the result set.
Definition: IndexPager.php:607