r84856 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84855‎ | r84856 | r84857 >
Date:16:49, 27 March 2011
Author:happy-melon
Status:reverted (Comments)
Tags:
Comment:
Follow-up r84805: convert SpecialActiveusers to not use the now-absent UsersPager.
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
@@ -585,7 +585,6 @@
586586
587587 # includes/specials
588588 'SpecialAllmessages' => 'includes/specials/SpecialAllmessages.php',
589 - 'ActiveUsersPager' => 'includes/specials/SpecialActiveusers.php',
590589 'AllmessagesTablePager' => 'includes/specials/SpecialAllmessages.php',
591590 'AncientPagesPage' => 'includes/specials/SpecialAncientpages.php',
592591 '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 - *
 263+ * Also called by SpecialActiveUsers
264264 * @param $group String: group name
265265 * @return string
266266 */
267 - protected static function buildGroupLink( $group ) {
 267+ public 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 ActiveUsersPager extends UsersPager {
 34+class SpecialActiveUsers extends QueryPage {
3535
3636 /**
3737 * @var FormOptions
@@ -56,7 +56,7 @@
5757
5858 $this->setupOptions();
5959
60 - parent::__construct();
 60+ parent::__construct( 'Activeusers' );
6161 }
6262
6363 public function setupOptions() {
@@ -66,6 +66,8 @@
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 );
7072
7173 $this->opts->fetchValuesFromRequest( $wgRequest );
7274
@@ -78,8 +80,8 @@
7981 }
8082 }
8183
82 - function getIndexField() {
83 - return 'rc_user_text';
 84+ function getOrderFields() {
 85+ return array( 'rc_user_text', 'user_id' );
8486 }
8587
8688 function getQueryInfo() {
@@ -114,19 +116,23 @@
115117 return $query;
116118 }
117119
118 - function formatRow( $row ) {
 120+ function formatResult( $skin, $row ) {
119121 global $wgLang;
120122 $userName = $row->user_name;
121123
122 - $ulinks = $this->getSkin()->userLink( $row->user_id, $userName );
123 - $ulinks .= $this->getSkin()->userToolLinks( $row->user_id, $userName );
 124+ $ulinks = $skin->userLink( $row->user_id, $userName );
 125+ $ulinks .= $skin->userToolLinks( $row->user_id, $userName );
124126
125127 $list = array();
126 - foreach( self::getGroups( $row->user_id ) as $group ) {
 128+ $user = User::newFromId( $row->user_id );
 129+ foreach( $user->getEffectiveGroups() as $group ) {
127130 if ( isset( $this->groups[$group] ) ) {
128 - return;
 131+ return false;
129132 }
130 - $list[] = self::buildGroupLink( $group );
 133+ if( in_array( $group, array( '*', 'user' ) ) ){
 134+ continue;
 135+ }
 136+ $list[] = SpecialListUsers::buildGroupLink( $group );
131137 }
132138 $groups = $wgLang->commaList( $list );
133139
@@ -139,18 +145,35 @@
140146 );
141147 $blocked = $row->blocked ? ' ' . wfMsgExt( 'listusers-blocked', array( 'parsemag' ), $userName ) : '';
142148
143 - return Html::rawElement( 'li', array(), "{$item} [{$count}]{$blocked}" );
 149+ return "{$item} [{$count}]{$blocked}";
144150 }
145151
 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+
146160 function getPageHeader() {
147 - global $wgScript;
 161+ global $wgScript, $wgActiveUserDays, $wgLang;
148162
149163 $self = $this->getTitle();
150 - $limit = $this->mLimit ? Html::hidden( 'limit', $this->mLimit ) : '';
 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+ : '';
151170
152 - $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ); # Form tag
 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
153176 $out .= Xml::fieldset( wfMsg( 'activeusers' ) ) . "\n";
154 - $out .= Html::hidden( 'title', $self->getPrefixedDBkey() ) . $limit . "\n";
 177+ $out .= Html::hidden( 'title', $self->getPrefixedDBkey() ) . $limit . $offset . "\n";
155178
156179 $out .= Xml::inputLabel( wfMsg( 'activeusers-from' ), 'username', 'offset', 20, $this->requestedUser ) . '<br />';# Username field
157180
@@ -164,50 +187,4 @@
165188
166189 return $out;
167190 }
168 -}
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 -}
 191+}
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r85892Revert r84856: restore version that works before destruction of the UsersPage...brion17:08, 12 April 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84805Convert SpecialListusers to subclass SpecialPage. Only two left now!happy-melon16:40, 26 March 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   17:09, 12 April 2011

Reverted in r85892 to match the revert of r84805 in r85889.

Status & tagging log