MediaWiki  master
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(
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(
151  'ul',
152  [ 'class' => 'mw-autoblocklist-otherblocks' ],
153  $list
154  ) . "\n"
155  );
156  }
157  }
158 
159  protected function getGroupName() {
160  return 'users';
161  }
162 }
$context
Definition: load.php:45
getContext()
Gets the context this SpecialPage is executed in.
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
An IContextSource implementation which will inherit context from another source but allow individual ...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
getOutput()
Get the OutputPage being used for this instance.
getPermissionManager()
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
static factory( $displayFormat,... $arguments)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:307
A special page that lists autoblocks.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
showList(BlockListPager $pager)
Show the list of blocked accounts matching the actual filter.
getUser()
Shortcut to get the User executing this instance.
getFullOutput()
Get the formatted result list, with navigation bars.
Definition: TablePager.php:104
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
getPageTitle( $subpage=false)
Get a self-referential title object.
getBlockListPager()
Setup a new BlockListPager instance.
showTotal(BlockListPager $pager)
Show total number of autoblocks on top of the table.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
getTotalAutoblocks()
Get total number of autoblocks at any given time.
getNumRows()
Get the number of rows in the result set.
Definition: IndexPager.php:607