Thread:Extension talk:Contribution Scores/Add column for rank

I wanted a column to show the user's rank in the table. That way it is a little easier to see where you stand in a list of 50 people. The Score column is great and is what is used for Rank but if people start raising their Score they still need an easy way to see if they are improving their relative position among the other editors.

I made the following changes in ContributionsScore_body.php (lines 107-145):

Old code: $altrow = '';

foreach ( $res as $row ) { // Use real name if option used and real name present. if ( $wgContribScoresUseRealName && $row->user_real_name !== '' ) { $userLink = Linker::userLink(					$row->user_id,					$row->user_name,					$row->user_real_name				); } else { $userLink = Linker::userLink(					$row->user_id,					$row->user_name				); }

$output .= Html::closeElement( 'tr' ); $output .= "\n". $wgLang->formatNum( round( $row->wiki_rank, 0 ) ). "\n ". $wgLang->formatNum( $row->page_count ). "\n ". $wgLang->formatNum( $row->rev_count ). "\n ". $userLink;

# Option to not display user tools if ( !in_array( 'notools', $opts ) ) { $output .= Linker::userToolLinks( $row->user_id, $row->user_name ); }

$output .= Html::closeElement( 'td' ). "\n";

if ( $altrow == '' && empty( $sortable ) ) { $altrow = 'odd '; } else { $altrow = ''; }		}

New code: $altrow = ''; $userRank = 1;

foreach ( $res as $row ) { // Use real name if option used and real name present. if ( $wgContribScoresUseRealName && $row->user_real_name !== '' ) { $userLink = Linker::userLink(					$row->user_id,					$row->user_name,					$row->user_real_name				); } else { $userLink = Linker::userLink(					$row->user_id,					$row->user_name				); }

$output .= Html::closeElement( 'tr' ); $output .= "\n". $wgLang->formatNum( round( $userRank, 0 ) ). "\n ". $wgLang->formatNum( round( $row->wiki_rank, 0 ) ). "\n ". $wgLang->formatNum( $row->page_count ). "\n ". $wgLang->formatNum( $row->rev_count ). "\n ". $userLink;

# Option to not display user tools if ( !in_array( 'notools', $opts ) ) { $output .= Linker::userToolLinks( $row->user_id, $row->user_name ); }

$output .= Html::closeElement( 'td' ). "\n";

if ( $altrow == '' && empty( $sortable ) ) { $altrow = 'odd '; } else { $altrow = ''; }			$userRank++; }

In addition to the new column, I right-justified the numeric columns. Keep in mind that this code is not fully-baked in that there are several items that are hard-coded.

Enjoy!