From f1e3ad6c82c06426f96c74b91674e4087ece7474 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 5 Jan 2012 09:04:02 +0000 Subject: [PATCH] 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. --- ContributionScores.php | 12 ++++++------ ContributionScores_body.php | 37 +++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/ContributionScores.php b/ContributionScores.php index f23b316..dafb80c 100644 --- a/ContributionScores.php +++ b/ContributionScores.php @@ -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'; diff --git a/ContributionScores_body.php b/ContributionScores_body.php index b8497fe..22ed520 100644 --- a/ContributionScores_body.php +++ b/ContributionScores_body.php @@ -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 = "\n". "\n". - "\n" . - "\n" . - "\n" . - "\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 .= "\n\n\n"; + $output .= Html::closeElement( 'td' ) . "\n"; - if ( $altrow == '' && empty( $sortable ) ) + if ( $altrow == '' && empty( $sortable ) ) { $altrow = 'odd '; - else + } else { $altrow = ''; + } } - $output .= "
" . wfMsgHtml( 'contributionscores-score' ) . "" . wfMsgHtml( 'contributionscores-pages' ) . "" . wfMsgHtml( 'contributionscores-changes' ) . "" . wfMsgHtml( 'contributionscores-username' ) . "
" . + $output .= Html::closeElement( 'tr' ); + $output .= "
" . $wgLang->formatNum( round( $row->wiki_rank, 0 ) ) . "\n" . $wgLang->formatNum( $row->page_count ) . "\n" . $wgLang->formatNum( $row->rev_count ) . "\n" . - $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 .= "
"; + $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; }