Minor refactoring:

* remove unused constant CONTRIBUTIONSCORES_EXTPATH
* replace CONTRIBUTIONSCORES_PATH constant by more often used $dir
* remove superfluous getDescription()
* remove use of some unneeded/unused globals
* use Html functions instead of raw HTML in some cases.
This commit is contained in:
Siebrand Mazeland 2012-01-05 09:04:02 +00:00
parent f0cd952fc0
commit f1e3ad6c82
2 changed files with 25 additions and 24 deletions

View file

@ -15,23 +15,23 @@ $wgExtensionCredits['specialpage'][] = array(
'url' => 'https://www.mediawiki.org/wiki/Extension:Contribution_Scores',
'author' => 'Tim Laqua',
'descriptionmsg' => 'contributionscores-desc',
'version' => '1.12'
'version' => '1.13'
);
define( 'CONTRIBUTIONSCORES_PATH', dirname( __FILE__ ) );
define( 'CONTRIBUTIONSCORES_EXTPATH', str_replace( $_SERVER['DOCUMENT_ROOT'], '/', CONTRIBUTIONSCORES_PATH ) );
$dir = dirname( __FILE__ ) . '/';
define( 'CONTRIBUTIONSCORES_MAXINCLUDELIMIT', 50 );
$wgContribScoreReports = null;
$wgContribScoreIgnoreBlockedUsers = false;
$wgContribScoreIgnoreBots = false;
$wgContribScoreDisableCache = false;
$wgAutoloadClasses['ContributionScores'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores_body.php';
$wgAutoloadClasses['ContributionScores'] = $dir . 'ContributionScores_body.php';
$wgSpecialPages['ContributionScores'] = 'ContributionScores';
$wgSpecialPageGroups['ContributionScores'] = 'wiki';
$wgExtensionMessagesFiles['ContributionScores'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores.i18n.php';
$wgExtensionMessagesFiles['ContributionScoresAlias'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores.alias.php';
$wgExtensionMessagesFiles['ContributionScores'] = $dir . 'ContributionScores.i18n.php';
$wgExtensionMessagesFiles['ContributionScoresAlias'] = $dir . 'ContributionScores.alias.php';
$wgHooks['LanguageGetMagic'][] = 'efContributionScores_LanguageGetMagic';

View file

@ -17,10 +17,6 @@ class ContributionScores extends IncludableSpecialPage {
parent::__construct( 'ContributionScores' );
}
function getDescription() {
return wfMsg( 'contributionscores' );
}
///Generates a "Contribution Scores" table for a given LIMIT and date range
/**
* Function generates Contribution Scores tables in HTML format (not wikiText)
@ -31,7 +27,7 @@ class ContributionScores extends IncludableSpecialPage {
* @return HTML Table representing the requested Contribution Scores.
*/
function genContributionScoreTable( $days, $limit, $title = null, $options = 'none' ) {
global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgUser, $wgLang;
global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgLang;
$opts = explode( ',', strtolower( $options ) );
@ -95,32 +91,36 @@ class ContributionScores extends IncludableSpecialPage {
$output = "<table class=\"wikitable contributionscores plainlinks{$sortable}\" >\n".
"<tr class='header'>\n".
"<th>" . wfMsgHtml( 'contributionscores-score' ) . "</th>\n" .
"<th>" . wfMsgHtml( 'contributionscores-pages' ) . "</th>\n" .
"<th>" . wfMsgHtml( 'contributionscores-changes' ) . "</th>\n" .
"<th>" . wfMsgHtml( 'contributionscores-username' ) . "</th>\n";
Html::element( 'th', array(), wfMsg( 'contributionscores-score' ) ) .
Html::element( 'th', array(), wfMsg( 'contributionscores-pages' ) ) .
Html::element( 'th', array(), wfMsg( 'contributionscores-changes' ) ) .
Html::element( 'th', array(), wfMsg( 'contributionscores-username' ) );
$skin = $wgUser->getSkin();
$altrow = '';
foreach ( $res as $row ) {
$output .= "</tr><tr class='{$altrow}'>\n<td class='content'>" .
$output .= Html::closeElement( 'tr' );
$output .= "<tr class='{$altrow}'>\n<td class='content'>" .
$wgLang->formatNum( round( $row->wiki_rank, 0 ) ) . "\n</td><td class='content'>" .
$wgLang->formatNum( $row->page_count ) . "\n</td><td class='content'>" .
$wgLang->formatNum( $row->rev_count ) . "\n</td><td class='content'>" .
$skin->userLink( $row->user_id, $row->user_name );
Linker::userLink( $row->user_id, $row->user_name );
# Option to not display user tools
if ( !in_array( 'notools', $opts ) )
$output .= $skin->userToolLinks( $row->user_id, $row->user_name );
if ( !in_array( 'notools', $opts ) ) {
$output .= Linker::userToolLinks( $row->user_id, $row->user_name );
}
$output .= "</td>\n";
$output .= Html::closeElement( 'td' ) . "\n";
if ( $altrow == '' && empty( $sortable ) )
if ( $altrow == '' && empty( $sortable ) ) {
$altrow = 'odd ';
else
} else {
$altrow = '';
}
}
$output .= "</tr></table>";
$output .= Html::closeElement( 'tr' );
$output .= Html::closeElement( 'table' );
$dbr->freeResult( $res );
if ( !empty( $title ) )
@ -145,6 +145,7 @@ class ContributionScores extends IncludableSpecialPage {
} else {
$this->showPage();
}
return true;
}