Index: trunk/extensions/ContributionScores/ContributionScores_body.php |
— | — | @@ -1,13 +1,35 @@ |
2 | 2 | <?php |
| 3 | +/** \file |
| 4 | +* \brief Contains code for the ContributionScores Class (extends SpecialPage). |
| 5 | +*/ |
| 6 | + |
| 7 | +///Special page class for the Contribution Scores extension |
| 8 | +/** |
| 9 | + * Special page that generates a list of wiki contributors based |
| 10 | + * on edit diversity (unique pages edited) and edit volume (total |
| 11 | + * number of edits. |
| 12 | + * |
| 13 | + * @addtogroup Extensions |
| 14 | + * @author Tim Laqua <t.laqua@gmail.com> |
| 15 | + */ |
3 | 16 | class ContributionScores extends SpecialPage |
4 | 17 | { |
5 | 18 | function ContributionScores() { |
6 | 19 | SpecialPage::SpecialPage("ContributionScores"); |
7 | 20 | self::loadMessages(); |
8 | 21 | } |
9 | | - |
| 22 | + |
| 23 | + ///Generates a "Contribution Scores" table for a given LIMIT and date range |
| 24 | + /** |
| 25 | + * Function generates Contribution Scores tables in HTML format (not wikiText) |
| 26 | + * |
| 27 | + * @param $days int Days in the past to run report for |
| 28 | + * @param $limit int Maximum number of users to return (default 50) |
| 29 | + * |
| 30 | + * @return HTML Table representing the requested Contribution Scores. |
| 31 | + */ |
10 | 32 | function genContributionScoreTable( $days, $limit ) { |
11 | | - global $contribScoreIgnoreBots; |
| 33 | + global $contribScoreIgnoreBots, $wgUser; |
12 | 34 | |
13 | 35 | $dbr =& wfGetDB( DB_SLAVE ); |
14 | 36 | |
— | — | @@ -44,22 +66,23 @@ |
45 | 67 | |
46 | 68 | $res = $dbr->query($sql); |
47 | 69 | |
48 | | - $output = "{|class=\"wikitable sortable\"\n". |
49 | | - "|-\n". |
50 | | - "|style=\"font-weight: bold;\"|Score\n". |
51 | | - "|style=\"font-weight: bold;\"|Pages\n". |
52 | | - "|style=\"font-weight: bold;\"|Changes\n". |
53 | | - "|style=\"font-weight: bold;\"|Username\n"; |
| 70 | + $output = "<table class=\"wikitable sortable\">\n". |
| 71 | + "<tr>\n". |
| 72 | + "<td style=\"font-weight: bold;\">Score</td>\n". |
| 73 | + "<td style=\"font-weight: bold;\">Pages</td>\n". |
| 74 | + "<td style=\"font-weight: bold;\">Changes</td>\n". |
| 75 | + "<td style=\"font-weight: bold;\">Username</td>\n"; |
54 | 76 | |
| 77 | + $skin =& $wgUser->getSkin(); |
55 | 78 | while ( $row = $dbr->fetchObject( $res ) ) { |
56 | | - $wikiUserName = $row->user_name; |
57 | | - $output .= "|-\n|" . |
58 | | - round($row->wiki_rank,0) . "\n|" . |
59 | | - $row->page_count . "\n|" . |
60 | | - $row->rev_count . "\n|" . |
61 | | - "[[User:".$wikiUserName."|".$wikiUserName."]] ([[User_talk:".$wikiUserName."|Talk]] | [[Special:Contributions/".$wikiUserName."|contribs]])" . "\n"; |
| 79 | + $output .= "</tr><tr>\n<td>" . |
| 80 | + round($row->wiki_rank,0) . "\n</td><td>" . |
| 81 | + $row->page_count . "\n</td><td>" . |
| 82 | + $row->rev_count . "\n</td><td>" . |
| 83 | + $skin->userLink( $row->user_id, $row->user_name ) . |
| 84 | + $skin->userToolLinks( $row->user_id, $row->user_name ) . "</td>\n"; |
62 | 85 | } |
63 | | - $output .= "|}"; |
| 86 | + $output .= "</tr></table>"; |
64 | 87 | $dbr->freeResult( $res ); |
65 | 88 | |
66 | 89 | return $output; |
— | — | @@ -80,21 +103,17 @@ |
81 | 104 | array(0,50)); |
82 | 105 | } |
83 | 106 | |
84 | | - $wgOut->addWikiText ("Scores are calculated as follows:\n". |
85 | | - "*1 point for each unique page edited\n". |
86 | | - "*Square Root of (Total Edits Made) - (Total Unique Pages) * 2\n". |
87 | | - "Scores calculated in this manner weight edit diversity over edit volume. Basically, this score measures". |
88 | | - " primarily unique pages edited, with consideration for high edit volume - assumed to be a higher quality ". |
89 | | - "article."); |
| 107 | + $wgOut->addWikiText (wfMsgForContent('contributionscores-info')); |
90 | 108 | |
91 | 109 | foreach ( $contribScoreReports as $scoreReport) { |
92 | 110 | if ( $scoreReport[0] > 0 ) { |
93 | | - $reportTitle = "Last $scoreReport[0] Days"; |
| 111 | + $reportTitle = wfMsgForContent('contributionscores-days', $scoreReport[0]); |
94 | 112 | } else { |
95 | | - $reportTitle = "All Revisions"; |
| 113 | + $reportTitle = wfMsgForContent('contributionscores-allrevisions'); |
96 | 114 | } |
97 | | - $reportTitle .= " (Top $scoreReport[1])"; |
98 | | - $wgOut->addWikiText ("== $reportTitle ==\n".$this->genContributionScoreTable($scoreReport[0],$scoreReport[1])); |
| 115 | + $reportTitle .= " " . wfMsgForContent('contributionscores-top', $scoreReport[1]); |
| 116 | + $wgOut->addWikiText ("== $reportTitle ==\n"); |
| 117 | + $wgOut->addHtml( $this->genContributionScoreTable($scoreReport[0],$scoreReport[1])); |
99 | 118 | } |
100 | 119 | } |
101 | 120 | |
Index: trunk/extensions/ContributionScores/ContributionScores.i18n.php |
— | — | @@ -1,7 +1,20 @@ |
2 | 2 | <?php |
| 3 | +/** \file |
| 4 | +* \brief Internationalisation file for the Contribution Scores Extension. |
| 5 | +*/ |
| 6 | + |
3 | 7 | $allMessages = array( |
4 | 8 | 'en' => array( |
5 | | - 'contributionscores' => 'Contribution Scores' |
| 9 | + 'contributionscores' => 'Contribution Scores', |
| 10 | + 'contributionscores-info' => "Scores are calculated as follows:\n". |
| 11 | + "*1 point for each unique page edited\n". |
| 12 | + "*Square Root of (Total Edits Made) - (Total Unique Pages) * 2\n". |
| 13 | + "Scores calculated in this manner weight edit diversity over edit volume. Basically, this score measures". |
| 14 | + " primarily unique pages edited, with consideration for high edit volume - assumed to be a higher quality ". |
| 15 | + "article.", |
| 16 | + 'contributionscores-top' => '(Top $1)', |
| 17 | + 'contributionscores-days' => 'Last $1 Days', |
| 18 | + 'contributionscores-allrevisions' => 'All Revisions' |
6 | 19 | ), |
7 | 20 | 'de' => array( |
8 | 21 | 'contributionscores' => 'Benutzerbeiträge auswerten', |
Index: trunk/extensions/ContributionScores/ContributionScores.php |
— | — | @@ -1,4 +1,8 @@ |
2 | 2 | <?php |
| 3 | +/** \file |
| 4 | +* \brief Contains setup code for the Contribution Scores Extension. |
| 5 | +*/ |
| 6 | + |
3 | 7 | # Not a valid entry point, skip unless MEDIAWIKI is defined |
4 | 8 | if (!defined('MEDIAWIKI')) { |
5 | 9 | echo "Contribution Scores extension"; |