HTMLForm: Use <button> and allow differing label and value
[lhc/web/wiklou.git] / includes / specials / SpecialActiveusers.php
index 5e2ee1c..70c7a8b 100644 (file)
@@ -212,10 +212,20 @@ class ActiveUsersPager extends UsersPager {
                $out .= Xml::fieldset( $this->msg( 'activeusers' )->text() ) . "\n";
                $out .= Html::hidden( 'title', $self->getPrefixedDBkey() ) . $limit . "\n";
 
-               # Username field
-               $out .= Xml::inputLabel( $this->msg( 'activeusers-from' )->text(),
-                       'username', 'offset', 20, $this->requestedUser,
-                       array( 'class' => 'mw-ui-input-inline', 'tabindex' => 1 ) ) . '<br />';
+               # Username field (with autocompletion support)
+               $this->getOutput()->addModules( 'mediawiki.userSuggest' );
+               $out .= Xml::inputLabel(
+                       $this->msg( 'activeusers-from' )->text(),
+                       'username',
+                       'offset',
+                       20,
+                       $this->requestedUser,
+                       array(
+                               'class' => 'mw-ui-input-inline mw-autocomplete-user',
+                               'tabindex' => 1,
+                               'autofocus' => $this->requestedUser === '',
+                       )
+               ) . '<br />';
 
                $out .= Xml::checkLabel( $this->msg( 'activeusers-hidebots' )->text(),
                        'hidebots', 'hidebots', $this->opts->getValue( 'hidebots' ), array( 'tabindex' => 2 ) );
@@ -230,7 +240,7 @@ class ActiveUsersPager extends UsersPager {
 
                # Submit button and form bottom
                $out .= Xml::submitButton(
-                       $this->msg( 'allpagessubmit' )->text(),
+                       $this->msg( 'activeusers-submit' )->text(),
                        array( 'tabindex' => 4 )
                ) . "\n";
                $out .= Xml::closeElement( 'fieldset' );
@@ -267,21 +277,24 @@ class SpecialActiveUsers extends SpecialPage {
                $out->wrapWikiMsg( "<div class='mw-activeusers-intro'>\n$1\n</div>",
                        array( 'activeusers-intro', $this->getLanguage()->formatNum( $days ) ) );
 
-               // Get the timestamp of the last cache update
+               // Mention the level of cache staleness...
                $dbr = wfGetDB( DB_SLAVE, 'recentchanges' );
-               $cTime = $dbr->selectField( 'querycache_info',
-                       'qci_timestamp',
-                       array( 'qci_type' => 'activeusers' )
-               );
-
-               $secondsOld = $cTime
-                       ? time() - wfTimestamp( TS_UNIX, $cTime )
-                       : $days * 86400; // fully stale :)
-
-               if ( $secondsOld > 0 ) {
-                       // Mention the level of staleness
-                       $out->addWikiMsg( 'cachedspecial-viewing-cached-ttl',
+               $rcMax = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)' );
+               if ( $rcMax ) {
+                       $cTime = $dbr->selectField( 'querycache_info',
+                               'qci_timestamp',
+                               array( 'qci_type' => 'activeusers' )
+                       );
+                       if ( $cTime ) {
+                               $secondsOld = wfTimestamp( TS_UNIX, $rcMax ) - wfTimestamp( TS_UNIX, $cTime );
+                       } else {
+                               $rcMin = $dbr->selectField( 'recentchanges', 'MIN(rc_timestamp)' );
+                               $secondsOld = time() - wfTimestamp( TS_UNIX, $rcMin );
+                       }
+                       if ( $secondsOld > 0 ) {
+                               $out->addWikiMsg( 'cachedspecial-viewing-cached-ttl',
                                $this->getLanguage()->formatDuration( $secondsOld ) );
+                       }
                }
 
                $up = new ActiveUsersPager( $this->getContext(), null, $par );
@@ -305,3 +318,5 @@ class SpecialActiveUsers extends SpecialPage {
                return 'users';
        }
 }
+
+