r53466 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53465‎ | r53466 | r53467 >
Date:00:05, 19 July 2009
Author:siebrand
Status:deferred
Tags:
Comment:
* Update messages for CooperationStatistics
* stylize.php, indentation fixes and triling whitespace removed for CooperationStatistics
* add support for CooperationStatistics to Translate
Modified paths:
  • /trunk/extensions/CooperationStatistics/CooperationStatistics.i18n.php (modified) (history)
  • /trunk/extensions/CooperationStatistics/CooperationStatistics.php (modified) (history)
  • /trunk/extensions/CooperationStatistics/CooperationStatistics_body.php (modified) (history)
  • /trunk/extensions/Translate/aliases.txt (modified) (history)
  • /trunk/extensions/Translate/groups/mediawiki-defines.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/CooperationStatistics/CooperationStatistics_body.php
@@ -2,6 +2,7 @@
33 /**
44 * Special:CooperationStatistics
55 */
 6+
67 class CooperationStatistics extends SpecialPage {
78 public function __construct() {
89 parent::__construct( 'CooperationStatistics' );
@@ -12,24 +13,24 @@
1314
1415 wfLoadExtensionMessages( 'CooperationStatistics' );
1516 $nb_of_revuser = wfMsg( 'cooperationstatistics-limit-few-revisors' );
16 - $nbpages = $this->getNbOfPages($nb_of_revuser,'<=');
 17+ $nbpages = $this->getNbOfPages( $nb_of_revuser, '<=' );
1718 $this->OutputTableRaw( $nbpages, $nb_of_revuser, 'init' );
18 -
19 - $retval = array();
20 - $retval[$nb_of_revuser] = $this->getNbOfPages($nb_of_revuser,'=');
 19+
 20+ $retval = array();
 21+ $retval[$nb_of_revuser] = $this->getNbOfPages( $nb_of_revuser, '=' );
2122 $nb_of_revuser++;
22 - $range = 1 + wfMsg( 'cooperationstatistics-limit-many-revisors' ) - $nb_of_revuser;
 23+ $range = 1 + wfMsg( 'cooperationstatistics-limit-many-revisors' ) - $nb_of_revuser;
2324 for ( $j = 0; $j < $range; $j++ ) {
24 - $nbpages = $this->getNbOfPages($nb_of_revuser,'=');
25 - $this->OutputTableRaw( $nbpages, $nb_of_revuser, '=' );
 25+ $nbpages = $this->getNbOfPages( $nb_of_revuser, '=' );
 26+ $this->OutputTableRaw( $nbpages, $nb_of_revuser, '=' );
2627 $retval[$nb_of_revuser] = $nbpages;
2728 $nb_of_revuser++;
2829 }
29 -
30 - $nbpages = $this->getNbOfPages($nb_of_revuser,'>=');
 30+
 31+ $nbpages = $this->getNbOfPages( $nb_of_revuser, '>=' );
3132 $this->OutputTableRaw( $nbpages, $nb_of_revuser, 'end' );
3233 $retval[$nb_of_revuser] = $nbpages;
33 -
 34+
3435 if ( $wgCooperationStatsGoogleCharts == True ) {
3536 $wgOut->addHTML( Xml::element( 'img', array( 'src' =>
3637 $this->getGoogleChartBarParams( $retval ) ) )
@@ -37,9 +38,9 @@
3839 $this->getGoogleChartParams( $retval ) ) ) );
3940 }
4041 }
41 -
 42+
4243 private function getGoogleChartBarParams( $stats ) {
43 - global $wgCoopStatsChartBarDimensions;
 44+ global $wgCoopStatsChartBarDimensions;
4445 return "http://chart.apis.google.com/chart?" . wfArrayToCGI(
4546 array(
4647 'chs' => $wgCoopStatsChartBarDimensions,
@@ -51,58 +52,68 @@
5253 'chl' => implode( '|', array_keys( $stats ) ) . "++"
5354 ) );
5455 }
 56+
5557 private function getGoogleChartParams( $stats ) {
56 - global $wgCoopStatsChartDimensions;
 58+ global $wgCoopStatsChartDimensions;
5759 return "http://chart.apis.google.com/chart?" . wfArrayToCGI(
5860 array(
5961 'chs' => $wgCoopStatsChartDimensions,
6062 'cht' => 'p3',
6163 'chd' => 't:' . implode( ',', $stats ),
62 - 'chl' => implode( ' '.wfMsg( 'cooperationstatistics-users' ) . ' |', array_keys( $stats ) ) . wfMsg('cooperationstatistics-legendmore')
 64+ 'chl' => implode( ' ' . wfMsg( 'cooperationstatistics-users' ) . ' |', array_keys( $stats ) ) . wfMsg( 'cooperationstatistics-legendmore' )
6365 ) );
6466 }
65 -
 67+
6668 private function InitPageAndHtmlTable( ) {
6769 global $wgOut;
68 - $this->setHeaders();
69 - $wgOut->setPagetitle( wfMsg( "cooperationstatistics" ) );
 70+ $this->setHeaders();
 71+ $wgOut->setPagetitle( wfMsg( "cooperationstatistics" ) );
7072 $wgOut->addWikiMsg( "cooperationstatistics-text" );
71 - $wgOut->addHTML( "<table class=\"wikitable sortable\"><tr><td>");
 73+ $wgOut->addHTML( "<table class=\"wikitable sortable\"><tr><td>" );
7274 $wgOut->addWikiMsg( "cooperationstatistics-tablearticle" );
73 - $wgOut->addHTML("</td>
74 - <td>");
 75+ $wgOut->addHTML( "</td>
 76+ <td>" );
7577 $wgOut->addWikiMsg( "cooperationstatistics-tablevalue" );
76 - $wgOut->addHTML("</td>
77 - </tr>");
 78+ $wgOut->addHTML( "</td>
 79+ </tr>" );
7880 }
 81+
7982 private function OutputTableRaw( $nbpages, $nb_of_revuser, $msg ) {
80 - global $wgOut;
81 - if ($msg == 'init') $this->InitPageAndHtmlTable();
82 - $wgOut->addHTML("
83 -<tr>
84 - <td align='left'>");
85 - $wgOut->addWikiMsg( 'cooperationstatistics-articles', $nbpages );
86 - $wgOut->addHTML("</td>
87 - <td align='left'>");
88 - if ($msg == 'init') $wgOut->addWikiMsg( 'cooperationstatistics-nblessusers', $nb_of_revuser );
89 - if ($msg == '=' ) $wgOut->addWikiMsg( 'cooperationstatistics-nbusers', $nb_of_revuser );
90 - if ($msg == 'end') $wgOut->addWikiMsg( 'cooperationstatistics-nbmoreusers', $nb_of_revuser );
91 - $wgOut->addHTML("</td>
92 -</tr>");
93 - if ($msg == 'end') $wgOut->addHTML("</table>");
 83+ global $wgOut;
 84+
 85+ if ( $msg == 'init' ) $this->InitPageAndHtmlTable();
 86+
 87+ $wgOut->addHTML( " <tr>
 88+ <td align='left'>" );
 89+ $wgOut->addWikiMsg( 'cooperationstatistics-articles', $nbpages );
 90+ $wgOut->addHTML( " </td>
 91+ <td align='left'>" );
 92+
 93+ if ( $msg == 'init' ) $wgOut->addWikiMsg( 'cooperationstatistics-nblessusers', $nb_of_revuser );
 94+ if ( $msg == '=' ) $wgOut->addWikiMsg( 'cooperationstatistics-nbusers', $nb_of_revuser );
 95+ if ( $msg == 'end' ) $wgOut->addWikiMsg( 'cooperationstatistics-nbmoreusers', $nb_of_revuser );
 96+
 97+ $wgOut->addHTML( " </td>
 98+ </tr>" );
 99+
 100+ if ( $msg == 'end' ) $wgOut->addHTML( "</table>" );
94101 }
95102
96103 private function getNbOfPages( $nb, $relation ) {
97 - if ($relation == '<=') $sql = self::getSQLlower($nb);
98 - if ($relation == '=') $sql = self::getSQL($nb);
99 - if ($relation == '>=') $sql = self::getSQLupper($nb);
100 - $db = wfGetDB( DB_SLAVE );
 104+ if ( $relation == '<=' ) $sql = self::getSQLlower( $nb );
 105+ if ( $relation == '=' ) $sql = self::getSQL( $nb );
 106+ if ( $relation == '>=' ) $sql = self::getSQLupper( $nb );
 107+
 108+ $db = wfGetDB( DB_SLAVE );
101109 $res = $db->query( $sql, __METHOD__ );
 110+
102111 return $db->numRows( $res );
103112 }
104 - private function getSQL($nb_of_revuser) {
 113+
 114+ private function getSQL( $nb_of_revuser ) {
105115 $dbr = wfGetDB( DB_SLAVE );
106116 list( $revision, $page ) = $dbr->tableNamesN( 'revision', 'page' );
 117+
107118 return
108119 "
109120 SELECT
@@ -115,9 +126,11 @@
116127 HAVING COUNT(distinct rev_user)=$nb_of_revuser
117128 ";
118129 }
119 - private function getSQLupper($nb_of_revuser) {
 130+
 131+ private function getSQLupper( $nb_of_revuser ) {
120132 $dbr = wfGetDB( DB_SLAVE );
121133 list( $revision, $page ) = $dbr->tableNamesN( 'revision', 'page' );
 134+
122135 return
123136 "
124137 SELECT
@@ -130,9 +143,11 @@
131144 HAVING COUNT(distinct rev_user)>=$nb_of_revuser
132145 ";
133146 }
134 - private function getSQLlower($nb_of_revuser) {
 147+
 148+ private function getSQLlower( $nb_of_revuser ) {
135149 $dbr = wfGetDB( DB_SLAVE );
136150 list( $revision, $page ) = $dbr->tableNamesN( 'revision', 'page' );
 151+
137152 return
138153 "
139154 SELECT
@@ -145,4 +160,4 @@
146161 HAVING COUNT(distinct rev_user)<=$nb_of_revuser
147162 ";
148163 }
149 -}
\ No newline at end of file
 164+}
Index: trunk/extensions/CooperationStatistics/CooperationStatistics.i18n.php
@@ -8,30 +8,26 @@
99 $messages = array();
1010
1111 $messages['en'] = array(
12 - 'cooperationstatistics' => 'Cooperation statistics',
13 - 'cooperationstatistics-desc' => 'Show [[Special:CooperationStatistics|cooperation statistics on main namespace]].',
14 - 'cooperationstatistics-text' => 'Show cooperation statistics on main namespace. (From [[MediaWiki:cooperationstatistics-limit-few-revisors|{{MediaWiki:cooperationstatistics-limit-few-revisors}}]] to [[MediaWiki:cooperationstatistics-limit-many-revisors|{{MediaWiki:cooperationstatistics-limit-many-revisors}}+]] revisors)' .
15 - '<br>See also the [[Special:MostRevisors|\'\'\'pages with the most revisors\'\'\']] and [[Special:MostRevisions|with the most revisions]].',
16 - 'cooperationstatistics-tablearticle' => 'Article count',
17 - 'cooperationstatistics-tablevalue' => 'Number of editors',
18 - 'cooperationstatistics-users' => 'editors',
19 - 'cooperationstatistics-articles' => '$1 articles',
20 - 'cooperationstatistics-nbusers' => 'have $1 editors',
21 - 'cooperationstatistics-nblessusers' => 'have $1 or less editors',
22 - 'cooperationstatistics-nbmoreusers' => 'have $1 or more editors',
23 - 'cooperationstatistics-legendmore' => ' or more editors.',
24 - 'cooperationstatistics-limit-few-revisors' => '1',
 12+ 'cooperationstatistics' => 'Cooperation statistics',
 13+ 'cooperationstatistics-desc' => 'Show [[Special:CooperationStatistics|cooperation statistics on main namespace]].',
 14+ 'cooperationstatistics-text' => 'Show cooperation statistics on main namespace.
 15+From [[MediaWiki:Cooperationstatistics-limit-few-revisors|{{MediaWiki:Cooperationstatistics-limit-few-revisors}}]] to [[MediaWiki:Cooperationstatistics-limit-many-revisors|{{MediaWiki:cooperationstatistics-limit-many-revisors}}+]] revisors)<br />
 16+See also the [[Special:MostRevisors|\'\'\'pages with the most revisors\'\'\']] and [[Special:MostRevisions|pages with the most revisions]].',
 17+ 'cooperationstatistics-tablearticle' => 'Page count',
 18+ 'cooperationstatistics-tablevalue' => 'Number of editors',
 19+ 'cooperationstatistics-articles' => '$1 pages',
 20+ 'cooperationstatistics-nbusers' => 'have $1 editors',
 21+ 'cooperationstatistics-nblessusers' => 'have $1 or less editors',
 22+ 'cooperationstatistics-nbmoreusers' => 'have $1 or more editors',
 23+ 'cooperationstatistics-legendmore' => ' or more editors.',
 24+
 25+ // Settings. Do not translate
 26+ 'cooperationstatistics-users' => 'editors',
 27+ 'cooperationstatistics-limit-few-revisors' => '1',
2528 'cooperationstatistics-limit-many-revisors' => '5',
2629 );
2730
28 -/** Message documentation (Message documentation)
29 - * @author Fryed-peach
30 - * @author Jon Harald Søby
31 - * @author Lejonel
32 - * @author Purodha
33 - * @author Siebrand
34 - */
 31+/** Message documentation (Message documentation) */
3532 $messages['qqq'] = array(
36 - 'cooperationstatistics' => '{{Identical|Most Revisors}}',
3733 'cooperationstatistics-desc' => 'Short description of the extension, shown on [[Special:Version]].',
3834 );
Index: trunk/extensions/CooperationStatistics/CooperationStatistics.php
@@ -5,20 +5,12 @@
66 */
77
88 // If this is run directly from the web die as this is not a valid entry point.
9 -if( !defined( 'MEDIAWIKI' ) ) die( 'Invalid entry point.' );
 9+if ( !defined( 'MEDIAWIKI' ) ) die( 'Invalid entry point.' );
1010
11 -$wgCooperationStatsGoogleCharts = True; // false to disable charts
 11+$wgCooperationStatsGoogleCharts = true; // false to disable charts
1212 $wgCoopStatsChartDimensions = '520x200';
1313 $wgCoopStatsChartBarDimensions = '180x200';
1414
15 -// Set extension files.
16 -$dir = dirname( __FILE__ ) . '/';
17 -$wgExtensionMessagesFiles['CooperationStatistics'] = $dir . 'CooperationStatistics.i18n.php';
18 -$wgExtensionAliasesFiles['CooperationStatistics'] = $dir . 'CooperationStatistics.alias.php';
19 -$wgAutoloadClasses['CooperationStatistics'] = $dir . 'CooperationStatistics_body.php';
20 -$wgSpecialPages['CooperationStatistics'] = 'CooperationStatistics';
21 -$wgSpecialPageGroups['CooperationStatistics'] = 'wiki';
22 -
2315 // Extension credits.
2416 $wgExtensionCredits['specialpage'][] = array(
2517 'path' => __FILE__,
@@ -30,3 +22,11 @@
3123 'description' => '',
3224 'descriptionmsg' => 'cooperationstatistics-desc',
3325 );
 26+
 27+// Set extension files.
 28+$dir = dirname( __FILE__ ) . '/';
 29+$wgExtensionMessagesFiles['CooperationStatistics'] = $dir . 'CooperationStatistics.i18n.php';
 30+$wgExtensionAliasesFiles['CooperationStatistics'] = $dir . 'CooperationStatistics.alias.php';
 31+$wgAutoloadClasses['CooperationStatistics'] = $dir . 'CooperationStatistics_body.php';
 32+$wgSpecialPages['CooperationStatistics'] = 'CooperationStatistics';
 33+$wgSpecialPageGroups['CooperationStatistics'] = 'wiki';
Index: trunk/extensions/Translate/groups/mediawiki-defines.txt
@@ -208,6 +208,9 @@
209209 id = ext-contributorsaddon
210210 file = ContributorsAddon/ContributorsAddon.i18n.php
211211
 212+Cooperation Statistics
 213+ignored = cooperationstatistics-users, cooperationstatistics-limit-few-revisors, cooperationstatistics-limit-many-revisors
 214+
212215 Count Edits
213216
214217 Create Box
Index: trunk/extensions/Translate/aliases.txt
@@ -76,6 +76,9 @@
7777 Contribution tracking
7878 file = ContributionTracking/ContributionTracking.alias.php
7979
 80+Cooperation statistics
 81+file = CooperationStatistics/CooperationStatistics.alias.php
 82+
8083 Cross namespace links
8184 file = CrossNamespaceLinks/SpecialCrossNamespaceLinks.alias.php
8285

Status & tagging log