r25160 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25159‎ | r25160 | r25161 >
Date:14:39, 26 August 2007
Author:tlaqua
Status:old
Tags:
Comment:
Fixed i18n files, switched over to utilize abstraction layer f/ messages, etc, etc. + Doxygen comments.
Modified paths:
  • /trunk/extensions/ContributionScores/ContributionScores.i18n.php (modified) (history)
  • /trunk/extensions/ContributionScores/ContributionScores.php (modified) (history)
  • /trunk/extensions/ContributionScores/ContributionScores_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ContributionScores/ContributionScores_body.php
@@ -1,13 +1,35 @@
22 <?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+ */
316 class ContributionScores extends SpecialPage
417 {
518 function ContributionScores() {
619 SpecialPage::SpecialPage("ContributionScores");
720 self::loadMessages();
821 }
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+ */
1032 function genContributionScoreTable( $days, $limit ) {
11 - global $contribScoreIgnoreBots;
 33+ global $contribScoreIgnoreBots, $wgUser;
1234
1335 $dbr =& wfGetDB( DB_SLAVE );
1436
@@ -44,22 +66,23 @@
4567
4668 $res = $dbr->query($sql);
4769
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";
5476
 77+ $skin =& $wgUser->getSkin();
5578 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";
6285 }
63 - $output .= "|}";
 86+ $output .= "</tr></table>";
6487 $dbr->freeResult( $res );
6588
6689 return $output;
@@ -80,21 +103,17 @@
81104 array(0,50));
82105 }
83106
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'));
90108
91109 foreach ( $contribScoreReports as $scoreReport) {
92110 if ( $scoreReport[0] > 0 ) {
93 - $reportTitle = "Last $scoreReport[0] Days";
 111+ $reportTitle = wfMsgForContent('contributionscores-days', $scoreReport[0]);
94112 } else {
95 - $reportTitle = "All Revisions";
 113+ $reportTitle = wfMsgForContent('contributionscores-allrevisions');
96114 }
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]));
99118 }
100119 }
101120
Index: trunk/extensions/ContributionScores/ContributionScores.i18n.php
@@ -1,7 +1,20 @@
22 <?php
 3+/** \file
 4+* \brief Internationalisation file for the Contribution Scores Extension.
 5+*/
 6+
37 $allMessages = array(
48 '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'
619 ),
720 'de' => array(
821 'contributionscores' => 'Benutzerbeiträge auswerten',
Index: trunk/extensions/ContributionScores/ContributionScores.php
@@ -1,4 +1,8 @@
22 <?php
 3+/** \file
 4+* \brief Contains setup code for the Contribution Scores Extension.
 5+*/
 6+
37 # Not a valid entry point, skip unless MEDIAWIKI is defined
48 if (!defined('MEDIAWIKI')) {
59 echo "Contribution Scores extension";

Status & tagging log