MediaWiki  1.29.1
SpecialAutoblockList.php
Go to the documentation of this file.
1 <?php
31 
32  function __construct() {
33  parent::__construct( 'AutoblockList' );
34  }
35 
41  public function execute( $par ) {
42  $this->setHeaders();
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' ] );
49 
50  # setup BlockListPager here to get the actual default Limit
51  $pager = $this->getBlockListPager();
52 
53  # Just show the block list
54  $fields = [
55  'Limit' => [
56  'type' => 'limitselect',
57  'label-message' => 'table_pager_limit_label',
58  'options' => [
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,
64  ],
65  'name' => 'limit',
66  'default' => $pager->getLimit(),
67  ]
68  ];
69 
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()
78  ->prepareForm()
79  ->displayForm( false );
80 
81  $this->showList( $pager );
82  }
83 
88  protected function getBlockListPager() {
89  $conds = [
90  'ipb_parent_block_id IS NOT NULL'
91  ];
92  # Is the user allowed to see hidden blocks?
93  if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
94  $conds['ipb_deleted'] = 0;
95  }
96 
97  return new BlockListPager( $this, $conds );
98  }
99 
104  protected function showList( BlockListPager $pager ) {
105  $out = $this->getOutput();
106 
107  # Check for other blocks, i.e. global/tor blocks
108  $otherAutoblockLink = [];
109  Hooks::run( 'OtherAutoblockLogLink', [ &$otherAutoblockLink ] );
110 
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 ) ) {
114  $out->addHTML(
115  Html::element( 'h2', [], $this->msg( 'autoblocklist-localblocks',
116  $pager->getNumRows() )->parse() )
117  . "\n"
118  );
119  }
120 
121  if ( $pager->getNumRows() ) {
122  $out->addParserOutputContent( $pager->getFullOutput() );
123  } else {
124  $out->addWikiMsg( 'autoblocklist-empty' );
125  }
126 
127  if ( count( $otherAutoblockLink ) ) {
128  $out->addHTML(
130  'h2',
131  [],
132  $this->msg( 'autoblocklist-otherblocks', count( $otherAutoblockLink ) )->parse()
133  ) . "\n"
134  );
135  $list = '';
136  foreach ( $otherAutoblockLink as $link ) {
137  $list .= Html::rawElement( 'li', [], $link ) . "\n";
138  }
139  $out->addHTML(
141  'ul',
142  [ 'class' => 'mw-autoblocklist-otherblocks' ],
143  $list
144  ) . "\n"
145  );
146  }
147  }
148 
149  protected function getGroupName() {
150  return 'users';
151  }
152 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:628
$context
error also a ContextSource you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition: hooks.txt:2612
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:675
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
captcha-old.count
count
Definition: captcha-old.py:225
BlockListPager
Definition: BlockListPager.php:28
TablePager\getFullOutput
getFullOutput()
Get the formatted result list, with navigation bars.
Definition: TablePager.php:99
SpecialAutoblockList
A special page that lists autoblocks.
Definition: SpecialAutoblockList.php:30
SpecialAutoblockList\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialAutoblockList.php:149
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:705
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
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:785
HTMLForm\factory
static factory( $displayFormat)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:277
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:484
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:685
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:648
SpecialPage\msg
msg()
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:746
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:36
SpecialAutoblockList\showList
showList(BlockListPager $pager)
Show the list of blocked accounts matching the actual filter.
Definition: SpecialAutoblockList.php:104
SpecialAutoblockList\execute
execute( $par)
Main execution point.
Definition: SpecialAutoblockList.php:41
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2929
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
SpecialAutoblockList\__construct
__construct()
Definition: SpecialAutoblockList.php:32
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
SpecialAutoblockList\getBlockListPager
getBlockListPager()
Setup a new BlockListPager instance.
Definition: SpecialAutoblockList.php:88
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:583
IndexPager\getNumRows
getNumRows()
Get the number of rows in the result set.
Definition: IndexPager.php:555
$out
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:783