Corrected grammatical error.
[lhc/web/wiklou.git] / includes / specials / SpecialBlockList.php
index 667b814..4e541c9 100644 (file)
@@ -31,28 +31,28 @@ class SpecialBlockList extends SpecialPage {
 
        protected $options;
 
+       protected $blockType;
+
        function __construct() {
                parent::__construct( 'BlockList' );
        }
 
        /**
-        * Main execution point
-        *
-        * @param string $par Title fragment
+        * @param string|null $par Title fragment
         */
        public function execute( $par ) {
                $this->setHeaders();
                $this->outputHeader();
                $out = $this->getOutput();
-               $lang = $this->getLanguage();
                $out->setPageTitle( $this->msg( 'ipblocklist' ) );
-               $out->addModuleStyles( [ 'mediawiki.special' ] );
+               $out->addModuleStyles( [ 'mediawiki.special', 'mediawiki.special.blocklist' ] );
 
                $request = $this->getRequest();
                $par = $request->getVal( 'ip', $par );
                $this->target = trim( $request->getVal( 'wpTarget', $par ) );
 
                $this->options = $request->getArray( 'wpOptions', [] );
+               $this->blockType = $request->getVal( 'blockType' );
 
                $action = $request->getText( 'action' );
 
@@ -86,20 +86,33 @@ class SpecialBlockList extends SpecialPage {
                                ],
                                'flatlist' => true,
                        ],
-                       'Limit' => [
-                               'type' => 'limitselect',
-                               'label-message' => 'table_pager_limit_label',
+               ];
+
+               if ( $this->getConfig()->get( 'EnablePartialBlocks' ) ) {
+                       $fields['BlockType'] = [
+                               'type' => 'select',
+                               'label-message' => 'blocklist-type',
                                'options' => [
-                                       $lang->formatNum( 20 ) => 20,
-                                       $lang->formatNum( 50 ) => 50,
-                                       $lang->formatNum( 100 ) => 100,
-                                       $lang->formatNum( 250 ) => 250,
-                                       $lang->formatNum( 500 ) => 500,
+                                       $this->msg( 'blocklist-type-opt-all' )->escaped() => '',
+                                       $this->msg( 'blocklist-type-opt-sitewide' )->escaped() => 'sitewide',
+                                       $this->msg( 'blocklist-type-opt-partial' )->escaped() => 'partial',
                                ],
-                               'name' => 'limit',
-                               'default' => $pager->getLimit(),
-                       ],
+                               'name' => 'blockType',
+                               'cssclass' => 'mw-field-block-type',
+                       ];
+               }
+
+               $fields['Limit'] = [
+                       'type' => 'limitselect',
+                       'label-message' => 'table_pager_limit_label',
+                       'options' => $pager->getLimitSelectList(),
+                       'name' => 'limit',
+                       'default' => $pager->getLimit(),
+                       'cssclass' => $this->getConfig()->get( 'EnablePartialBlocks' ) ?
+                               'mw-field-limit mw-has-field-block-type' :
+                               'mw-field-limit',
                ];
+
                $context = new DerivativeContext( $this->getContext() );
                $context->setTitle( $this->getPageTitle() ); // Remove subpage
                $form = HTMLForm::factory( 'ooui', $fields, $context );
@@ -168,6 +181,12 @@ class SpecialBlockList extends SpecialPage {
                        $conds[] = "ipb_range_end = ipb_range_start";
                }
 
+               if ( $this->blockType === 'sitewide' ) {
+                       $conds[] = 'ipb_sitewide = 1';
+               } elseif ( $this->blockType === 'partial' ) {
+                       $conds[] = 'ipb_sitewide = 0';
+               }
+
                return new BlockListPager( $this, $conds );
        }