3 // TortoiseSVN specific module that creates download and translation information pages
\r
5 // Copyright (C) 2004-2008 the TortoiseSVN team
\r
6 // This file is distributed under the same license as TortoiseSVN
\r
9 // $Date: 2008-10-31 18:05:08 +0800 (Fri, 31 Oct 2008) $
\r
15 * TortoiseSVN specific module that creates download and translation information pages.
\r
19 * Implementation of hook_help().
\r
21 function tortoisesvn_help($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
31 * Implementation of hook_settings().
\r
34 function tortoisesvn_settings() {
\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
43 $form['tsvn']['version'] = array(
\r
44 '#type' => 'textfield',
\r
45 '#title' => t('Version'),
\r
46 '#default_value' => variable_get('tsvn_version',0),
\r
49 '#description' => t('The version number of the latest official TortoiseSVN release (e.g. 1.3.0).'),
\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
57 '#description' => t('The date on which the above version of TortoiseSVN was released.'),
\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
65 '#description' => t('The TortoiseSVN build number for 32 bit processors.'),
\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
73 '#description' => t('The TortoiseSVN build number for 64 bit processors.'),
\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
81 '#description' => t('The version number of the Subversion libraries against which TortoiseSVN is linked.'),
\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
89 '#description' => t('The Sourceforge release id for the binaries.'),
\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
97 '#description' => t('The Sourceforge release id for the language packs.'),
\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
107 $form['repos']['trunk'] = array(
\r
108 '#type' => 'textfield',
\r
109 '#title' => t('Trunk'),
\r
110 '#default_value' => variable_get('tsvn_repos_trunk',''),
\r
112 '#maxlength' => 100,
\r
113 '#description' => t('The TortoiseSVN trunk URL).'),
\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
121 '#maxlength' => 100,
\r
122 '#description' => t('The URL of the latest TortoiseSVN release branch (e.g. 1.3.x).'),
\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
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
138 '#description' => t('The Sourceforge project ID of TortoiseSVN.'),
\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
145 '#maxlength' => 100,
\r
146 '#description' => t('The part of the Sourceforge download URL that is placed <b>before</b> the filename.'),
\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
153 '#maxlength' => 100,
\r
154 '#description' => t('The part of the Sourceforge download URL that is placed <b>after</b> the filename.'),
\r
162 * functions which are used to print the Doc & GUI translation statistics
\r
165 function print_footer($vars)
\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
172 Translations were made by many people, you find them on the <a href="translator_credits">translator credits page</a>.
\r
180 function print_table_header($name, $summary, $postat, $vars)
\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
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
197 function print_table_footer()
\r
202 <div style="clear:both"> <br/></div>
\r
206 function print_blank_stat($i, $postat, $vars)
\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 $postat[3]</a>";
\r
216 if ($postat[5] > 0) {
\r
217 // Error while running msgfmt on existing .po file
\r
218 $graphtag="Error in po file";
\r
221 $graphtag="<img src=\"/siteicons/transparent.png\" alt=\"blank\" width=\"$wc\" height=\"16\"/>";
\r
224 echo "<td>$i</td>";
\r
225 echo "<td class=\"lang\">$flagtag</td>";
\r
226 echo "<td class=\"lang\"> </td>";
\r
227 echo "<td class=\"trans\"> </td>";
\r
228 echo "<td class=\"graph\">$graphtag</td>";
\r
229 echo "<td class=\"lang\">$fdate</td>";
\r
230 echo "<td> </td>";
\r
233 function print_content_stat($i, $postat, $vars)
\r
235 $release=$vars['release'];
\r
236 $build=$vars['build'];
\r
237 $wc=120; // Fixed width for graph
\r
239 $lang_cc=$postat[2];
\r
240 $lang_name=$postat[3];
\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
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 $lang_name</a>";
\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
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
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
280 $wu = $wc-$wt-$wa-$wf;
\r
284 // Calculate percentage done.
\r
285 $pt=number_format(100*$tra/$total, 1)."%";
\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
292 if ($pt=="100.0%") {
\r
293 $title="Perfect :-)";
\r
295 $title="tr:$tra fu:$fuz ut:$unt; $acc missing hotkeys";
\r
298 // Put Debug info into title
\r
299 // $title="$wc tr:$wt fu:$wf ut:$wu; $wa missing hotkeys";
\r
301 // count fuzzies as translated, only for the display
\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
310 echo "<img src=\"/siteicons/translated.png\" alt=\"tr\" title=\"$title\" width=\"$wt\" height=\"16\"/>";
\r
312 echo "<img src=\"/siteicons/missingaccelerator.png\" alt=\"mh\" title=\"$title\" width=\"$wa\" height=\"16\"/>";
\r
314 echo "<img src=\"/siteicons/fuzzy.png\" alt=\"fu\" title=\"$title\" width=\"$wf\" height=\"16\"/>";
\r
316 echo "<img src=\"/siteicons/untranslated.png\" alt=\"un\" title=\"$title\" width=\"$wu\" height=\"16\" />";
\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
323 echo "<td> </td>";
\r
327 function print_single_stat($i, $postat, $vars)
\r
332 echo "<tr class=\"stat_ok\">\n";
\r
333 echo "<td>$i</td> <td><pre>";
\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
344 } elseif ($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
351 echo "<tr class=\"stat_ok\">\n";
\r
352 print_content_stat($i, $postat, $vars);
\r
357 function print_all_stats($data, $vars)
\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
365 print_single_stat($i, $postat, $vars);
\r