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:
parent
f0cd952fc0
commit
f1e3ad6c82
2 changed files with 25 additions and 24 deletions
|
@ -15,23 +15,23 @@ $wgExtensionCredits['specialpage'][] = array(
|
||||||
'url' => 'https://www.mediawiki.org/wiki/Extension:Contribution_Scores',
|
'url' => 'https://www.mediawiki.org/wiki/Extension:Contribution_Scores',
|
||||||
'author' => 'Tim Laqua',
|
'author' => 'Tim Laqua',
|
||||||
'descriptionmsg' => 'contributionscores-desc',
|
'descriptionmsg' => 'contributionscores-desc',
|
||||||
'version' => '1.12'
|
'version' => '1.13'
|
||||||
);
|
);
|
||||||
|
|
||||||
define( 'CONTRIBUTIONSCORES_PATH', dirname( __FILE__ ) );
|
$dir = dirname( __FILE__ ) . '/';
|
||||||
define( 'CONTRIBUTIONSCORES_EXTPATH', str_replace( $_SERVER['DOCUMENT_ROOT'], '/', CONTRIBUTIONSCORES_PATH ) );
|
|
||||||
define( 'CONTRIBUTIONSCORES_MAXINCLUDELIMIT', 50 );
|
define( 'CONTRIBUTIONSCORES_MAXINCLUDELIMIT', 50 );
|
||||||
$wgContribScoreReports = null;
|
$wgContribScoreReports = null;
|
||||||
$wgContribScoreIgnoreBlockedUsers = false;
|
$wgContribScoreIgnoreBlockedUsers = false;
|
||||||
$wgContribScoreIgnoreBots = false;
|
$wgContribScoreIgnoreBots = false;
|
||||||
$wgContribScoreDisableCache = false;
|
$wgContribScoreDisableCache = false;
|
||||||
|
|
||||||
$wgAutoloadClasses['ContributionScores'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores_body.php';
|
$wgAutoloadClasses['ContributionScores'] = $dir . 'ContributionScores_body.php';
|
||||||
$wgSpecialPages['ContributionScores'] = 'ContributionScores';
|
$wgSpecialPages['ContributionScores'] = 'ContributionScores';
|
||||||
$wgSpecialPageGroups['ContributionScores'] = 'wiki';
|
$wgSpecialPageGroups['ContributionScores'] = 'wiki';
|
||||||
|
|
||||||
$wgExtensionMessagesFiles['ContributionScores'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores.i18n.php';
|
$wgExtensionMessagesFiles['ContributionScores'] = $dir . 'ContributionScores.i18n.php';
|
||||||
$wgExtensionMessagesFiles['ContributionScoresAlias'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores.alias.php';
|
$wgExtensionMessagesFiles['ContributionScoresAlias'] = $dir . 'ContributionScores.alias.php';
|
||||||
|
|
||||||
$wgHooks['LanguageGetMagic'][] = 'efContributionScores_LanguageGetMagic';
|
$wgHooks['LanguageGetMagic'][] = 'efContributionScores_LanguageGetMagic';
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,6 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
parent::__construct( 'ContributionScores' );
|
parent::__construct( 'ContributionScores' );
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDescription() {
|
|
||||||
return wfMsg( 'contributionscores' );
|
|
||||||
}
|
|
||||||
|
|
||||||
///Generates a "Contribution Scores" table for a given LIMIT and date range
|
///Generates a "Contribution Scores" table for a given LIMIT and date range
|
||||||
/**
|
/**
|
||||||
* Function generates Contribution Scores tables in HTML format (not wikiText)
|
* 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.
|
* @return HTML Table representing the requested Contribution Scores.
|
||||||
*/
|
*/
|
||||||
function genContributionScoreTable( $days, $limit, $title = null, $options = 'none' ) {
|
function genContributionScoreTable( $days, $limit, $title = null, $options = 'none' ) {
|
||||||
global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgUser, $wgLang;
|
global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgLang;
|
||||||
|
|
||||||
$opts = explode( ',', strtolower( $options ) );
|
$opts = explode( ',', strtolower( $options ) );
|
||||||
|
|
||||||
|
@ -95,32 +91,36 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
|
|
||||||
$output = "<table class=\"wikitable contributionscores plainlinks{$sortable}\" >\n".
|
$output = "<table class=\"wikitable contributionscores plainlinks{$sortable}\" >\n".
|
||||||
"<tr class='header'>\n".
|
"<tr class='header'>\n".
|
||||||
"<th>" . wfMsgHtml( 'contributionscores-score' ) . "</th>\n" .
|
Html::element( 'th', array(), wfMsg( 'contributionscores-score' ) ) .
|
||||||
"<th>" . wfMsgHtml( 'contributionscores-pages' ) . "</th>\n" .
|
Html::element( 'th', array(), wfMsg( 'contributionscores-pages' ) ) .
|
||||||
"<th>" . wfMsgHtml( 'contributionscores-changes' ) . "</th>\n" .
|
Html::element( 'th', array(), wfMsg( 'contributionscores-changes' ) ) .
|
||||||
"<th>" . wfMsgHtml( 'contributionscores-username' ) . "</th>\n";
|
Html::element( 'th', array(), wfMsg( 'contributionscores-username' ) );
|
||||||
|
|
||||||
$skin = $wgUser->getSkin();
|
|
||||||
$altrow = '';
|
$altrow = '';
|
||||||
foreach ( $res as $row ) {
|
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( round( $row->wiki_rank, 0 ) ) . "\n</td><td class='content'>" .
|
||||||
$wgLang->formatNum( $row->page_count ) . "\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'>" .
|
$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
|
# Option to not display user tools
|
||||||
if ( !in_array( 'notools', $opts ) )
|
if ( !in_array( 'notools', $opts ) ) {
|
||||||
$output .= $skin->userToolLinks( $row->user_id, $row->user_name );
|
$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 ';
|
$altrow = 'odd ';
|
||||||
else
|
} else {
|
||||||
$altrow = '';
|
$altrow = '';
|
||||||
}
|
}
|
||||||
$output .= "</tr></table>";
|
}
|
||||||
|
$output .= Html::closeElement( 'tr' );
|
||||||
|
$output .= Html::closeElement( 'table' );
|
||||||
|
|
||||||
$dbr->freeResult( $res );
|
$dbr->freeResult( $res );
|
||||||
|
|
||||||
if ( !empty( $title ) )
|
if ( !empty( $title ) )
|
||||||
|
@ -145,6 +145,7 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
} else {
|
} else {
|
||||||
$this->showPage();
|
$this->showPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue