X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2FSpecialActiveusers.php;h=2da441b88043b4c631da370d7157aba58ba009bb;hp=d6d4500972e7c9b295742fbc1481dfec5ca3e3a6;hb=f43fa6f4f0e2cb60b8543daad661b48a3e0653a9;hpb=6593f76927558202414e67d4ee1435c96baea658 diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php index d6d4500972..2da441b880 100644 --- a/includes/specials/SpecialActiveusers.php +++ b/includes/specials/SpecialActiveusers.php @@ -24,6 +24,8 @@ */ /** + * Implements Special:Activeusers + * * @ingroup SpecialPage */ class SpecialActiveUsers extends SpecialPage { @@ -41,17 +43,26 @@ class SpecialActiveUsers extends SpecialPage { * @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( "
\n$1\n
", - [ '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... - $dbr = wfGetDB( DB_SLAVE, 'recentchanges' ); + $cacheText = ''; + $dbr = wfGetDB( DB_REPLICA, 'recentchanges' ); $rcMax = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', '', __METHOD__ ); if ( $rcMax ) { $cTime = $dbr->selectField( 'querycache_info', @@ -66,22 +77,51 @@ class SpecialActiveUsers extends SpecialPage { $secondsOld = time() - wfTimestamp( TS_UNIX, $rcMin ); } if ( $secondsOld > 0 ) { - $out->addWikiMsg( 'cachedspecial-viewing-cached-ttl', - $this->getLanguage()->formatDuration( $secondsOld ) ); + $cacheTxt = '
' . $this->msg( 'cachedspecial-viewing-cached-ttl' ) + ->durationParams( $secondsOld ); } } - $up = new ActiveUsersPager( $this->getContext(), null, $par ); + $pager = new ActiveUsersPager( $this->getContext(), $opts ); + $usersBody = $pager->getBody(); + + $days = $this->getConfig()->get( 'ActiveUserDays' ); + + $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, + ], + ]; - # getBody() first to check, if empty - $usersbody = $up->getBody(); + $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() ) + ->setIntro( $this->msg( 'activeusers-intro' )->numParams( $days ) . $cacheText ) + ->setWrapperLegendMsg( 'activeusers' ) + ->setSubmitTextMsg( 'activeusers-submit' ) + ->setMethod( 'get' ) + ->prepareForm() + ->displayForm( false ); - $out->addHTML( $up->getPageHeader() ); - if ( $usersbody ) { + 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' );