Index: trunk/extensions/CooperationStatistics/CooperationStatistics_body.php |
— | — | @@ -2,6 +2,7 @@ |
3 | 3 | /** |
4 | 4 | * Special:CooperationStatistics |
5 | 5 | */ |
| 6 | + |
6 | 7 | class CooperationStatistics extends SpecialPage { |
7 | 8 | public function __construct() { |
8 | 9 | parent::__construct( 'CooperationStatistics' ); |
— | — | @@ -12,24 +13,24 @@ |
13 | 14 | |
14 | 15 | wfLoadExtensionMessages( 'CooperationStatistics' ); |
15 | 16 | $nb_of_revuser = wfMsg( 'cooperationstatistics-limit-few-revisors' ); |
16 | | - $nbpages = $this->getNbOfPages($nb_of_revuser,'<='); |
| 17 | + $nbpages = $this->getNbOfPages( $nb_of_revuser, '<=' ); |
17 | 18 | $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, '=' ); |
21 | 22 | $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; |
23 | 24 | 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, '=' ); |
26 | 27 | $retval[$nb_of_revuser] = $nbpages; |
27 | 28 | $nb_of_revuser++; |
28 | 29 | } |
29 | | - |
30 | | - $nbpages = $this->getNbOfPages($nb_of_revuser,'>='); |
| 30 | + |
| 31 | + $nbpages = $this->getNbOfPages( $nb_of_revuser, '>=' ); |
31 | 32 | $this->OutputTableRaw( $nbpages, $nb_of_revuser, 'end' ); |
32 | 33 | $retval[$nb_of_revuser] = $nbpages; |
33 | | - |
| 34 | + |
34 | 35 | if ( $wgCooperationStatsGoogleCharts == True ) { |
35 | 36 | $wgOut->addHTML( Xml::element( 'img', array( 'src' => |
36 | 37 | $this->getGoogleChartBarParams( $retval ) ) ) |
— | — | @@ -37,9 +38,9 @@ |
38 | 39 | $this->getGoogleChartParams( $retval ) ) ) ); |
39 | 40 | } |
40 | 41 | } |
41 | | - |
| 42 | + |
42 | 43 | private function getGoogleChartBarParams( $stats ) { |
43 | | - global $wgCoopStatsChartBarDimensions; |
| 44 | + global $wgCoopStatsChartBarDimensions; |
44 | 45 | return "http://chart.apis.google.com/chart?" . wfArrayToCGI( |
45 | 46 | array( |
46 | 47 | 'chs' => $wgCoopStatsChartBarDimensions, |
— | — | @@ -51,58 +52,68 @@ |
52 | 53 | 'chl' => implode( '|', array_keys( $stats ) ) . "++" |
53 | 54 | ) ); |
54 | 55 | } |
| 56 | + |
55 | 57 | private function getGoogleChartParams( $stats ) { |
56 | | - global $wgCoopStatsChartDimensions; |
| 58 | + global $wgCoopStatsChartDimensions; |
57 | 59 | return "http://chart.apis.google.com/chart?" . wfArrayToCGI( |
58 | 60 | array( |
59 | 61 | 'chs' => $wgCoopStatsChartDimensions, |
60 | 62 | 'cht' => 'p3', |
61 | 63 | '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' ) |
63 | 65 | ) ); |
64 | 66 | } |
65 | | - |
| 67 | + |
66 | 68 | private function InitPageAndHtmlTable( ) { |
67 | 69 | global $wgOut; |
68 | | - $this->setHeaders(); |
69 | | - $wgOut->setPagetitle( wfMsg( "cooperationstatistics" ) ); |
| 70 | + $this->setHeaders(); |
| 71 | + $wgOut->setPagetitle( wfMsg( "cooperationstatistics" ) ); |
70 | 72 | $wgOut->addWikiMsg( "cooperationstatistics-text" ); |
71 | | - $wgOut->addHTML( "<table class=\"wikitable sortable\"><tr><td>"); |
| 73 | + $wgOut->addHTML( "<table class=\"wikitable sortable\"><tr><td>" ); |
72 | 74 | $wgOut->addWikiMsg( "cooperationstatistics-tablearticle" ); |
73 | | - $wgOut->addHTML("</td> |
74 | | - <td>"); |
| 75 | + $wgOut->addHTML( "</td> |
| 76 | + <td>" ); |
75 | 77 | $wgOut->addWikiMsg( "cooperationstatistics-tablevalue" ); |
76 | | - $wgOut->addHTML("</td> |
77 | | - </tr>"); |
| 78 | + $wgOut->addHTML( "</td> |
| 79 | + </tr>" ); |
78 | 80 | } |
| 81 | + |
79 | 82 | 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>" ); |
94 | 101 | } |
95 | 102 | |
96 | 103 | 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 ); |
101 | 109 | $res = $db->query( $sql, __METHOD__ ); |
| 110 | + |
102 | 111 | return $db->numRows( $res ); |
103 | 112 | } |
104 | | - private function getSQL($nb_of_revuser) { |
| 113 | + |
| 114 | + private function getSQL( $nb_of_revuser ) { |
105 | 115 | $dbr = wfGetDB( DB_SLAVE ); |
106 | 116 | list( $revision, $page ) = $dbr->tableNamesN( 'revision', 'page' ); |
| 117 | + |
107 | 118 | return |
108 | 119 | " |
109 | 120 | SELECT |
— | — | @@ -115,9 +126,11 @@ |
116 | 127 | HAVING COUNT(distinct rev_user)=$nb_of_revuser |
117 | 128 | "; |
118 | 129 | } |
119 | | - private function getSQLupper($nb_of_revuser) { |
| 130 | + |
| 131 | + private function getSQLupper( $nb_of_revuser ) { |
120 | 132 | $dbr = wfGetDB( DB_SLAVE ); |
121 | 133 | list( $revision, $page ) = $dbr->tableNamesN( 'revision', 'page' ); |
| 134 | + |
122 | 135 | return |
123 | 136 | " |
124 | 137 | SELECT |
— | — | @@ -130,9 +143,11 @@ |
131 | 144 | HAVING COUNT(distinct rev_user)>=$nb_of_revuser |
132 | 145 | "; |
133 | 146 | } |
134 | | - private function getSQLlower($nb_of_revuser) { |
| 147 | + |
| 148 | + private function getSQLlower( $nb_of_revuser ) { |
135 | 149 | $dbr = wfGetDB( DB_SLAVE ); |
136 | 150 | list( $revision, $page ) = $dbr->tableNamesN( 'revision', 'page' ); |
| 151 | + |
137 | 152 | return |
138 | 153 | " |
139 | 154 | SELECT |
— | — | @@ -145,4 +160,4 @@ |
146 | 161 | HAVING COUNT(distinct rev_user)<=$nb_of_revuser |
147 | 162 | "; |
148 | 163 | } |
149 | | -} |
\ No newline at end of file |
| 164 | +} |
Index: trunk/extensions/CooperationStatistics/CooperationStatistics.i18n.php |
— | — | @@ -8,30 +8,26 @@ |
9 | 9 | $messages = array(); |
10 | 10 | |
11 | 11 | $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', |
25 | 28 | 'cooperationstatistics-limit-many-revisors' => '5', |
26 | 29 | ); |
27 | 30 | |
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) */ |
35 | 32 | $messages['qqq'] = array( |
36 | | - 'cooperationstatistics' => '{{Identical|Most Revisors}}', |
37 | 33 | 'cooperationstatistics-desc' => 'Short description of the extension, shown on [[Special:Version]].', |
38 | 34 | ); |
Index: trunk/extensions/CooperationStatistics/CooperationStatistics.php |
— | — | @@ -5,20 +5,12 @@ |
6 | 6 | */ |
7 | 7 | |
8 | 8 | // 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.' ); |
10 | 10 | |
11 | | -$wgCooperationStatsGoogleCharts = True; // false to disable charts |
| 11 | +$wgCooperationStatsGoogleCharts = true; // false to disable charts |
12 | 12 | $wgCoopStatsChartDimensions = '520x200'; |
13 | 13 | $wgCoopStatsChartBarDimensions = '180x200'; |
14 | 14 | |
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 | | - |
23 | 15 | // Extension credits. |
24 | 16 | $wgExtensionCredits['specialpage'][] = array( |
25 | 17 | 'path' => __FILE__, |
— | — | @@ -30,3 +22,11 @@ |
31 | 23 | 'description' => '', |
32 | 24 | 'descriptionmsg' => 'cooperationstatistics-desc', |
33 | 25 | ); |
| 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 @@ |
209 | 209 | id = ext-contributorsaddon |
210 | 210 | file = ContributorsAddon/ContributorsAddon.i18n.php |
211 | 211 | |
| 212 | +Cooperation Statistics |
| 213 | +ignored = cooperationstatistics-users, cooperationstatistics-limit-few-revisors, cooperationstatistics-limit-many-revisors |
| 214 | + |
212 | 215 | Count Edits |
213 | 216 | |
214 | 217 | Create Box |
Index: trunk/extensions/Translate/aliases.txt |
— | — | @@ -76,6 +76,9 @@ |
77 | 77 | Contribution tracking |
78 | 78 | file = ContributionTracking/ContributionTracking.alias.php |
79 | 79 | |
| 80 | +Cooperation statistics |
| 81 | +file = CooperationStatistics/CooperationStatistics.alias.php |
| 82 | + |
80 | 83 | Cross namespace links |
81 | 84 | file = CrossNamespaceLinks/SpecialCrossNamespaceLinks.alias.php |
82 | 85 | |