source: trunk/Modules/Translation/Progress.php

Last change on this file was 893, checked in by chronos, 21 months ago
  • Fixed: Class types casting for better type checking.
  • Fixed: XML direct export.
  • Modified: User class instance moved from Core class to ModuleUser class.
File size: 5.2 KB
Line 
1<?php
2
3class PageProgress extends Page
4{
5 function ShowStatTable()
6 {
7 $Output = '';
8
9 $BuildNumber = GetBuildNumber($_SESSION['StatVersion']);
10 if (is_numeric($_SESSION['language'])) $LanguageFilter = 'AND (`Language`='.$_SESSION['language'].')';
11 else $LanguageFilter = ' AND (`Language`!='.Core::Cast($this->System)->Config['OriginalLanguage'].')';
12
13 $GroupListQuery = 'SELECT `Id`, `TablePrefix`, `Name` FROM `Group`';
14 $Query = '';
15 $DbResult = $this->Database->query($GroupListQuery);
16 if ($DbResult->num_rows > 0)
17 {
18 while ($DbRow = $DbResult->fetch_assoc())
19 {
20 $Query .= 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
21 'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '.
22 'WHERE (`Complete` = 1) '.$LanguageFilter.' '.
23 'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'.
24 ') AS `C1`) AS `Translated`, '.
25 '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
26 'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '.
27 'WHERE (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') '.
28 'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'.
29 ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name` UNION ';
30 }
31 $Query = substr($Query, 0, - 6);
32
33 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$GroupListQuery.') AS `T`');
34 $DbRow = $DbResult->fetch_row();
35 $PageList = GetPageList($DbRow[0]);
36 $Output .= $PageList['Output'];
37
38 $Output .= '<table class="BaseTable">';
39 $TableColumns = array(
40 array('Name' => 'Name', 'Title' => T('Name')),
41 array('Name' => 'Translated', 'Title' => T('Translated')),
42 array('Name' => 'Total', 'Title' => T('Original')),
43 array('Name' => 'Percent', 'Title' => T('Percentage')),
44 );
45
46 $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
47 $Output .= $Order['Output'];
48
49 $Translated = 0;
50 $Total = 0;
51 $DbResult = $this->Database->query('SELECT *, ROUND(`Translated` / `Total` * 100, 2) AS `Percent` FROM ('.$Query.') AS `C3` '.$Order['SQL'].$PageList['SQLLimit']);
52 while ($Group = $DbResult->fetch_assoc())
53 {
54 $Output .= '<tr><td>'.T($Group['Name']).'</td><td>'.$Group['Translated'].'</td><td>'.$Group['Total'].'</td><td>'.ProgressBar(150, $Group['Percent']).'</td></tr>';
55 $Translated += $Group['Translated'];
56 $Total += $Group['Total'];
57 }
58 if ($Total <> 0) $TotalCount = round($Translated / $Total * 100, 2);
59 else $TotalCount = 0;
60 $Output .= '<tr><td><strong>'.T('Total').'</strong></td><td><strong>'.$Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.ProgressBar(150, $TotalCount).'</strong></td></tr>'.
61 '</table>';
62 }
63 return $Output;
64 }
65
66 function Show(): string
67 {
68 $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
69 $this->Title = T('Progress');
70 $LanguageList = GetLanguageList();
71
72 if (array_key_exists('Version', $_GET)) $_SESSION['StatVersion'] = $_GET['Version'];
73 if (!array_key_exists('StatVersion', $_SESSION))
74 {
75 if ($User->Licence(LICENCE_USER) and ($User->PreferredVersionGame != ''))
76 {
77 $_SESSION['StatVersion'] = $User->PreferredVersionGame;
78 } else
79 {
80 $_SESSION['StatVersion'] = Core::Cast($this->System)->Config['Web']['GameVersion'];
81 }
82 }
83
84 if (!isset($_SESSION['language']))
85 {
86 if ($User->Licence(LICENCE_USER))
87 {
88 $_SESSION['language'] = $User->Language;
89 } else
90 {
91 $_SESSION['language'] = '';
92 }
93 }
94 if (array_key_exists('language', $_GET))
95 {
96 if ($_GET['language'] == '') {
97 $_SESSION['language'] = '';
98 } else
99 {
100 $_SESSION['language'] = $_GET['language'] * 1;
101 }
102 }
103 if (!array_key_exists($_SESSION['language'], $LanguageList)) $_SESSION['language'] = '';
104
105 // Show client version selection
106 $Output = T('Client version:').' ';
107 $DbResult = $this->Database->query('SELECT `Version`, `Title` FROM `ClientVersion` WHERE `Imported`=1 ORDER BY `Version`');
108 while ($DbRow = $DbResult->fetch_assoc())
109 {
110 $Output .= '<a href="?Version='.$DbRow['Version'].'" title="'.$DbRow['Title'].'">'.$DbRow['Version'].'</a> ';
111 }
112 $Output .= '<br/>';
113
114 // Show language selection
115 $Output .= T('Language:').' ';
116 $Lang = '<a href="?language=">'.T('All').'</a>';
117 if ($_SESSION['language'] == '') $Output .= '<strong>'.$Lang.'</strong> ';
118 else $Output .= $Lang;
119 foreach ($LanguageList as $Language)
120 if ($Language['Enabled'] == 1)
121 {
122 $Lang = ' <a href="?language='.$Language['Id'].'">'.T($Language['Name']).'</a>';
123 if ($Language['Id'] == $_SESSION['language']) $Output .= '<strong>'.$Lang.'</strong> ';
124 else $Output .= $Lang;
125 }
126
127 if (is_numeric($_SESSION['language'])) $LanguageName = $LanguageList[$_SESSION['language']]['Name'];
128 else $LanguageName = T('All');
129 $Output .= '<br/><br/><h3>'.sprintf(T('Statistics of translation completion of language %s for version %s'), T($LanguageName), $_SESSION['StatVersion']).'</h3><br/>';
130 $Output .= $this->ShowStatTable();
131
132 return $Output;
133 }
134}
Note: See TracBrowser for help on using the repository browser.