r108121 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108120‎ | r108121 | r108122 >
Date:09:04, 5 January 2012
Author:siebrand
Status:ok (Comments)
Tags:
Comment:
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.
Modified paths:
  • /trunk/extensions/ContributionScores/ContributionScores.php (modified) (history)
  • /trunk/extensions/ContributionScores/ContributionScores_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ContributionScores/ContributionScores_body.php
@@ -17,10 +17,6 @@
1818 parent::__construct( 'ContributionScores' );
1919 }
2020
21 - function getDescription() {
22 - return wfMsg( 'contributionscores' );
23 - }
24 -
2521 ///Generates a "Contribution Scores" table for a given LIMIT and date range
2622 /**
2723 * Function generates Contribution Scores tables in HTML format (not wikiText)
@@ -31,7 +27,7 @@
3228 * @return HTML Table representing the requested Contribution Scores.
3329 */
3430 function genContributionScoreTable( $days, $limit, $title = null, $options = 'none' ) {
35 - global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgUser, $wgLang;
 31+ global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgLang;
3632
3733 $opts = explode( ',', strtolower( $options ) );
3834
@@ -95,32 +91,36 @@
9692
9793 $output = "<table class=\"wikitable contributionscores plainlinks{$sortable}\" >\n".
9894 "<tr class='header'>\n".
99 - "<th>" . wfMsgHtml( 'contributionscores-score' ) . "</th>\n" .
100 - "<th>" . wfMsgHtml( 'contributionscores-pages' ) . "</th>\n" .
101 - "<th>" . wfMsgHtml( 'contributionscores-changes' ) . "</th>\n" .
102 - "<th>" . wfMsgHtml( 'contributionscores-username' ) . "</th>\n";
 95+ Html::element( 'th', array(), wfMsg( 'contributionscores-score' ) ) .
 96+ Html::element( 'th', array(), wfMsg( 'contributionscores-pages' ) ) .
 97+ Html::element( 'th', array(), wfMsg( 'contributionscores-changes' ) ) .
 98+ Html::element( 'th', array(), wfMsg( 'contributionscores-username' ) );
10399
104 - $skin = $wgUser->getSkin();
105100 $altrow = '';
106101 foreach ( $res as $row ) {
107 - $output .= "</tr><tr class='{$altrow}'>\n<td class='content'>" .
 102+ $output .= Html::closeElement( 'tr' );
 103+ $output .= "<tr class='{$altrow}'>\n<td class='content'>" .
108104 $wgLang->formatNum( round( $row->wiki_rank, 0 ) ) . "\n</td><td class='content'>" .
109105 $wgLang->formatNum( $row->page_count ) . "\n</td><td class='content'>" .
110106 $wgLang->formatNum( $row->rev_count ) . "\n</td><td class='content'>" .
111 - $skin->userLink( $row->user_id, $row->user_name );
 107+ Linker::userLink( $row->user_id, $row->user_name );
112108
113109 # Option to not display user tools
114 - if ( !in_array( 'notools', $opts ) )
115 - $output .= $skin->userToolLinks( $row->user_id, $row->user_name );
 110+ if ( !in_array( 'notools', $opts ) ) {
 111+ $output .= Linker::userToolLinks( $row->user_id, $row->user_name );
 112+ }
116113
117 - $output .= "</td>\n";
 114+ $output .= Html::closeElement( 'td' ) . "\n";
118115
119 - if ( $altrow == '' && empty( $sortable ) )
 116+ if ( $altrow == '' && empty( $sortable ) ) {
120117 $altrow = 'odd ';
121 - else
 118+ } else {
122119 $altrow = '';
 120+ }
123121 }
124 - $output .= "</tr></table>";
 122+ $output .= Html::closeElement( 'tr' );
 123+ $output .= Html::closeElement( 'table' );
 124+
125125 $dbr->freeResult( $res );
126126
127127 if ( !empty( $title ) )
@@ -145,6 +145,7 @@
146146 } else {
147147 $this->showPage();
148148 }
 149+
149150 return true;
150151 }
151152
Index: trunk/extensions/ContributionScores/ContributionScores.php
@@ -15,23 +15,23 @@
1616 'url' => 'https://www.mediawiki.org/wiki/Extension:Contribution_Scores',
1717 'author' => 'Tim Laqua',
1818 'descriptionmsg' => 'contributionscores-desc',
19 - 'version' => '1.12'
 19+ 'version' => '1.13'
2020 );
2121
22 -define( 'CONTRIBUTIONSCORES_PATH', dirname( __FILE__ ) );
23 -define( 'CONTRIBUTIONSCORES_EXTPATH', str_replace( $_SERVER['DOCUMENT_ROOT'], '/', CONTRIBUTIONSCORES_PATH ) );
 22+$dir = dirname( __FILE__ ) . '/';
 23+
2424 define( 'CONTRIBUTIONSCORES_MAXINCLUDELIMIT', 50 );
2525 $wgContribScoreReports = null;
2626 $wgContribScoreIgnoreBlockedUsers = false;
2727 $wgContribScoreIgnoreBots = false;
2828 $wgContribScoreDisableCache = false;
2929
30 -$wgAutoloadClasses['ContributionScores'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores_body.php';
 30+$wgAutoloadClasses['ContributionScores'] = $dir . 'ContributionScores_body.php';
3131 $wgSpecialPages['ContributionScores'] = 'ContributionScores';
3232 $wgSpecialPageGroups['ContributionScores'] = 'wiki';
3333
34 -$wgExtensionMessagesFiles['ContributionScores'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores.i18n.php';
35 -$wgExtensionMessagesFiles['ContributionScoresAlias'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores.alias.php';
 34+$wgExtensionMessagesFiles['ContributionScores'] = $dir . 'ContributionScores.i18n.php';
 35+$wgExtensionMessagesFiles['ContributionScoresAlias'] = $dir . 'ContributionScores.alias.php';
3636
3737 $wgHooks['LanguageGetMagic'][] = 'efContributionScores_LanguageGetMagic';
3838

Comments

#Comment by Nikerabbit (talk | contribs)   09:33, 5 January 2012

It's also possible to do "$dir/ContributionScores.alias.php". It's matter of taste.

Status & tagging log