Sethakill has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/286392

Change subject: Convert Special:Activeusers to use OOUI
......................................................................

Convert Special:Activeusers to use OOUI

Moved FormOptions and form from pager
and recreated it with HtmlForm.

Bug: T117733
Change-Id: Ia330bee63ad17bb75e715cd95e407d5e43310177
---
M includes/specialpage/SpecialPageFactory.php
M includes/specials/SpecialActiveusers.php
M includes/specials/pagers/ActiveUsersPager.php
3 files changed, 61 insertions(+), 84 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/92/286392/1

diff --git a/includes/specialpage/SpecialPageFactory.php 
b/includes/specialpage/SpecialPageFactory.php
index 725c4fc..5c24ee0 100644
--- a/includes/specialpage/SpecialPageFactory.php
+++ b/includes/specialpage/SpecialPageFactory.php
@@ -86,6 +86,7 @@
                'CreateAccount' => 'SpecialCreateAccount',
 
                // Users and rights
+               'Activeusers' => 'SpecialActiveUsers',
                'Block' => 'SpecialBlock',
                'Unblock' => 'SpecialUnblock',
                'BlockList' => 'SpecialBlockList',
@@ -253,8 +254,6 @@
                        if ( $wgContentHandlerUseDB ) {
                                self::$list['ChangeContentModel'] = 
'SpecialChangeContentModel';
                        }
-
-                       self::$list['Activeusers'] = 'SpecialActiveUsers';
 
                        // Add extension special pages
                        self::$list = array_merge( self::$list, $wgSpecialPages 
);
diff --git a/includes/specials/SpecialActiveusers.php 
b/includes/specials/SpecialActiveusers.php
index d6d4500..aa48304 100644
--- a/includes/specials/SpecialActiveusers.php
+++ b/includes/specials/SpecialActiveusers.php
@@ -41,16 +41,25 @@
         * @param string $par Parameter passed to the page or null
         */
        public function execute( $par ) {
-               $days = $this->getConfig()->get( 'ActiveUserDays' );
+               $out = $this->getOutput();
 
                $this->setHeaders();
                $this->outputHeader();
 
-               $out = $this->getOutput();
-               $out->wrapWikiMsg( "<div 
class='mw-activeusers-intro'>\n$1\n</div>",
-                       [ 'activeusers-intro', $this->getLanguage()->formatNum( 
$days ) ] );
+               $opts = new FormOptions();
+
+               $opts->add( 'username', '' );
+               $opts->add( 'hidebots', false, FormOptions::BOOL );
+               $opts->add( 'hidesysops', false, FormOptions::BOOL );
+
+               $opts->fetchValuesFromRequest( $this->getRequest() );
+
+               if ( $par !== null ) {
+                       $opts->setValue( 'username', $par );
+               }
 
                // Mention the level of cache staleness...
+               $cacheText = '';
                $dbr = wfGetDB( DB_SLAVE, 'recentchanges' );
                $rcMax = $dbr->selectField( 'recentchanges', 
'MAX(rc_timestamp)', '', __METHOD__ );
                if ( $rcMax ) {
@@ -66,22 +75,50 @@
                                $secondsOld = time() - wfTimestamp( TS_UNIX, 
$rcMin );
                        }
                        if ( $secondsOld > 0 ) {
-                               $out->addWikiMsg( 
'cachedspecial-viewing-cached-ttl',
+                               $cacheTxt = '<br>'.$this->msg( 
'cachedspecial-viewing-cached-ttl',
                                $this->getLanguage()->formatDuration( 
$secondsOld ) );
                        }
                }
 
-               $up = new ActiveUsersPager( $this->getContext(), null, $par );
+               $pager = new ActiveUsersPager( $this->getContext(), $opts );
+               $usersBody = $pager->getBody();
 
-               # getBody() first to check, if empty
-               $usersbody = $up->getBody();
+               $days = $this->getConfig()->get( 'ActiveUserDays' );
 
-               $out->addHTML( $up->getPageHeader() );
-               if ( $usersbody ) {
+               $formDescriptor = [
+                       'username' => [
+                               'type' => 'user',
+                               'name' => 'username',
+                               'label-message' => 'activeusers-from',
+                       ],
+
+                       'hidebots' => [
+                               'type' => 'check',
+                               'name' => 'hidebots',
+                               'label-message' => 'activeusers-hidebots',
+                               'default' => false,
+                       ],
+
+                       'hidesysops' => [
+                               'type' => 'check',
+                               'name' => 'hidesysops',
+                               'label-message' => 'activeusers-hidesysops',
+                               'default' => false,
+                       ],
+               ];
+
+               $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, 
$this->getContext() );
+               $htmlForm->setIntro( $this->msg( 'activeusers-intro', 
$this->getLanguage()->formatNum( $days ) ) . $cacheText);
+               $htmlForm->setWrapperLegendMsg( 'activeusers' );
+               $htmlForm->setSubmitTextMsg( 'activeusers-submit' );
+               $htmlForm->setMethod( 'get' );
+               $htmlForm->prepareForm()->displayForm( false );
+
+               if ( $usersBody ) {
                        $out->addHTML(
-                               $up->getNavigationBar() .
-                               Html::rawElement( 'ul', [], $usersbody ) .
-                               $up->getNavigationBar()
+                               $pager->getNavigationBar() .
+                               Html::rawElement( 'ul', [], $usersBody ) .
+                               $pager->getNavigationBar()
                        );
                } else {
                        $out->addWikiMsg( 'activeusers-noresult' );
@@ -91,4 +128,4 @@
        protected function getGroupName() {
                return 'users';
        }
-}
+}
\ No newline at end of file
diff --git a/includes/specials/pagers/ActiveUsersPager.php 
b/includes/specials/pagers/ActiveUsersPager.php
index 0d3bc9a..eae208b 100644
--- a/includes/specials/pagers/ActiveUsersPager.php
+++ b/includes/specials/pagers/ActiveUsersPager.php
@@ -52,15 +52,15 @@
 
        /**
         * @param IContextSource $context
-        * @param null $group Unused
-        * @param string $par Parameter passed to the page
+        * @param FormOptions $opts
         */
-       function __construct( IContextSource $context = null, $group = null, 
$par = null ) {
+       function __construct( IContextSource $context = null, FormOptions $opts 
) {
                parent::__construct( $context );
 
                $this->RCMaxAge = $this->getConfig()->get( 'ActiveUserDays' );
-               $un = $this->getRequest()->getText( 'username', $par );
                $this->requestedUser = '';
+
+               $un = $opts->getValue( 'username' );
                if ( $un != '' ) {
                        $username = Title::makeTitleSafe( NS_USER, $un );
                        if ( !is_null( $username ) ) {
@@ -68,21 +68,10 @@
                        }
                }
 
-               $this->setupOptions();
-       }
-
-       public function setupOptions() {
-               $this->opts = new FormOptions();
-
-               $this->opts->add( 'hidebots', false, FormOptions::BOOL );
-               $this->opts->add( 'hidesysops', false, FormOptions::BOOL );
-
-               $this->opts->fetchValuesFromRequest( $this->getRequest() );
-
-               if ( $this->opts->getValue( 'hidebots' ) == 1 ) {
+               if ( $opts->getValue( 'hidebots' ) == 1 ) {
                        $this->hideRights[] = 'bot';
                }
-               if ( $this->opts->getValue( 'hidesysops' ) == 1 ) {
+               if ( $opts->getValue( 'hidesysops' ) == 1 ) {
                        $this->hideGroups[] = 'sysop';
                }
        }
@@ -196,59 +185,11 @@
                if ( $isBlocked && $this->blockStatusByUid[$row->user_id] == 1 
) {
                        $item = "<span class=\"deleted\">$item</span>";
                }
-               $count = $this->msg( 'activeusers-count' )->numParams( 
$row->recentedits )
-                       ->params( $userName )->numParams( $this->RCMaxAge 
)->escaped();
+               $count = $this->msg( 'activeusers-count', $row->recentedits, 
$userName, $this->RCMaxAge )
+                       ->escaped();
                $blocked = $isBlocked ? ' ' . $this->msg( 'listusers-blocked', 
$userName )->escaped() : '';
 
                return Html::rawElement( 'li', [], "{$item} 
[{$count}]{$blocked}" );
        }
 
-       function getPageHeader() {
-               $self = $this->getTitle();
-               $limit = $this->mLimit ? Html::hidden( 'limit', $this->mLimit ) 
: '';
-
-               # Form tag
-               $out = Xml::openElement( 'form', [ 'method' => 'get', 'action' 
=> wfScript() ] );
-               $out .= Xml::fieldset( $this->msg( 'activeusers' )->text() ) . 
"\n";
-               $out .= Html::hidden( 'title', $self->getPrefixedDBkey() ) . 
$limit . "\n";
-
-               # Username field (with autocompletion support)
-               $this->getOutput()->addModules( 'mediawiki.userSuggest' );
-               $out .= Xml::inputLabel(
-                               $this->msg( 'activeusers-from' )->text(),
-                               'username',
-                               'offset',
-                               20,
-                               $this->requestedUser,
-                               [
-                                       'class' => 'mw-ui-input-inline 
mw-autocomplete-user',
-                                       'tabindex' => 1,
-                               ] + (
-                                       // Set autofocus on blank input
-                               $this->requestedUser === '' ? [ 'autofocus' => 
'' ] : []
-                               )
-                       ) . '<br />';
-
-               $out .= Xml::checkLabel( $this->msg( 'activeusers-hidebots' 
)->text(),
-                       'hidebots', 'hidebots', $this->opts->getValue( 
'hidebots' ), [ 'tabindex' => 2 ] );
-
-               $out .= Xml::checkLabel(
-                               $this->msg( 'activeusers-hidesysops' )->text(),
-                               'hidesysops',
-                               'hidesysops',
-                               $this->opts->getValue( 'hidesysops' ),
-                               [ 'tabindex' => 3 ]
-                       ) . '<br />';
-
-               # Submit button and form bottom
-               $out .= Xml::submitButton(
-                               $this->msg( 'activeusers-submit' )->text(),
-                               [ 'tabindex' => 4 ]
-                       ) . "\n";
-               $out .= Xml::closeElement( 'fieldset' );
-               $out .= Xml::closeElement( 'form' );
-
-               return $out;
-       }
-
-}
+}
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/286392
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia330bee63ad17bb75e715cd95e407d5e43310177
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Sethakill <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to