MediaWiki  master
SpecialAutoblockList.php
Go to the documentation of this file.
1 <?php
25 
33 
35  private $permManager;
36 
41  parent::__construct( 'AutoblockList' );
42 
43  $this->permManager = $permManager;
44  }
45 
49  public function execute( $par ) {
50  $this->setHeaders();
51  $this->outputHeader();
52  $out = $this->getOutput();
53  $out->setPageTitle( $this->msg( 'autoblocklist' ) );
54  $this->addHelpLink( 'Autoblock' );
55  $out->addModuleStyles( [ 'mediawiki.special' ] );
56 
57  # setup BlockListPager here to get the actual default Limit
58  $pager = $this->getBlockListPager();
59 
60  # Just show the block list
61  $fields = [
62  'Limit' => [
63  'type' => 'limitselect',
64  'label-message' => 'table_pager_limit_label',
65  'options' => $pager->getLimitSelectList(),
66  'name' => 'limit',
67  'default' => $pager->getLimit(),
68  ]
69  ];
70 
71  $context = new DerivativeContext( $this->getContext() );
72  $context->setTitle( $this->getPageTitle() ); // Remove subpage
73  $form = HTMLForm::factory( 'ooui', $fields, $context );
74  $form->setMethod( 'get' )
75  ->setFormIdentifier( 'blocklist' )
76  ->setWrapperLegendMsg( 'autoblocklist-legend' )
77  ->setSubmitTextMsg( 'autoblocklist-submit' )
78  ->prepareForm()
79  ->displayForm( false );
80 
81  $this->showTotal( $pager );
82  $this->showList( $pager );
83  }
84 
89  protected function getBlockListPager() {
90  $conds = [
91  'ipb_parent_block_id IS NOT NULL'
92  ];
93  # Is the user allowed to see hidden blocks?
94  if ( !$this->permManager->userHasRight( $this->getUser(), 'hideuser' ) ) {
95  $conds['ipb_deleted'] = 0;
96  }
97 
98  return new BlockListPager( $this, $conds );
99  }
100 
106  protected function showTotal( BlockListPager $pager ) {
107  $out = $this->getOutput();
108  $out->addHTML(
109  Html::rawElement( 'div', [ 'style' => 'font-weight: bold;' ],
110  $this->msg( 'autoblocklist-total-autoblocks', $pager->getTotalAutoblocks() )->parse() )
111  . "\n"
112  );
113  }
114 
119  protected function showList( BlockListPager $pager ) {
120  $out = $this->getOutput();
121 
122  # Check for other blocks, i.e. global/tor blocks
123  $otherAutoblockLink = [];
124  $this->getHookRunner()->onOtherAutoblockLogLink( $otherAutoblockLink );
125 
126  # Show additional header for the local block only when other blocks exists.
127  # Not necessary in a standard installation without such extensions enabled
128  if ( count( $otherAutoblockLink ) ) {
129  $out->addHTML(
130  Html::rawElement( 'h2', [], $this->msg( 'autoblocklist-localblocks',
131  $pager->getNumRows() )->parse() )
132  . "\n"
133  );
134  }
135 
136  if ( $pager->getNumRows() ) {
137  $out->addParserOutputContent( $pager->getFullOutput() );
138  } else {
139  $out->addWikiMsg( 'autoblocklist-empty' );
140  }
141 
142  if ( count( $otherAutoblockLink ) ) {
143  $out->addHTML(
145  'h2',
146  [],
147  $this->msg( 'autoblocklist-otherblocks', count( $otherAutoblockLink ) )->parse()
148  ) . "\n"
149  );
150  $list = '';
151  foreach ( $otherAutoblockLink as $link ) {
152  $list .= Html::rawElement( 'li', [], $link ) . "\n";
153  }
154  $out->addHTML(
156  'ul',
157  [ 'class' => 'mw-autoblocklist-otherblocks' ],
158  $list
159  ) . "\n"
160  );
161  }
162  }
163 
164  protected function getGroupName() {
165  return 'users';
166  }
167 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:697
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:828
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:744
BlockListPager
Definition: BlockListPager.php:34
TablePager\getFullOutput
getFullOutput()
Get the formatted result list, with navigation bars.
Definition: TablePager.php:111
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:164
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition: DerivativeContext.php:31
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:864
SpecialPage\getHookRunner
getHookRunner()
Definition: SpecialPage.php:1010
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!...
Definition: SpecialPage.php:571
SpecialAutoblockList\showTotal
showTotal(BlockListPager $pager)
Show total number of autoblocks on top of the table.
Definition: SpecialAutoblockList.php:106
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:717
MediaWiki\Permissions\PermissionManager
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
Definition: PermissionManager.php:49
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:41
SpecialAutoblockList\showList
showList(BlockListPager $pager)
Show the list of blocked accounts matching the actual filter.
Definition: SpecialAutoblockList.php:119
BlockListPager\getTotalAutoblocks
getTotalAutoblocks()
Get total number of autoblocks at any given time.
Definition: BlockListPager.php:386
SpecialAutoblockList\$permManager
PermissionManager $permManager
Definition: SpecialAutoblockList.php:35
SpecialAutoblockList\execute
execute( $par)
Definition: SpecialAutoblockList.php:49
SpecialAutoblockList\__construct
__construct(PermissionManager $permManager)
Definition: SpecialAutoblockList.php:40
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
SpecialAutoblockList\getBlockListPager
getBlockListPager()
Setup a new BlockListPager instance.
Definition: SpecialAutoblockList.php:89
HTMLForm\factory
static factory( $displayFormat,... $arguments)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:315
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:662
IndexPager\getNumRows
getNumRows()
Get the number of rows in the result set.
Definition: IndexPager.php:731