OSDN Git Service

Add color setting
[tortoisegit/TortoiseGitJp.git] / contrib / drupal-modules / module / tortoisesvn.module
1 <?php\r
2 //\r
3 // TortoiseSVN specific module that creates download and translation information pages\r
4 //\r
5 // Copyright (C) 2004-2008 the TortoiseSVN team\r
6 // This file is distributed under the same license as TortoiseSVN\r
7 //\r
8 // $Author: luebbe $\r
9 // $Date: 2008-10-31 18:05:08 +0800 (Fri, 31 Oct 2008) $\r
10 // $Rev: 14458 $\r
11 //\r
12 \r
13 /**\r
14  * @file\r
15  * TortoiseSVN specific module that creates download and translation information pages.\r
16  */\r
17 \r
18 /**\r
19  * Implementation of hook_help().\r
20  */\r
21 function tortoisesvn_help($section) {\r
22   switch ($section) {\r
23     case 'admin/modules#description':\r
24       return t('TortoiseSVN specific module that creates download and translation information pages.');\r
25     case 'admin/settings/tortoisesvn':\r
26       return t('The settings on this page define the parameters for the latest official release. These change with every release of TortoiseSVN.<br /> In the bottom section some general parameters for sourceforge are requested. These parameters change rarely.<br/>Both sets of settings are used to create information pages and download urls.');\r
27   }\r
28 }\r
29 \r
30 /**\r
31  * Implementation of hook_settings().\r
32  */\r
33 \r
34 function tortoisesvn_settings() {\r
35 \r
36   $form['tsvn'] = array(\r
37     '#type' => 'fieldset',\r
38     '#title' => t('TortoiseSVN release information'),\r
39     '#collapsible' => TRUE,\r
40     '#collapsed' => FALSE\r
41   );\r
42   \r
43   $form['tsvn']['version'] = array(\r
44     '#type' => 'textfield',\r
45     '#title' => t('Version'),\r
46     '#default_value' => variable_get('tsvn_version',0),\r
47     '#size' => 20,\r
48     '#maxlength' => 10,\r
49     '#description' => t('The version number of the latest official TortoiseSVN release (e.g. 1.3.0).'),\r
50   );\r
51   $form['tsvn']['date'] = array(\r
52     '#type' => 'textfield',\r
53     '#title' => t('Release date'),\r
54     '#default_value' => variable_get('tsvn_date','01-01-1970'),\r
55     '#size' => 20,\r
56     '#maxlength' => 10,\r
57     '#description' => t('The date on which the above version of TortoiseSVN was released.'),\r
58   );\r
59   $form['tsvn']['tsvn_build'] = array(\r
60     '#type' => 'textfield',\r
61     '#title' => t('Build number (w32)'),\r
62     '#default_value' => variable_get('tsvn_build',0),\r
63     '#size' => 20,\r
64     '#maxlength' => 5,\r
65     '#description' => t('The TortoiseSVN build number for 32 bit processors.'),\r
66   );\r
67   $form['tsvn']['tsvn_build_x64'] = array(\r
68     '#type' => 'textfield',\r
69     '#title' => t('Build number (x64)'),\r
70     '#default_value' => variable_get('tsvn_build_x64',0),\r
71     '#size' => 20,\r
72     '#maxlength' => 5,\r
73     '#description' => t('The TortoiseSVN build number for 64 bit processors.'),\r
74   );\r
75   $form['tsvn']['svnlib'] = array(\r
76     '#type' => 'textfield',\r
77     '#title' => t('Subversion library version'),\r
78     '#default_value' => variable_get('tsvn_svnlib',0),\r
79     '#size' => 20,\r
80     '#maxlength' => 5,\r
81     '#description' => t('The version number of the Subversion libraries against which TortoiseSVN is linked.'),\r
82   );\r
83   $form['tsvn']['sf_release_binary'] = array(\r
84     '#type' => 'textfield',\r
85     '#title' => t('Sourceforge binaries release ID'),\r
86     '#default_value' => variable_get('tsvn_sf_release_binary',0),\r
87     '#size' => 20,\r
88     '#maxlength' => 6,\r
89     '#description' => t('The Sourceforge release id for the binaries.'),\r
90   );\r
91   $form['tsvn']['sf_release_language'] = array(\r
92     '#type' => 'textfield',\r
93     '#title' => t('Sourceforge language pack release ID'),\r
94     '#default_value' => variable_get('tsvn_sf_release_language',0),\r
95     '#size' => 20,\r
96     '#maxlength' => 6,\r
97     '#description' => t('The Sourceforge release id for the language packs.'),\r
98   );\r
99 \r
100   $form['repos'] = array(\r
101     '#type' => 'fieldset',\r
102     '#title' => t('TortoiseSVN repository URLs'),\r
103     '#collapsible' => TRUE,\r
104     '#collapsed' => FALSE\r
105   );\r
106 \r
107   $form['repos']['trunk'] = array(\r
108     '#type' => 'textfield',\r
109     '#title' => t('Trunk'),\r
110     '#default_value' => variable_get('tsvn_repos_trunk',''),\r
111     '#size' => 100,\r
112     '#maxlength' => 100,\r
113     '#description' => t('The TortoiseSVN trunk URL).'),\r
114   );\r
115 \r
116   $form['repos']['branch'] = array(\r
117     '#type' => 'textfield',\r
118     '#title' => t('Branch'),\r
119     '#default_value' => variable_get('tsvn_repos_branch',''),\r
120     '#size' => 100,\r
121     '#maxlength' => 100,\r
122     '#description' => t('The URL of the latest TortoiseSVN release branch (e.g. 1.3.x).'),\r
123   );\r
124 \r
125   $form['sf'] = array(\r
126     '#type' => 'fieldset',\r
127     '#title' => t('Sourceforge download settings information'),\r
128     '#collapsible' => TRUE,\r
129     '#collapsed' => FALSE\r
130   );\r
131 \r
132   $form['sf']['project'] = array(\r
133     '#type' => 'textfield',\r
134     '#title' => t('Sourceforge project ID'),\r
135     '#default_value' => variable_get('tsvn_sf_project',0),\r
136     '#size' => 20,\r
137     '#maxlength' => 6,\r
138     '#description' => t('The Sourceforge project ID of TortoiseSVN.'),\r
139   );\r
140   $form['sf']['prefix'] = array(\r
141     '#type' => 'textfield',\r
142     '#title' => t('Prefix of download URL'),\r
143     '#default_value' => variable_get('tsvn_sf_prefix',0),\r
144     '#size' => 100,\r
145     '#maxlength' => 100,\r
146     '#description' => t('The part of the Sourceforge download URL that is placed <b>before</b> the filename.'),\r
147   );\r
148   $form['sf']['append'] = array(\r
149     '#type' => 'textfield',\r
150     '#title' => t('Appendix of download URL'),\r
151     '#default_value' => variable_get('tsvn_sf_append',0),\r
152     '#size' => 100,\r
153     '#maxlength' => 100,\r
154     '#description' => t('The part of the Sourceforge download URL that is placed <b>after</b> the filename.'),\r
155   );\r
156 \r
157   return $form;\r
158 }\r
159 \r
160 \r
161 /**\r
162  * functions which are used to print the Doc & GUI translation statistics\r
163  */\r
164 \r
165 function print_footer($vars)\r
166 {\r
167 ?>\r
168 <p>\r
169 <img src="/siteicons/translated.png" alt="translated" title="translated" width="32" height="16"/> Translated <img src="/siteicons/missingaccelerator.png" alt="missing accelerator keys" title="missing accelerator keys" width="32" height="16"/> Missing accelerator keys <img src="/siteicons/fuzzy.png" alt="fuzzy" title="fuzzy" width="32" height="16"/> Fuzzy <img src="/siteicons/untranslated.png" alt="untranslated" title="untranslated" width="32" height="16" /> Untranslated\r
170 </p>\r
171 <p>\r
172 Translations were made by many people, you find them on the <a href="translator_credits">translator credits page</a>.\r
173 </p>\r
174 \r
175 </div>\r
176 \r
177 <?php\r
178 }\r
179 \r
180 function print_table_header($name, $summary, $postat, $vars)\r
181 {\r
182 ?>\r
183 <h2><a name="<?php echo $name ?>"></a><?php echo $summary ?></h2>\r
184 <div class="table">\r
185 <table class="translations" summary="<?php echo $summary ?>">\r
186 <tr>\r
187 <th class="lang">Nr.</th>\r
188 <th class="download">Language</th>\r
189 <th class="lang">ISO code</th>\r
190 <th class="trans">Total= <?php echo $postat[6] ?></th>\r
191 <th class="graph">Graph</th>\r
192 <th colspan="2" class="download">Last update</th>\r
193 </tr>\r
194 <?php\r
195 }\r
196 \r
197 function print_table_footer()\r
198 {\r
199 ?>\r
200 </table>\r
201 </div>\r
202 <div style="clear:both">&nbsp;<br/></div>\r
203 <?php\r
204 }\r
205 \r
206 function print_blank_stat($i, $postat, $vars)\r
207 {\r
208   $tl = $postat[6];\r
209   $wc=$vars['wc'];\r
210   $reposurl = $vars['reposurl'].$postat[11];\r
211   $fdate=date("Y-m-d",$postat[12]);\r
212   $flagimg=$vars['flagpath'].$postat[2].".png";\r
213   $flagtag="<img src=\"$flagimg\" height=\"12\" width=\"18\" alt=\"$postat[3] flag\"/>";\r
214   $flagtag="<a href=\"$reposurl\">$flagtag&nbsp;$postat[3]</a>";\r
215 \r
216   if ($postat[5] > 0) {\r
217     // Error while running msgfmt on existing .po file\r
218     $graphtag="Error in po file";\r
219   } else {\r
220     // .pot File\r
221     $graphtag="<img src=\"/siteicons/transparent.png\" alt=\"blank\" width=\"$wc\" height=\"16\"/>";\r
222   }\r
223 \r
224   echo "<td>$i</td>";\r
225   echo "<td class=\"lang\">$flagtag</td>";\r
226   echo "<td class=\"lang\">&nbsp;</td>";\r
227   echo "<td class=\"trans\">&nbsp;</td>";\r
228   echo "<td class=\"graph\">$graphtag</td>";\r
229   echo "<td class=\"lang\">$fdate</td>";\r
230   echo "<td>&nbsp;</td>";\r
231 }\r
232 \r
233 function print_content_stat($i, $postat, $vars)\r
234 {\r
235   $release=$vars['release'];\r
236   $build=$vars['build'];\r
237   $wc=120;         // Fixed width for graph\r
238 \r
239   $lang_cc=$postat[2];\r
240   $lang_name=$postat[3];\r
241   $total=$postat[6];\r
242   $tra=$postat[7];\r
243   $fuz=$postat[8];\r
244   $unt=$postat[9];\r
245   $acc=$postat[10];\r
246   $reposfile=$postat[11].'.po';\r
247   $reposurl=$vars['reposurl'].$reposfile;\r
248   $fdate=$postat[12];\r
249   $age=(strtotime("now") - strtotime($fdate)) / 86400;\r
250 \r
251   $dlfile=$vars['downloadurl1']."LanguagePack-".$release.".".$build."-win32-".$lang_cc.".exe".$vars['downloadurl2'];\r
252   $flagimg=$vars['flagpath'].$lang_cc.".png";\r
253   $flagtag="<img src=\"$flagimg\" height=\"12\" width=\"18\" alt=\"$lang_name flag\"/>";\r
254   $flagtag="<a href=\"$reposurl\">$flagtag&nbsp;$lang_name</a>";\r
255 \r
256 \r
257   // Calculate width of bars\r
258   $wt=round($wc*$tra/$total);\r
259   $wa=round($wc*$acc/$total);\r
260   $wf=round($wc*$fuz/$total);\r
261   $wu=round($wc*$unt/$total);\r
262 \r
263   // Adjustments\r
264   // make sure that each bar is at least 2px wide if its value is > 0\r
265   if (($wt<2) && ($tra>0)) $wt=2;\r
266   if (($wa<2) && ($acc>0)) $wa=2;\r
267   if (($wf<2) && ($fuz>0)) $wf=2;\r
268   if (($wu<2) && ($unt>0)) $wu=2;\r
269 \r
270   // Make sure total width stays constant by determining the widest bar\r
271   // and subtracting the width of the shorter bars from it.\r
272   if ($wt+$wa+$wf+$wu!=$wc){\r
273     if ($wt>=wa && $wt>=$wf && $wt>=$wu){\r
274       $wt = $wc-$wa-$wf-$wu;\r
275     } else if ($wa>=$wt && $wa>=$wf && $wa>=$wu){\r
276       $wa = $wc-$wt-$wf-$wu;\r
277     } else if ($wf>=$wt && $wf>=$wa && $wf>=$wu){\r
278       $wf = $wc-$wt-$wa-$wu;\r
279     } else{\r
280       $wu = $wc-$wt-$wa-$wf;\r
281     }\r
282   }\r
283 \r
284   // Calculate percentage done. \r
285   $pt=number_format(100*$tra/$total, 1)."%";\r
286 \r
287   // If completeness was rounded up to 100% and \r
288   // anything is missing, set completeness down to 99.9%\r
289   if ( ($pt=="100.0%") && (($total>$tra) || ($acc>0)) )\r
290     $pt="99.9%";\r
291 \r
292   if ($pt=="100.0%") {\r
293     $title="Perfect :-)";\r
294   } else {\r
295     $title="tr:$tra&nbsp;fu:$fuz&nbsp;ut:$unt;&nbsp;$acc&nbsp;missing&nbsp;hotkeys";\r
296   }\r
297 \r
298   // Put Debug info into title\r
299   //  $title="$wc&nbsp;tr:$wt&nbsp;fu:$wf&nbsp;ut:$wu;&nbsp;$wa&nbsp;missing&nbsp;hotkeys";\r
300 \r
301   // count fuzzies as translated, only for the display\r
302   $tra=$tra+$fuz;\r
303 \r
304   echo "<td>$i</td>";\r
305   echo "<td class=\"lang\"><nobr>$flagtag</nobr></td>";\r
306   echo "<td class=\"lang\">$lang_cc</td>";\r
307   echo "<td class=\"trans\" align=\"right\">$pt</td>";\r
308   echo "<td class=\"graph\">";\r
309   if ($wt > 0) \r
310     echo "<img src=\"/siteicons/translated.png\" alt=\"tr\" title=\"$title\" width=\"$wt\" height=\"16\"/>";\r
311   if ($wa > 0) \r
312     echo "<img src=\"/siteicons/missingaccelerator.png\" alt=\"mh\" title=\"$title\" width=\"$wa\" height=\"16\"/>";\r
313   if ($wf > 0) \r
314     echo "<img src=\"/siteicons/fuzzy.png\" alt=\"fu\" title=\"$title\" width=\"$wf\" height=\"16\"/>";\r
315   if ($wu > 0) \r
316     echo "<img src=\"/siteicons/untranslated.png\" alt=\"un\" title=\"$title\" width=\"$wu\" height=\"16\" />";\r
317   echo "</td>";\r
318   echo "<td class=\"lang\">$fdate</td>";\r
319   if ( ($pt<>"100.0%") && ($age>90) && ($vars['showold']==TRUE) ) {\r
320     $title = "Old translation. Last update on: ".$fdate." We need a maintainer!!";\r
321     echo "<td><img src=\"/siteicons/exclamation.png\" alt=\"!!OLD!!\" title=\"$title\" width=\"16\" height=\"16\"/></td>";\r
322   } else {\r
323     echo "<td>&nbsp;</td>";\r
324   }\r
325 }\r
326 \r
327 function print_single_stat($i, $postat, $vars)\r
328 {\r
329 \r
330 /*\r
331   Debugging code:\r
332   echo "<tr class=\"stat_ok\">\n";\r
333   echo "<td>$i</td> <td><pre>";\r
334         print_r($postat);\r
335         echo"</pre></td>";\r
336 */\r
337 \r
338   if ($postat[0] == 0) {\r
339     // $postat[0] == 0 \r
340     // -> It's the .pot file\r
341     echo "<tr class=\"stat_ok\">\n";\r
342     print_blank_stat($i, $postat, $vars);\r
343 \r
344   } elseif ($postat[5] > 0) {\r
345     // $postat[5] > 0 \r
346     // -> Error while running msgfmt on existing .po file\r
347     echo "<tr class=\"error\">\n";\r
348     print_blank_stat($i, $postat, $vars);\r
349 \r
350   } else {\r
351     echo "<tr class=\"stat_ok\">\n";\r
352     print_content_stat($i, $postat, $vars);\r
353   }\r
354   echo "</tr>\n";\r
355 }\r
356 \r
357 function print_all_stats($data, $vars)\r
358 {\r
359   $i=0;\r
360   foreach ($data as $key => $postat)\r
361     // $postat[5] == '' \r
362     // -> Non existant .po file. Only country information, no stats\r
363     if (isset($postat[5])) {\r
364       $i++;\r
365       print_single_stat($i, $postat, $vars);\r
366     }\r
367 }\r
368 \r
369 ?>\r