diff --git a/.gitignore b/.gitignore
index c798be9..bac39c7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
-.svn
*~
*.kate-swp
.*.swp
.idea
+node_modules/
+/composer.lock
+/vendor/
diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1 @@
+node_modules
diff --git a/ContributionScores.i18n.php b/ContributionScores.i18n.php
deleted file mode 100644
index d6a010c..0000000
--- a/ContributionScores.i18n.php
+++ /dev/null
@@ -1,35 +0,0 @@
- 'https://www.mediawiki.org/wiki/Extension:Contribution_Scores',
'author' => 'Tim Laqua',
'descriptionmsg' => 'contributionscores-desc',
- 'version' => '1.17.0'
+ 'version' => '1.23.0'
);
-$dir = dirname( __FILE__ ) . '/';
-
define( 'CONTRIBUTIONSCORES_MAXINCLUDELIMIT', 50 );
$wgContribScoreReports = null;
// These settings can be overridden in LocalSettings.php.
-$wgContribScoreIgnoreBlockedUsers = false; // Set to true to exclude bots from the reporting.
-$wgContribScoreIgnoreBots = false; // Set to true to exclude blocked users from the reporting.
-$wgContribScoresUseRealName = false; // Set to true to use real user names when available. Only for MediaWiki 1.19 and later.
-$wgContribScoreDisableCache = false; // Set to true to disable cache for parser function and inclusion of table.
-$wgAutoloadClasses['ContributionScores'] = $dir . 'ContributionScores_body.php';
+// Set to true to exclude bots from the reporting.
+$wgContribScoreIgnoreBlockedUsers = false;
+
+// Set to true to exclude blocked users from the reporting.
+$wgContribScoreIgnoreBots = false;
+
+// Set to true to use real user names when available. Only for MediaWiki 1.19 and later.
+$wgContribScoresUseRealName = false;
+
+// Set to true to disable cache for parser function and inclusion of table.
+$wgContribScoreDisableCache = false;
+
+$wgAutoloadClasses['ContributionScores'] = __DIR__ . '/ContributionScores_body.php';
$wgSpecialPages['ContributionScores'] = 'ContributionScores';
$wgMessagesDirs['ContributionScores'] = __DIR__ . '/i18n';
-$wgExtensionMessagesFiles['ContributionScores'] = $dir . 'ContributionScores.i18n.php';
-$wgExtensionMessagesFiles['ContributionScoresAlias'] = $dir . 'ContributionScores.alias.php';
-$wgExtensionMessagesFiles['ContributionScoresMagic'] = $dir . 'ContributionScores.i18n.magic.php';
+$wgExtensionMessagesFiles['ContributionScoresAlias'] = __DIR__ . '/ContributionScores.alias.php';
+$wgExtensionMessagesFiles['ContributionScoresMagic'] =
+ __DIR__ . '/ContributionScores.i18n.magic.php';
$wgHooks['ParserFirstCallInit'][] = 'efContributionScores_Setup';
function efContributionScores_Setup( &$parser ) {
$parser->setFunctionHook( 'cscore', 'efContributionScores_Render' );
+
return true;
}
@@ -59,21 +66,20 @@ function efContributionScores_Render( &$parser, $usertext, $metric = 'score' ) {
if ( $metric == 'score' ) {
$res = $dbr->select( 'revision',
- 'COUNT(DISTINCT rev_page)+SQRT(COUNT(rev_id)-COUNT(DISTINCT rev_page))*2 AS wiki_rank',
- array( 'rev_user' => $user->getID() ) );
+ 'COUNT(DISTINCT rev_page)+SQRT(COUNT(rev_id)-COUNT(DISTINCT rev_page))*2 AS wiki_rank',
+ array( 'rev_user' => $user->getID() ) );
$row = $dbr->fetchObject( $res );
$output = $wgLang->formatNum( round( $row->wiki_rank, 0 ) );
} elseif ( $metric == 'changes' ) {
$res = $dbr->select( 'revision',
- 'COUNT(rev_id) AS rev_count',
- array( 'rev_user' => $user->getID() ) );
+ 'COUNT(rev_id) AS rev_count',
+ array( 'rev_user' => $user->getID() ) );
$row = $dbr->fetchObject( $res );
$output = $wgLang->formatNum( $row->rev_count );
-
} elseif ( $metric == 'pages' ) {
$res = $dbr->select( 'revision',
- 'COUNT(DISTINCT rev_page) AS page_count',
- array( 'rev_user' => $user->getID() ) );
+ 'COUNT(DISTINCT rev_page) AS page_count',
+ array( 'rev_user' => $user->getID() ) );
$row = $dbr->fetchObject( $res );
$output = $wgLang->formatNum( $row->page_count );
} else {
diff --git a/ContributionScores_body.php b/ContributionScores_body.php
index 36dfd06..cabc238 100644
--- a/ContributionScores_body.php
+++ b/ContributionScores_body.php
@@ -1,7 +1,7 @@
0)";
+ $sqlWhere .= " {$nextPrefix} rev_user NOT IN " .
+ "(SELECT ipb_user FROM {$ipBlocksTable} WHERE ipb_user <> 0)";
$nextPrefix = "AND";
}
if ( $wgContribScoreIgnoreBots ) {
- $sqlWhere .= " {$nextPrefix} rev_user NOT IN (SELECT ug_user FROM {$userGroupTable} WHERE ug_group='bot')";
+ $sqlWhere .= " {$nextPrefix} rev_user NOT IN " .
+ "(SELECT ug_user FROM {$userGroupTable} WHERE ug_group='bot')";
}
$sqlMostPages = "SELECT rev_user,
@@ -67,7 +69,7 @@ class ContributionScores extends IncludableSpecialPage {
ORDER BY page_count DESC
LIMIT {$limit}";
- $sqlMostRevs = "SELECT rev_user,
+ $sqlMostRevs = "SELECT rev_user,
COUNT(DISTINCT rev_page) AS page_count,
COUNT(rev_id) AS rev_count
FROM {$revTable}
@@ -118,11 +120,16 @@ class ContributionScores extends IncludableSpecialPage {
}
$output .= Html::closeElement( 'tr' );
- $output .= "
\n" .
- $lang->formatNum( round( $user_rank, 0 ) ) . "\n | " .
- $lang->formatNum( round( $row->wiki_rank, 0 ) ) . "\n | " .
- $lang->formatNum( $row->page_count ) . "\n | " .
- $lang->formatNum( $row->rev_count ) . "\n | " .
+ $output .= " |
\n" .
+ "" .
+ $lang->formatNum( round( $user_rank, 0 ) ) .
+ "\n | " .
+ $lang->formatNum( round( $row->wiki_rank, 0 ) ) .
+ "\n | " .
+ $lang->formatNum( $row->page_count ) .
+ "\n | " .
+ $lang->formatNum( $row->rev_count ) .
+ "\n | " .
$userLink;
# Option to not display user tools
@@ -150,16 +157,16 @@ class ContributionScores extends IncludableSpecialPage {
array(
'style' => 'border-spacing: 0; padding: 0',
'class' => 'contributionscores-wrapper',
- 'lang' => htmlspecialchars( $lang->getCode()),
+ 'lang' => htmlspecialchars( $lang->getCode() ),
'dir' => $lang->getDir()
),
"\n" .
- " |
\n" .
- "{$title} | \n" .
- "
\n" .
- "\n" .
- "{$output} | \n" .
- "
\n"
+ "\n" .
+ "{$title} | \n" .
+ "
\n" .
+ "\n" .
+ "{$output} | \n" .
+ "
\n"
);
return $output;
@@ -213,9 +220,17 @@ class ContributionScores extends IncludableSpecialPage {
} else {
$reportTitle = $this->msg( 'contributionscores-allrevisions' )->text();
}
- $reportTitle .= " " . $this->msg( 'contributionscores-top' )->numParams( $limit )->text();
- $title = Xml::element( 'h4', array( 'class' => 'contributionscores-title' ), $reportTitle ) . "\n";
- $this->getOutput()->addHTML( $this->genContributionScoreTable( $days, $limit, $title, $options ) );
+ $reportTitle .= ' ' . $this->msg( 'contributionscores-top' )->numParams( $limit )->text();
+ $title = Xml::element( 'h4',
+ array( 'class' => 'contributionscores-title' ),
+ $reportTitle
+ ) . "\n";
+ $this->getOutput()->addHTML( $this->genContributionScoreTable(
+ $days,
+ $limit,
+ $title,
+ $options
+ ) );
}
/**
@@ -242,8 +257,11 @@ class ContributionScores extends IncludableSpecialPage {
} else {
$reportTitle = $this->msg( 'contributionscores-allrevisions' )->text();
}
- $reportTitle .= " " . $this->msg( 'contributionscores-top' )->numParams( $revs )->text();
- $title = Xml::element( 'h2', array( 'class' => 'contributionscores-title' ), $reportTitle ) . "\n";
+ $reportTitle .= ' ' . $this->msg( 'contributionscores-top' )->numParams( $revs )->text();
+ $title = Xml::element( 'h2',
+ array( 'class' => 'contributionscores-title' ),
+ $reportTitle
+ ) . "\n";
$out->addHTML( $title );
$out->addHTML( $this->genContributionScoreTable( $days, $revs ) );
}
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 0000000..1c93271
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,26 @@
+/*jshint node:true */
+module.exports = function ( grunt ) {
+ grunt.loadNpmTasks( 'grunt-contrib-jshint' );
+ grunt.loadNpmTasks( 'grunt-banana-checker' );
+ grunt.loadNpmTasks( 'grunt-jsonlint' );
+
+ grunt.initConfig( {
+ jshint: {
+ all: [
+ '*.js'
+ ]
+ },
+ banana: {
+ all: 'i18n/'
+ },
+ jsonlint: {
+ all: [
+ '**/*.json',
+ '!node_modules/**'
+ ]
+ }
+ } );
+
+ grunt.registerTask( 'test', [ 'jshint', 'jsonlint', 'banana' ] );
+ grunt.registerTask( 'default', 'test' );
+};
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..4365e8a
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,12 @@
+{
+ "require-dev": {
+ "jakub-onderka/php-parallel-lint": "0.9",
+ "mediawiki/mediawiki-codesniffer": "0.4.0"
+ },
+ "scripts": {
+ "test": [
+ "parallel-lint . --exclude vendor",
+ "phpcs -p -s"
+ ]
+ }
+}
diff --git a/i18n/en.json b/i18n/en.json
index d9357e3..6e58f9b 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -1,18 +1,18 @@
{
- "@metadata": {
- "authors": []
- },
- "contributionscores": "Contribution scores",
- "contributionscores-desc": "Polls the wiki database for highest [[Special:ContributionScores|user contribution volume]]",
- "contributionscores-info": "The score primarily measures unique pages edited, with consideration for high edit volume.",
- "contributionscores-top": "(Top $1)",
- "contributionscores-days": "Last {{PLURAL:$1|day|$1 days}}",
- "contributionscores-allrevisions": "All time",
- "contributionscores-score": "Score",
- "contributionscores-rank": "Rank",
- "contributionscores-pages": "Pages",
- "contributionscores-changes": "Changes",
- "contributionscores-username": "Username",
- "contributionscores-invalidusername": "Invalid username",
- "contributionscores-invalidmetric": "Invalid metric"
+ "@metadata": {
+ "authors": []
+ },
+ "contributionscores": "Contribution scores",
+ "contributionscores-desc": "Polls the wiki database for highest [[Special:ContributionScores|user contribution volume]]",
+ "contributionscores-info": "The score primarily measures unique pages edited, with consideration for high edit volume.",
+ "contributionscores-top": "(Top $1)",
+ "contributionscores-days": "Last {{PLURAL:$1|day|$1 days}}",
+ "contributionscores-allrevisions": "All time",
+ "contributionscores-score": "Score",
+ "contributionscores-rank": "Rank",
+ "contributionscores-pages": "Pages",
+ "contributionscores-changes": "Changes",
+ "contributionscores-username": "Username",
+ "contributionscores-invalidusername": "Invalid username",
+ "contributionscores-invalidmetric": "Invalid metric"
}
\ No newline at end of file
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..094b8ea
--- /dev/null
+++ b/package.json
@@ -0,0 +1,13 @@
+{
+ "private": true,
+ "scripts": {
+ "test": "grunt test"
+ },
+ "devDependencies": {
+ "grunt": "0.4.5",
+ "grunt-cli": "0.1.13",
+ "grunt-contrib-jshint": "0.11.3",
+ "grunt-banana-checker": "0.2.2",
+ "grunt-jsonlint": "1.0.4"
+ }
+}
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..d81a292
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,8 @@
+
+
+
+ .
+
+
+ vendor
+