r85892 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85891‎ | r85892 | r85893 >
Date:17:08, 12 April 2011
Author:brion
Status:ok
Tags:
Comment:
Revert r84856: restore version that works before destruction of the UsersPager class
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialActiveusers.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialListusers.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/AutoLoader.php
@@ -605,6 +605,7 @@
606606
607607 # includes/specials
608608 'SpecialAllmessages' => 'includes/specials/SpecialAllmessages.php',
 609+ 'ActiveUsersPager' => 'includes/specials/SpecialActiveusers.php',
609610 'AllmessagesTablePager' => 'includes/specials/SpecialAllmessages.php',
610611 'AncientPagesPage' => 'includes/specials/SpecialAncientpages.php',
611612 'BrokenRedirectsPage' => 'includes/specials/SpecialBrokenRedirects.php',
Index: trunk/phase3/includes/specials/SpecialListusers.php
@@ -259,11 +259,11 @@
260260
261261 /**
262262 * Format a link to a group description page
263 - * Also called by SpecialActiveUsers
 263+ *
264264 * @param $group String: group name
265265 * @return string
266266 */
267 - public static function buildGroupLink( $group ) {
 267+ protected static function buildGroupLink( $group ) {
268268 static $cache = array();
269269 if( !isset( $cache[$group] ) )
270270 $cache[$group] = User::makeGroupLinkHtml( $group, htmlspecialchars( User::getGroupMember( $group ) ) );
Index: trunk/phase3/includes/specials/SpecialActiveusers.php
@@ -30,7 +30,7 @@
3131 *
3232 * @ingroup SpecialPage
3333 */
34 -class SpecialActiveUsers extends QueryPage {
 34+class ActiveUsersPager extends UsersPager {
3535
3636 /**
3737 * @var FormOptions
@@ -56,7 +56,7 @@
5757
5858 $this->setupOptions();
5959
60 - parent::__construct( 'Activeusers' );
 60+ parent::__construct();
6161 }
6262
6363 public function setupOptions() {
@@ -66,8 +66,6 @@
6767
6868 $this->opts->add( 'hidebots', false, FormOptions::BOOL );
6969 $this->opts->add( 'hidesysops', false, FormOptions::BOOL );
70 - $this->opts->add( 'limit', 0, FormOptions::INT );
71 - $this->opts->add( 'offset', 0, FormOptions::INT );
7270
7371 $this->opts->fetchValuesFromRequest( $wgRequest );
7472
@@ -80,8 +78,8 @@
8179 }
8280 }
8381
84 - function getOrderFields() {
85 - return array( 'rc_user_text', 'user_id' );
 82+ function getIndexField() {
 83+ return 'rc_user_text';
8684 }
8785
8886 function getQueryInfo() {
@@ -116,23 +114,19 @@
117115 return $query;
118116 }
119117
120 - function formatResult( $skin, $row ) {
 118+ function formatRow( $row ) {
121119 global $wgLang;
122120 $userName = $row->user_name;
123121
124 - $ulinks = $skin->userLink( $row->user_id, $userName );
125 - $ulinks .= $skin->userToolLinks( $row->user_id, $userName );
 122+ $ulinks = $this->getSkin()->userLink( $row->user_id, $userName );
 123+ $ulinks .= $this->getSkin()->userToolLinks( $row->user_id, $userName );
126124
127125 $list = array();
128 - $user = User::newFromId( $row->user_id );
129 - foreach( $user->getEffectiveGroups() as $group ) {
 126+ foreach( self::getGroups( $row->user_id ) as $group ) {
130127 if ( isset( $this->groups[$group] ) ) {
131 - return false;
 128+ return;
132129 }
133 - if( in_array( $group, array( '*', 'user' ) ) ){
134 - continue;
135 - }
136 - $list[] = SpecialListUsers::buildGroupLink( $group );
 130+ $list[] = self::buildGroupLink( $group );
137131 }
138132 $groups = $wgLang->commaList( $list );
139133
@@ -145,35 +139,18 @@
146140 );
147141 $blocked = $row->blocked ? ' ' . wfMsgExt( 'listusers-blocked', array( 'parsemag' ), $userName ) : '';
148142
149 - return "{$item} [{$count}]{$blocked}";
 143+ return Html::rawElement( 'li', array(), "{$item} [{$count}]{$blocked}" );
150144 }
151145
152 - function linkParameters() {
153 - return array(
154 - 'hidebots' => isset( $this->groups['bot'] ),
155 - 'hidesysops' => isset( $this->groups['sysop'] ),
156 - 'username' => $this->requestedUser,
157 - );
158 - }
159 -
160146 function getPageHeader() {
161 - global $wgScript, $wgActiveUserDays, $wgLang;
 147+ global $wgScript;
162148
163149 $self = $this->getTitle();
164 - $limit = $this->opts->getValue( 'limit' )
165 - ? Html::hidden( 'limit', $this->opts->getValue( 'limit' ) )
166 - : '';
167 - $offset = $this->opts->getValue( 'offset' )
168 - ? Html::hidden( 'offset', $this->opts->getValue( 'offset' ) )
169 - : '';
 150+ $limit = $this->mLimit ? Html::hidden( 'limit', $this->mLimit ) : '';
170151
171 - $out = Html::rawElement( 'div', array( 'class' => 'mw-activeusers-intro' ),
172 - wfMsgExt( 'activeusers-intro', array( 'parsemag', 'escape' ), $wgLang->formatNum( $wgActiveUserDays ) )
173 - );
174 -
175 - $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ); # Form tag
 152+ $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ); # Form tag
176153 $out .= Xml::fieldset( wfMsg( 'activeusers' ) ) . "\n";
177 - $out .= Html::hidden( 'title', $self->getPrefixedDBkey() ) . $limit . $offset . "\n";
 154+ $out .= Html::hidden( 'title', $self->getPrefixedDBkey() ) . $limit . "\n";
178155
179156 $out .= Xml::inputLabel( wfMsg( 'activeusers-from' ), 'username', 'offset', 20, $this->requestedUser ) . '<br />';# Username field
180157
@@ -188,3 +165,49 @@
189166 return $out;
190167 }
191168 }
 169+
 170+/**
 171+ * @ingroup SpecialPage
 172+ */
 173+class SpecialActiveUsers extends SpecialPage {
 174+
 175+ /**
 176+ * Constructor
 177+ */
 178+ public function __construct() {
 179+ parent::__construct( 'Activeusers' );
 180+ }
 181+
 182+ /**
 183+ * Show the special page
 184+ *
 185+ * @param $par Mixed: parameter passed to the page or null
 186+ */
 187+ public function execute( $par ) {
 188+ global $wgOut, $wgLang, $wgActiveUserDays;
 189+
 190+ $this->setHeaders();
 191+ $this->outputHeader();
 192+
 193+ $up = new ActiveUsersPager();
 194+
 195+ # getBody() first to check, if empty
 196+ $usersbody = $up->getBody();
 197+
 198+ $s = Html::rawElement( 'div', array( 'class' => 'mw-activeusers-intro' ),
 199+ wfMsgExt( 'activeusers-intro', array( 'parsemag', 'escape' ), $wgLang->formatNum( $wgActiveUserDays ) )
 200+ );
 201+
 202+ $s .= $up->getPageHeader();
 203+ if( $usersbody ) {
 204+ $s .= $up->getNavigationBar();
 205+ $s .= Html::rawElement( 'ul', array(), $usersbody );
 206+ $s .= $up->getNavigationBar();
 207+ } else {
 208+ $s .= Html::element( 'p', array(), wfMsg( 'activeusers-noresult' ) );
 209+ }
 210+
 211+ $wgOut->addHTML( $s );
 212+ }
 213+
 214+}

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84856Follow-up r84805: convert SpecialActiveusers to not use the now-absent UsersP...happy-melon16:49, 27 March 2011

Status & tagging log