Merge "New hook for filters on Special:Contributions form"
[lhc/web/wiklou.git] / includes / specials / SpecialBlockList.php
index 8a9aefd..73a2774 100644 (file)
@@ -46,8 +46,7 @@ class SpecialBlockList extends SpecialPage {
                $out = $this->getOutput();
                $lang = $this->getLanguage();
                $out->setPageTitle( $this->msg( 'ipblocklist' ) );
-               $out->addModuleStyles( 'mediawiki.special' );
-               $out->addModules( 'mediawiki.userSuggest' );
+               $out->addModuleStyles( array( 'mediawiki.special', 'mediawiki.special.blocklist' ) );
 
                $request = $this->getRequest();
                $par = $request->getVal( 'ip', $par );
@@ -65,23 +64,25 @@ class SpecialBlockList extends SpecialPage {
                        return;
                }
 
+               # setup BlockListPager here to get the actual default Limit
+               $pager = $this->getBlockListPager();
+
                # Just show the block list
                $fields = array(
                        'Target' => array(
-                               'type' => 'text',
+                               'type' => 'user',
                                'label-message' => 'ipaddressorusername',
                                'tabindex' => '1',
                                'size' => '45',
                                'default' => $this->target,
-                               'cssclass' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
                        ),
                        'Options' => array(
                                'type' => 'multiselect',
-                               'options' => array(
-                                       $this->msg( 'blocklist-userblocks' )->text() => 'userblocks',
-                                       $this->msg( 'blocklist-tempblocks' )->text() => 'tempblocks',
-                                       $this->msg( 'blocklist-addressblocks' )->text() => 'addressblocks',
-                                       $this->msg( 'blocklist-rangeblocks' )->text() => 'rangeblocks',
+                               'options-messages' => array(
+                                       'blocklist-userblocks' => 'userblocks',
+                                       'blocklist-tempblocks' => 'tempblocks',
+                                       'blocklist-addressblocks' => 'addressblocks',
+                                       'blocklist-rangeblocks' => 'rangeblocks',
                                ),
                                'flatlist' => true,
                        ),
@@ -96,12 +97,12 @@ class SpecialBlockList extends SpecialPage {
                                        $lang->formatNum( 500 ) => 500,
                                ),
                                'name' => 'limit',
-                               'default' => 50,
+                               'default' => $pager->getLimit(),
                        ),
                );
                $context = new DerivativeContext( $this->getContext() );
                $context->setTitle( $this->getPageTitle() ); // Remove subpage
-               $form = new HTMLForm( $fields, $context );
+               $form = HTMLForm::factory( 'ooui', $fields, $context );
                $form->setMethod( 'get' );
                $form->setWrapperLegendMsg( 'ipblocklist-legend' );
                $form->setSubmitTextMsg( 'ipblocklist-submit' );
@@ -109,10 +110,14 @@ class SpecialBlockList extends SpecialPage {
                $form->prepareForm();
 
                $form->displayForm( '' );
-               $this->showList();
+               $this->showList( $pager );
        }
 
-       function showList() {
+       /**
+        * Setup a new BlockListPager instance.
+        * @return BlockListPager
+        */
+       protected function getBlockListPager() {
                $conds = array();
                # Is the user allowed to see hidden blocks?
                if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
@@ -163,12 +168,20 @@ class SpecialBlockList extends SpecialPage {
                        $conds[] = "ipb_range_end = ipb_range_start";
                }
 
+               return new BlockListPager( $this, $conds );
+       }
+
+       /**
+        * Show the list of blocked accounts matching the actual filter.
+        * @param BlockListPager $pager The BlockListPager instance for this page
+        */
+       protected function showList( BlockListPager $pager ) {
+               $out = $this->getOutput();
+
                # Check for other blocks, i.e. global/tor blocks
                $otherBlockLink = array();
                Hooks::run( 'OtherBlockLogLink', array( &$otherBlockLink, $this->target ) );
 
-               $out = $this->getOutput();
-
                # Show additional header for the local block only when other blocks exists.
                # Not necessary in a standard installation without such extensions enabled
                if ( count( $otherBlockLink ) ) {
@@ -177,7 +190,6 @@ class SpecialBlockList extends SpecialPage {
                        );
                }
 
-               $pager = new BlockListPager( $this, $conds );
                if ( $pager->getNumRows() ) {
                        $out->addParserOutputContent( $pager->getFullOutput() );
                } elseif ( $this->target ) {
@@ -249,7 +261,7 @@ class BlockListPager extends TablePager {
        function formatValue( $name, $value ) {
                static $msg = null;
                if ( $msg === null ) {
-                       $msg = array(
+                       $keys = array(
                                'anononlyblock',
                                'createaccountblock',
                                'noautoblockblock',
@@ -258,17 +270,22 @@ class BlockListPager extends TablePager {
                                'unblocklink',
                                'change-blocklink',
                        );
-                       $msg = array_combine( $msg, array_map( array( $this, 'msg' ), $msg ) );
+
+                       foreach ( $keys as $key ) {
+                               $msg[$key] = $this->msg( $key )->escaped();
+                       }
                }
 
                /** @var $row object */
                $row = $this->mCurrentRow;
 
+               $language = $this->getLanguage();
+
                $formatted = '';
 
                switch ( $name ) {
                        case 'ipb_timestamp':
-                               $formatted = $this->getLanguage()->userTimeAndDate( $value, $this->getUser() );
+                               $formatted = htmlspecialchars( $language->userTimeAndDate( $value, $this->getUser() ) );
                                break;
 
                        case 'ipb_target':
@@ -294,7 +311,10 @@ class BlockListPager extends TablePager {
                                break;
 
                        case 'ipb_expiry':
-                               $formatted = $this->getLanguage()->formatExpiry( $value, /* User preference timezone */true );
+                               $formatted = htmlspecialchars( $language->formatExpiry(
+                                       $value,
+                                       /* User preference timezone */true
+                               ) );
                                if ( $this->getUser()->isAllowed( 'block' ) ) {
                                        if ( $row->ipb_auto ) {
                                                $links[] = Linker::linkKnown(
@@ -317,7 +337,7 @@ class BlockListPager extends TablePager {
                                                'span',
                                                array( 'class' => 'mw-blocklist-actions' ),
                                                $this->msg( 'parentheses' )->rawParams(
-                                                       $this->getLanguage()->pipeList( $links ) )->escaped()
+                                                       $language->pipeList( $links ) )->escaped()
                                        );
                                }
                                break;
@@ -355,7 +375,7 @@ class BlockListPager extends TablePager {
                                        $properties[] = $msg['blocklist-nousertalk'];
                                }
 
-                               $formatted = $this->getLanguage()->commaList( $properties );
+                               $formatted = $language->commaList( $properties );
                                break;
 
                        default: