From: Jack Phoenix Date: Fri, 3 Jul 2009 00:22:22 +0000 (+0000) Subject: make ActiveUsers subclass SpecialPage X-Git-Tag: 1.31.0-rc.0~41126 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=564b2b306aa6582f2b3f8a37d7cf8e80270f280d;p=lhc%2Fweb%2Fwiklou.git make ActiveUsers subclass SpecialPage --- diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index f2192088ed..aef9297c11 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -512,6 +512,7 @@ $wgAutoloadLocalClasses = array( 'SpecialRevisionDelete' => 'includes/specials/SpecialRevisiondelete.php', 'RevisionDeleter' => 'includes/specials/SpecialRevisiondelete.php', 'ShortPagesPage' => 'includes/specials/SpecialShortpages.php', + 'SpecialActiveUsers' => 'includes/specials/SpecialActiveusers.php', 'SpecialAllpages' => 'includes/specials/SpecialAllpages.php', 'SpecialBlankpage' => 'includes/specials/SpecialBlankpage.php', 'SpecialBookSources' => 'includes/specials/SpecialBooksources.php', diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index f3495cb5a9..489492627f 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -27,8 +27,7 @@ * page list. * @ingroup SpecialPage */ -class SpecialPage -{ +class SpecialPage { /**#@+ * @access private */ @@ -125,7 +124,7 @@ class SpecialPage 'Contributions' => 'SpecialContributions', 'Listgrouprights' => 'SpecialListGroupRights', 'Listusers' => array( 'SpecialPage', 'Listusers' ), - 'Activeusers' => array( 'SpecialPage', 'Activeusers' ), + 'Activeusers' => 'SpecialActiveUsers', 'Userrights' => 'UserrightsPage', # Recent changes and logs diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php index 0fbb183404..d3ba35b850 100644 --- a/includes/specials/SpecialActiveusers.php +++ b/includes/specials/SpecialActiveusers.php @@ -1,5 +1,4 @@ getText( 'username' ); $this->requestedUser = ''; if ( $un != '' ) { $username = Title::makeTitleSafe( NS_USER, $un ); - if( ! is_null( $username ) ) { + if( !is_null( $username ) ) { $this->requestedUser = $username->getText(); } } parent::__construct(); } - function getIndexField() { return 'rc_user_text'; } @@ -55,23 +49,23 @@ class ActiveUsersPager extends UsersPager { $dbr = wfGetDB( DB_SLAVE ); $conds = array('rc_user > 0'); // Users - no anons $conds[] = 'ipb_deleted IS NULL'; // don't show hidden names - $useIndex = $dbr->useIndexClause('rc_user_text'); - if( $this->requestedUser != "" ) { + $useIndex = $dbr->useIndexClause( 'rc_user_text' ); + if( $this->requestedUser != '' ) { $conds[] = 'rc_user_text >= ' . $dbr->addQuotes( $this->requestedUser ); } - list ($recentchanges,$ipblocks,$user) = $dbr->tableNamesN('recentchanges','ipblocks','user'); + list( $recentchanges, $ipblocks, $user ) = $dbr->tableNamesN( 'recentchanges', 'ipblocks', 'user' ); $query = array( 'tables' => " $recentchanges $useIndex LEFT JOIN $ipblocks ON rc_user=ipb_user AND ipb_auto=0 AND ipb_deleted=1 INNER JOIN $user ON rc_user=user_id ", - 'fields' => array('rc_user_text AS user_name', // inheritance + 'fields' => array( 'rc_user_text AS user_name', // inheritance 'rc_user_text', // for Pager 'MAX(rc_user) AS user_id', 'COUNT(*) AS recentedits', - 'MAX(ipb_user) AS blocked'), - 'options' => array('GROUP BY' => 'rc_user_text'), + 'MAX(ipb_user) AS blocked' ), + 'options' => array( 'GROUP BY' => 'rc_user_text' ), 'conds' => $conds ); return $query; @@ -88,7 +82,7 @@ class ActiveUsersPager extends UsersPager { $groups = implode( ', ', $list ); $item = wfSpecialList( $name, $groups ); - $count = wfMsgExt( 'activeusers-count', array('parsemag'), $row->recentedits, $userName ); + $count = wfMsgExt( 'activeusers-count', array( 'parsemag' ), $row->recentedits, $userName ); $blocked = $row->blocked ? ' ' . wfMsgExt( 'listusers-blocked', array( 'parsemag' ), $userName ) : ''; return "
  • {$item} [{$count}]{$blocked}
  • "; @@ -102,7 +96,7 @@ class ActiveUsersPager extends UsersPager { $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) . '
    ' . Xml::element( 'legend', array(), wfMsg( 'activeusers' ) ); - $out .= Xml::hidden( 'title', $self->getPrefixedDbKey() ); + $out .= Xml::hidden( 'title', $self->getPrefixedDBkey() ); # Username field $out .= Xml::label( wfMsg( 'activeusers-from' ), 'offset' ) . ' ' . @@ -120,24 +114,41 @@ class ActiveUsersPager extends UsersPager { } /** - * constructor - * $par string (optional) A group to list users from + * @ingroup SpecialPage */ -function wfSpecialActiveusers( $par = null ) { - global $wgRequest, $wgOut; - - $up = new ActiveUsersPager(); - - # getBody() first to check, if empty - $usersbody = $up->getBody(); - $s = $up->getPageHeader(); - if( $usersbody ) { - $s .= $up->getNavigationBar(); - $s .= ''; - $s .= $up->getNavigationBar() ; - } else { - $s .= '

    ' . wfMsgHTML('activeusers-noresult') . '

    '; - }; - - $wgOut->addHTML( $s ); -} +class SpecialActiveUsers extends SpecialPage { + + /** + * Constructor + */ + public function __construct() { + parent::__construct( 'ActiveUsers' ); + } + + /** + * Show the special page + * + * @param $par Mixed: parameter passed to the page or null + */ + public function execute( $par ) { + global $wgOut; + + $this->setHeaders(); + + $up = new ActiveUsersPager(); + + # getBody() first to check, if empty + $usersbody = $up->getBody(); + $s = $up->getPageHeader(); + if( $usersbody ) { + $s .= $up->getNavigationBar(); + $s .= ''; + $s .= $up->getNavigationBar(); + } else { + $s .= '

    ' . wfMsgHtml( 'activeusers-noresult' ) . '

    '; + } + + $wgOut->addHTML( $s ); + } + +} \ No newline at end of file