1 | <?php
|
---|
2 |
|
---|
3 | class CompletionState
|
---|
4 | {
|
---|
5 | const All = 0;
|
---|
6 | const NotTranslated = 1;
|
---|
7 | const Translated = 2;
|
---|
8 | const NotFinished = 3;
|
---|
9 | const Original = 4;
|
---|
10 | const NotFinishedNotTranslated = 5;
|
---|
11 | const Missing1 = 6;
|
---|
12 | const Missing2 = 7;
|
---|
13 | }
|
---|
14 |
|
---|
15 | class PageTranslationList extends Page
|
---|
16 | {
|
---|
17 | function ShowFilter($GroupId = 0)
|
---|
18 | {
|
---|
19 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
---|
20 | $TranslationTree = ModuleTranslation::Cast($this->System->GetModule('Translation'))->GetTranslationTree();
|
---|
21 |
|
---|
22 | $Filter = array('SQL' => '');
|
---|
23 |
|
---|
24 | $Output = '<form action="?" method="post">'.
|
---|
25 | '<table class="BaseTable"><tr>'.
|
---|
26 | '<th>'.T('Processing').'</th>'.
|
---|
27 | '<th>'.T('Group').'</th>'.
|
---|
28 | '<th>'.T('Version').'</th>'.
|
---|
29 | '<th>'.T('Language').'</th>'.
|
---|
30 | '<th>'.T('Translator').'</th>'.
|
---|
31 | '<th>'.T('Words').'</th>'.
|
---|
32 | '<th>'.T('Item').'</th>'.
|
---|
33 | '<th></th></tr><tr>';
|
---|
34 |
|
---|
35 | // State
|
---|
36 | $Filter['State'] = GetParameter('state', 0, true, true);
|
---|
37 | $Output .= '<td><select name="state">';
|
---|
38 | $StateTypes = array(
|
---|
39 | CompletionState::All => T('All'),
|
---|
40 | CompletionState::NotTranslated => T('Not translated'),
|
---|
41 | CompletionState::Translated => T('Translated'),
|
---|
42 | CompletionState::NotFinished => T('Unfinished'),
|
---|
43 | CompletionState::Original => T('Original'),
|
---|
44 | CompletionState::NotFinishedNotTranslated => T('Unfinished - Not translated'),
|
---|
45 | CompletionState::Missing1 => T('Missing $ ($N,$s..)'),
|
---|
46 | CompletionState::Missing2 => T('Missing $ - Not fixed'),
|
---|
47 | );
|
---|
48 | foreach ($StateTypes as $index => $StateType) {
|
---|
49 | if ($Filter['State'] == $index) $Selected = ' selected="selected"';
|
---|
50 | else $Selected = '';
|
---|
51 | $Output .= '<option value="'.$index.'"'.$Selected.'>'.$StateType.'</option>';
|
---|
52 | }
|
---|
53 | $Output .= '</select></td>';
|
---|
54 |
|
---|
55 | // Translation group
|
---|
56 | if ($GroupId == 0)
|
---|
57 | {
|
---|
58 | $Filter['Group'] = GetParameter('group', 0, true, true);
|
---|
59 | if ($Filter['Group'] != 0)
|
---|
60 | {
|
---|
61 | if (isset($TranslationTree[$Filter['Group']]) == false)
|
---|
62 | ErrorMessage('Překladová skupina dle zadaného Id neexistuje.');
|
---|
63 | $Table = $TranslationTree[$Filter['Group']]['TablePrefix'];
|
---|
64 | }
|
---|
65 | } else
|
---|
66 | {
|
---|
67 | $Filter['Group'] = $GroupId;
|
---|
68 | $Table = $TranslationTree[$Filter['Group']]['TablePrefix'];
|
---|
69 | }
|
---|
70 |
|
---|
71 | $Output .= '<td><select name="group" style="width: 80px">';
|
---|
72 | if ($Filter['Group'] == 0) $Selected = ' selected="selected"';
|
---|
73 | else $Selected = '';
|
---|
74 | $Output .= '<option value="0"'.$Selected.'>'.T('All').'</option>';
|
---|
75 | $DbResult = $this->Database->query('SELECT `Id`,`Name` FROM `Group`');
|
---|
76 | while ($Group = $DbResult->fetch_assoc())
|
---|
77 | $Groups[T($Group['Name'])] = $Group;
|
---|
78 | ksort($Groups);
|
---|
79 | foreach ($Groups as $Group)
|
---|
80 | {
|
---|
81 | if ($Group['Id'] == $Filter['Group']) $Selected = ' selected="selected"';
|
---|
82 | else $Selected = '';
|
---|
83 | $Output .= '<option value="'.$Group['Id'].'"'.$Selected.'>'.T($Group['Name']).'</option>';
|
---|
84 | }
|
---|
85 | $Output .= '</select></td>';
|
---|
86 |
|
---|
87 | if ($User->Licence(LICENCE_USER))
|
---|
88 | $Filter['Version'] = GetParameter('version', $User->PreferredVersion, true, true);
|
---|
89 | else
|
---|
90 | $Filter['Version'] = GetParameter('version', 0, true, true);
|
---|
91 | if ($Filter['Version'] != 0)
|
---|
92 | {
|
---|
93 | $DbResult = $this->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE (`Imported` = 1) AND (`Id` ='.$Filter['Version'].')');
|
---|
94 | if ($DbResult->num_rows > 0)
|
---|
95 | {
|
---|
96 | $DbRow = $DbResult->fetch_assoc();
|
---|
97 | $Filter['BuildNumber'] = $DbRow['BuildNumber'];
|
---|
98 | } else ErrorMessage('Zadaná verze klienta nenalezena');
|
---|
99 | }
|
---|
100 | $Output .= '<td><select name="version">';
|
---|
101 | if ($Filter['Version'] == 0) $Selected = ' selected="selected"';
|
---|
102 | else $Selected = '';
|
---|
103 | $Output .= '<option value="0"'.$Selected.'>'.T('All').'</option>';
|
---|
104 | $DbResult = $this->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE `Imported` = 1 ORDER BY `BuildNumber` DESC');
|
---|
105 | while ($Version = $DbResult->fetch_assoc())
|
---|
106 | {
|
---|
107 | if ($Version['Id'] == $Filter['Version']) $Selected = ' selected="selected"';
|
---|
108 | else $Selected = '';
|
---|
109 | $Output .= '<option value="'.$Version['Id'].'"'.$Selected.'>'.$Version['Version'].'</option>';
|
---|
110 | }
|
---|
111 | $Output .= '</select></td>';
|
---|
112 | if ($Filter['Version'] != 0) $VersionFilter = ' AND (`VersionStart` <= '.$Filter['BuildNumber'].') AND (`VersionEnd` >= '.$Filter['BuildNumber'].')';
|
---|
113 | else $VersionFilter = '';
|
---|
114 | //else $Filter['SQL'] .= ' AND '; DISTINCT(Entry)
|
---|
115 |
|
---|
116 | // Language
|
---|
117 | $Filter['Language'] = GetParameter('lang', 0, true, true);
|
---|
118 | $Output .= '<td><select name="lang">';
|
---|
119 | if ($Filter['Language'] == 0) $Selected = ' selected="selected"';
|
---|
120 | else $Selected = '';
|
---|
121 | $Output .= '<option value="0"'.$Selected.'>'.T('All').'</option>';
|
---|
122 | $DbResult = $this->Database->query('SELECT `Id`, `Name` FROM `Language` WHERE `Enabled` = 1 ORDER BY `Name`');
|
---|
123 | while ($Language = $DbResult->fetch_assoc())
|
---|
124 | {
|
---|
125 | if ($Language['Id'] == $Filter['Language']) $Selected = ' selected="selected"';
|
---|
126 | else $Selected = '';
|
---|
127 | $Output .= '<option value="'.$Language['Id'].'"'.$Selected.'>'.T($Language['Name']).'</option>';
|
---|
128 | }
|
---|
129 | $Output .= '</select></td>';
|
---|
130 | $LanguageFilter = '';
|
---|
131 | $LanguageFilterSub = '';
|
---|
132 | if ($Filter['Language'] != 0) {
|
---|
133 | $LanguageFilter = ' AND (`T`.`Language` = '.$Filter['Language'].')';
|
---|
134 | $LanguageFilterSub = ' AND (`Sub`.`Language` = '.$Filter['Language'].')';
|
---|
135 | }
|
---|
136 |
|
---|
137 | // User
|
---|
138 | $Filter['User'] = GetParameter('user', 0, true, true);
|
---|
139 | $Output .= '<td><select name="user" style="width: 80px">';
|
---|
140 | if ($Filter['User'] == 0) $Selected = ' selected="selected"';
|
---|
141 | else $Selected = '';
|
---|
142 | $Output .= '<option value="0"'.$Selected.'>'.T('All').'</option>';
|
---|
143 | $DbResult = $this->Database->query('SELECT `Id`, `Name` FROM `User` ORDER BY `Name`');
|
---|
144 | while ($User = $DbResult->fetch_assoc())
|
---|
145 | {
|
---|
146 | if ($User['Id'] == $Filter['User']) $Selected = ' selected="selected"';
|
---|
147 | else $Selected = '';
|
---|
148 | $Output .= '<option value="'.$User['Id'].'"'.$Selected.'>'.$User['Name'].'</option>';
|
---|
149 | }
|
---|
150 | $Output .= '</select></td>';
|
---|
151 | if ($Filter['User'] != 0) $UserFilter = ' AND (`User` = '.$Filter['User'].')';
|
---|
152 | else $UserFilter = '';
|
---|
153 |
|
---|
154 | // Words
|
---|
155 | $Filter['Text'] = GetParameter('text', '', false, true);
|
---|
156 | $Output .= '<td><input name="text" type="text" style="width: 60px;" value="'.htmlentities($Filter['Text']).'"></td>';
|
---|
157 | if ($Filter['Text'] != '')
|
---|
158 | {
|
---|
159 | $Items = array('(`T`.`ID` LIKE "%'.$Filter['Text'].'%")', '(`T`.`Entry` LIKE "%'.$Filter['Text'].'%")');
|
---|
160 | if ($Filter['Group'] != 0)
|
---|
161 | foreach ($TranslationTree[$Filter['Group']]['Items'] as $GroupItem)
|
---|
162 | if ($GroupItem['Visible'] == 1)
|
---|
163 | $Items[] = '(`T`.`'.$GroupItem['Column'].'` LIKE "%'.$Filter['Text'].'%")';
|
---|
164 | $Filter['SQL'] .= ' AND ('.implode(' OR ', $Items).')';
|
---|
165 | }
|
---|
166 |
|
---|
167 | // Entry
|
---|
168 | $Filter['Entry'] = GetParameter('entry', '', false, true);
|
---|
169 | $Output .= '<td><input name="entry" type="text" style="width: 60px;" value="'.htmlentities($Filter['Entry']).'"></td>';
|
---|
170 | if ($Filter['Entry'] != '')
|
---|
171 | {
|
---|
172 | $Filter['SQL'] .= ' AND (`Entry` = "'.$Filter['Entry'].'")';
|
---|
173 | }
|
---|
174 |
|
---|
175 | if ($Filter['Group'] != 0)
|
---|
176 | {
|
---|
177 | $WithoutAlter = ' AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '.
|
---|
178 | '(`Sub`.`Language` <> '.Core::Cast($this->System)->Config['OriginalLanguage'].')'.$LanguageFilterSub.
|
---|
179 | ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`ID` != `T`.`ID`) AND (`Sub`.`Complete` = 1) AND '.
|
---|
180 | '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`) LIMIT 1 ) ';
|
---|
181 | foreach ($TranslationTree[$Filter['Group']]['Items'] as $GroupItem)
|
---|
182 | if ($GroupItem['Visible'] == 1) {
|
---|
183 | $ItemsVar[] = 'LENGTH(`T`.`'.$GroupItem['Column'].'`) - LENGTH( REPLACE( `T`.`'.$GroupItem['Column'].'`, \'$\', \'\' ) ) '.
|
---|
184 | ' < ('.
|
---|
185 | 'SELECT LENGTH(`Sub`.`'.$GroupItem['Column'].'`) - LENGTH( REPLACE( `Sub`.`'.$GroupItem['Column'].'`, \'$\', \'\' ) ) FROM `'.$Table.'` AS `Sub` WHERE '.
|
---|
186 | ' `Sub`.`Entry` = `T`.`Entry` AND `Sub`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].' AND '.
|
---|
187 | '`Sub`.`VersionStart` = `T`.`VersionStart` AND `Sub`.`VersionEnd` = `T`.`VersionEnd` LIMIT 1 '.
|
---|
188 | ')';
|
---|
189 | }
|
---|
190 | if ($Filter['State'] == CompletionState::All) {
|
---|
191 | $Filter['SQL'] .= $UserFilter.$VersionFilter;
|
---|
192 | } else
|
---|
193 | if ($Filter['State'] == CompletionState::NotTranslated) {
|
---|
194 | $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') '.
|
---|
195 | 'AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '.
|
---|
196 | '(`Sub`.`Language` <> '.Core::Cast($this->System)->Config['OriginalLanguage'].') '.$LanguageFilterSub.$UserFilter.
|
---|
197 | ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`Complete` = 1) AND '.
|
---|
198 | '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`))';
|
---|
199 | } else
|
---|
200 | if ($Filter['State'] == CompletionState::Translated) {
|
---|
201 | $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Complete` = 1)';
|
---|
202 | } else
|
---|
203 | if ($Filter['State'] == CompletionState::NotFinished) {
|
---|
204 | $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'].
|
---|
205 | ') AND (`T`.`Complete` = 0)';
|
---|
206 | } else
|
---|
207 | if ($Filter['State'] == CompletionState::Original) {
|
---|
208 | $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].')';
|
---|
209 | } else
|
---|
210 | if ($Filter['State'] == CompletionState::NotFinishedNotTranslated) {
|
---|
211 | $Filter['SQL'] .= $UserFilter.$VersionFilter.$WithoutAlter.
|
---|
212 | ' AND (`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'].
|
---|
213 | ') AND (`T`.`Complete` = 0)';
|
---|
214 | } else
|
---|
215 | if ($Filter['State'] == CompletionState::Missing1) {
|
---|
216 | $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'];
|
---|
217 | $Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') ';
|
---|
218 | } else
|
---|
219 | if ($Filter['State'] == CompletionState::Missing2) {
|
---|
220 | $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'];
|
---|
221 | $Filter['SQL'] .= ' '. $WithoutAlter;
|
---|
222 | $Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') ';
|
---|
223 | }
|
---|
224 | }
|
---|
225 |
|
---|
226 | /*
|
---|
227 | // Ownership
|
---|
228 | if (array_key_exists('owner', $_GET) and is_numeric($_GET['owner'])) $Filter['Owner'] = $_GET['owner'];
|
---|
229 | else $Filter['Owner'] = 0;
|
---|
230 | $Output .= ' <td><select name="owner">';
|
---|
231 | if ($Filter['Owner'] == 0) $Selected = ' selected="selected"';
|
---|
232 | else $Selected = '';
|
---|
233 | $Output .= '<option value="0"'.$Selected.'>Všech</option>';
|
---|
234 | if ($Filter['Owner'] == 1) $Selected = ' selected="selected"';
|
---|
235 | else $Selected = '';
|
---|
236 | $Output .= '<option value="1"'.$Selected.'>Překladatelův tým</option>';
|
---|
237 | if ($Filter['Owner'] == 2) $Selected = ' selected="selected"';
|
---|
238 | else $Selected = '';
|
---|
239 | $Output .= '<option value="2"'.$Selected.'>Překladatele</option>';
|
---|
240 | $Output .= '</select></td>';
|
---|
241 | if (($Filter['Owner'] == 2) AND ($Filter['User'] != 0)) $Filter['SQL'] .= ' AND (`User` = '.$Filter['User'].')';
|
---|
242 | */
|
---|
243 |
|
---|
244 | $Output .= '<td><input type="submit" value="'.T('Filter').'"/></td>';
|
---|
245 | $Output .= '</tr></table>';
|
---|
246 | $Output .= '</form><br/>';
|
---|
247 | $Filter['Output'] = $Output;
|
---|
248 | return $Filter;
|
---|
249 | }
|
---|
250 |
|
---|
251 | function ShowTranslationList($Filter)
|
---|
252 | {
|
---|
253 | $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
|
---|
254 |
|
---|
255 | $Output = $Filter['Output'];
|
---|
256 | $Table = $TranslationTree[$Filter['Group']]['TablePrefix'];
|
---|
257 |
|
---|
258 | $Query = 'SELECT `T`.`ModifyTime`, `T`.`ID`, `T`.`Entry`, `T`.`VersionStart`, `T`.`VersionEnd`, '.
|
---|
259 | '`T`.`'.$TranslationTree[$Filter['Group']]['Items'][0]['Column'].'`, '.
|
---|
260 | '`User`.`Name` AS `UserName`, `User`.`ID` AS `UserId`, '.
|
---|
261 | '`Language`.`Name` AS `LanguageName`, `TS`.`Version` AS `VersionStartText`, `TE`.`Version` AS `VersionEndText` '.
|
---|
262 | 'FROM `'.$Table.'` AS `T` '.
|
---|
263 | 'LEFT JOIN `User` ON `User`.`ID` = `T`.`User` '.
|
---|
264 | 'LEFT JOIN `Language` ON `Language`.`ID` = `T`.`Language` '.
|
---|
265 | 'LEFT JOIN `ClientVersion` AS `TS` ON `TS`.`BuildNumber` = `T`.`VersionStart` '.
|
---|
266 | 'LEFT JOIN `ClientVersion` AS `TE` ON `TE`.`BuildNumber` = `T`.`VersionEnd` '.
|
---|
267 | 'WHERE 1 '.$Filter['SQL'];
|
---|
268 |
|
---|
269 | // Get total item count
|
---|
270 | $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `TT`');
|
---|
271 | $DbRow = $DbResult->fetch_row();
|
---|
272 | $PageList = GetPageList($DbRow[0]);
|
---|
273 |
|
---|
274 | $Output .= $PageList['Output'];
|
---|
275 | $TableColumns = array(
|
---|
276 | array('Name' => 'ID', 'Title' => T('Number')),
|
---|
277 | array('Name' => 'Entry', 'Title' => T('Item')),
|
---|
278 | array('Name' => $TranslationTree[$Filter['Group']]['Items'][0]['Column'], 'Title' => T('Name')),
|
---|
279 | array('Name' => 'VersionStart', 'Title' => T('From version')),
|
---|
280 | array('Name' => 'VersionEnd', 'Title' => T('To version')),
|
---|
281 | array('Name' => 'LanguageName', 'Title' => T('Language')),
|
---|
282 | array('Name' => 'UserName', 'Title' => T('Translator')),
|
---|
283 | array('Name' => 'ModifyTime', 'Title' => T('Date')),
|
---|
284 | );
|
---|
285 |
|
---|
286 | $Order = GetOrderTableHeader($TableColumns, 'VersionStart', 1);
|
---|
287 | $Output .= '<table class="BaseTable">'.
|
---|
288 | $Order['Output'];
|
---|
289 |
|
---|
290 | $DbResult = $this->Database->query($Query.' '.$Order['SQL'].' '.$PageList['SQLLimit']);
|
---|
291 | while ($Line = $DbResult->fetch_assoc())
|
---|
292 | {
|
---|
293 | $Text = $Line[$TranslationTree[$Filter['Group']]['Items'][0]['Column']];
|
---|
294 | if ($Text != null) $Text = htmlspecialchars($Text);
|
---|
295 |
|
---|
296 | $Output .= '<tr><td><a href="'.$this->System->Link('/form.php?group='.$Filter['Group'].'&ID='.$Line['ID']).'">'.$Line['ID'].'</a></td>'.
|
---|
297 | '<td>'.$Line['Entry'].'</td>'.
|
---|
298 | '<td>'.$Text.'</td>'.
|
---|
299 | '<td><a href="'.$this->System->Link('/client-version/?action=item&id='.
|
---|
300 | GetVersionWOWId($Line['VersionStart'])).'">'.GetVersionWOW($Line['VersionStart']).'</a></td>'.
|
---|
301 | '<td><a href="'.$this->System->Link('/client-version/?action=item&id='.
|
---|
302 | GetVersionWOWId($Line['VersionEnd'])).'">'.GetVersionWOW($Line['VersionEnd']).'</a></td>'.
|
---|
303 | '<td>'.T($Line['LanguageName']).'</td>'.
|
---|
304 | '<td><a href="'.$this->System->Link('/user/?user='.$Line['UserId']).'">'.$Line['UserName'].'</a></td>'.
|
---|
305 | '<td>'.HumanDate($Line['ModifyTime']).'</td>'.
|
---|
306 | '</tr>';
|
---|
307 | }
|
---|
308 | $Output .= '</table>'.
|
---|
309 | $PageList['Output'];
|
---|
310 | return $Output;
|
---|
311 | }
|
---|
312 |
|
---|
313 | function ShowGroupList($Filter)
|
---|
314 | {
|
---|
315 | $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
|
---|
316 |
|
---|
317 | $Output = $Filter['Output'];
|
---|
318 |
|
---|
319 | $Output .= '<table class="BaseTable"><tr><th>'.T('Group').'</th><th>'.T('Count').'</th></tr>';
|
---|
320 | $Total = 0;
|
---|
321 | foreach ($TranslationTree as $Group)
|
---|
322 | {
|
---|
323 | if ($Group['TablePrefix'] != '')
|
---|
324 | {
|
---|
325 | $Filter = $this->ShowFilter($Group['Id']);
|
---|
326 | $ID = $this->Database->query('SELECT COUNT(*) FROM `'.$Group['TablePrefix'].'` AS `T` WHERE 1 '.$Filter['SQL']);
|
---|
327 | $Line = $ID->fetch_row();
|
---|
328 | if ($Line[0] <> '0')
|
---|
329 | $Output .= '<tr><td><a href="?group='.$Group['Id'].'">'.$Group['Name'].'</td><td>'.$Line[0].'</a></tr>';
|
---|
330 | $Total += $Line[0];
|
---|
331 | }
|
---|
332 | }
|
---|
333 | $Output .= '<tr><td><strong>'.T('Total').'</strong></td><td><strong>'.$Total.'</strong></td></tr>'.
|
---|
334 | '</table>';
|
---|
335 | return $Output;
|
---|
336 | }
|
---|
337 |
|
---|
338 | function ShowMenu()
|
---|
339 | {
|
---|
340 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
---|
341 | $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
|
---|
342 |
|
---|
343 | $GroupId = GetParameter('group', 0, true);
|
---|
344 | if ($GroupId == 0) $Output = ShowMessage('Skupina nenalezena', MESSAGE_CRITICAL);
|
---|
345 | else
|
---|
346 | {
|
---|
347 | $Table = $TranslationTree[$GroupId]['TablePrefix'];
|
---|
348 |
|
---|
349 | $Output = '<h3>'.T('Basic text filtering').'</h3><br/>'.
|
---|
350 | '<table class="BaseTable"><tr><th>'.T('Link').'</th><th>'.T('Description').'</th></tr>'.
|
---|
351 | '<tr><td><a title="'.T('All texts available in group').'" href="?group='.$GroupId.'&state=4">'.T('All').'</a></td>'.
|
---|
352 | '<td>'.T('Show all available original texts in group').'</td></tr>'.
|
---|
353 | '<tr><td><a title="'.T('Translated texts, you can modify them here').'" href="?group='.$GroupId.'&state=2">'.T('Translated').'</a></td>'.
|
---|
354 | '<td>'.T('Show only translated texts').'</td></tr>'.
|
---|
355 | '<tr><td><a title="'.T('Untranslated texts').'" href="?group='.$GroupId.'&state=1">'.T('Untranslated').'</a></td>'.
|
---|
356 | '<td>'.T('Not yet translated texts which need to be translated').'</td></tr>'.
|
---|
357 | '<tr><td><a title="'.T('Unfinished texts').'" href="?group='.$GroupId.'&state=3">'.T('Unfinished').'</a></td>'.
|
---|
358 | '<td>'.T('Texts marked as unfinished').'</td></tr>';
|
---|
359 |
|
---|
360 | if ($User->Licence(LICENCE_USER))
|
---|
361 | {
|
---|
362 | $Output .= '<tr><td><a title="'.T('Unfinished texts').'" href="?group='.$GroupId.'&state=3&user='.$User->Id.'">'.T('My unfinished').'</a></td>
|
---|
363 | <td>'.T('Unfinished texts of logged-in user').'</td></tr>
|
---|
364 | <tr><td><a title="'.T('Translated texts of logged-in user').'" href="?group='.$GroupId.'&state=2&user='.$User->Id.'">'.T('My translated').'</a></td>
|
---|
365 | <td>'.T('Translated texts of logged-in user').'</td></tr>';
|
---|
366 | }
|
---|
367 |
|
---|
368 | $Output .= '<tr><td><form action="?group='.$GroupId.'&entry=" method="post"><div>'.
|
---|
369 | '<input type="text" name="text" size="8" />'.
|
---|
370 | '<input type="submit" value="'.T('Search').'" />'.
|
---|
371 | '</div></form>'.
|
---|
372 | '</td><td>'.T('Search using text').'</td></tr>';
|
---|
373 |
|
---|
374 | $Output .= '<tr><td><form action="?group='.$GroupId.'&text=" method="post"><div>'.
|
---|
375 | '<input type="text" name="entry" size="8" />'.
|
---|
376 | '<input type="submit" value="'.T('Search').'" />'.
|
---|
377 | '</div></form>'.
|
---|
378 | '</td><td>'.T('Show by datbase text ID').'</td></tr>';
|
---|
379 |
|
---|
380 | $Output .= '</table>';
|
---|
381 | }
|
---|
382 | return $Output;
|
---|
383 | }
|
---|
384 |
|
---|
385 | function Show(): string
|
---|
386 | {
|
---|
387 | $this->Title = T('Translation groups');
|
---|
388 | $Action = GetParameter('action', '');
|
---|
389 | if ($Action == 'filter') $Output = $this->ShowMenu();
|
---|
390 | else
|
---|
391 | {
|
---|
392 | $Filter = $this->ShowFilter();
|
---|
393 | if ($Filter['Group'] > 0) $Output = $this->ShowTranslationList($Filter);
|
---|
394 | else $Output = $this->ShowGroupList($Filter);
|
---|
395 | }
|
---|
396 | return $Output;
|
---|
397 | }
|
---|
398 | }
|
---|
399 |
|
---|
400 | class PageTranslationGroups extends Page
|
---|
401 | {
|
---|
402 | function ShowList()
|
---|
403 | {
|
---|
404 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
---|
405 | $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Group`');
|
---|
406 | $DbRow = $DbResult->fetch_row();
|
---|
407 | $PageList = GetPageList($DbRow[0]);
|
---|
408 | $Output = '<h3>'.T('List of translation groups').'</h3>'.
|
---|
409 | $PageList['Output'];
|
---|
410 |
|
---|
411 | $Output .= '<table class="BaseTable">';
|
---|
412 | $TableColumns = array(
|
---|
413 | array('Name' => 'Name', 'Title' => T('Name')),
|
---|
414 | array('Name' => 'SourceType', 'Title' => T('Source type')),
|
---|
415 | array('Name' => '', 'Title' => T('Sources')),
|
---|
416 | array('Name' => 'LastImport', 'Title' => T('Date of last import')),
|
---|
417 | array('Name' => 'LastVersion', 'Title' => T('Version of last import')),
|
---|
418 | );
|
---|
419 | if ($User->Licence(LICENCE_ADMIN))
|
---|
420 | $TableColumns[] = array('Name' => '', 'Title' => T('Actions'));
|
---|
421 |
|
---|
422 | $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
|
---|
423 | $Output .= $Order['Output'];
|
---|
424 |
|
---|
425 | $DbResult = $this->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']);
|
---|
426 | while ($Group = $DbResult->fetch_assoc())
|
---|
427 | {
|
---|
428 | $Output .= '<tr><td><a href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&action=filter').'">'.T($Group['Name']).'</a></td>'.
|
---|
429 | '<td>'.$Group['SourceType'].'</td><td>';
|
---|
430 | if ($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql ';
|
---|
431 | if ($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc ';
|
---|
432 | if ($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua ';
|
---|
433 | $Output .= '</td>';
|
---|
434 | if ($User->Licence(LICENCE_ADMIN))
|
---|
435 | $Output .= '<td><a title="Změny po posledním importu u vybrané překladové skupiny" href="'.$this->System->Link('/log/?group='.
|
---|
436 | $Group['Id'].'&type=11').'">'.HumanDate($Group['LastImport']).'</a></td>';
|
---|
437 | else $Output .= '<td>'.HumanDate($Group['LastImport']).'</td>';
|
---|
438 | $Output .= '<td><a href="'.$this->System->Link('/client-version/?action=item&id='.
|
---|
439 | GetVersionWOWId($Group['LastVersion'])).'">'.GetVersionWOW($Group['LastVersion']).'</a></td>';
|
---|
440 | if ($User->Licence(LICENCE_ADMIN))
|
---|
441 | $Output .= '<td><a href="?action=groupdelete&id='.$Group['Id'].'">'.T('Remove').'</a></td>';
|
---|
442 | $Output .= '</tr>';
|
---|
443 | }
|
---|
444 | $Output .= '</table>'.
|
---|
445 | '<br /><a title="'.T('Changelog of changes after import').'" href="'.$this->System->Link('/log/?type=11').'">'.T('Changelog of text modification during import').'</a><br/>';
|
---|
446 | if ($User->Licence(LICENCE_ADMIN)) $Output .= '<a href="?action=groupadd">'.T('Add translation group').'</a>';
|
---|
447 | return $Output;
|
---|
448 | }
|
---|
449 |
|
---|
450 | function ShowGroupAdd()
|
---|
451 | {
|
---|
452 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
---|
453 | if ($User->Licence(LICENCE_ADMIN))
|
---|
454 | {
|
---|
455 | $Output = '<h3>Vložení nové překladové skupiny</h3>'.
|
---|
456 | '<form action="?action=groupaddfinish" method="post">'.
|
---|
457 | '<table>'.
|
---|
458 | '<tr><td>Název:</td><td><input type="text" name="Name"/></td></tr>'.
|
---|
459 | '<tr><td>Název tabulky v databázi:</td><td>Text<input type="text" name="TablePrefix"/></td></tr>'.
|
---|
460 | '<tr><td colspan="2"><input type="submit" name="add" value="Přidat"/></td></tr>'.
|
---|
461 | '</table></form>';
|
---|
462 | } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
---|
463 | return $Output;
|
---|
464 | }
|
---|
465 |
|
---|
466 | function ShowGroupAddFinish()
|
---|
467 | {
|
---|
468 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
---|
469 | if ($User->Licence(LICENCE_ADMIN))
|
---|
470 | {
|
---|
471 | $TableName = 'Text'.$_POST['TablePrefix'];
|
---|
472 | $DbResult = $this->System->Database->select('Group', 'Id', 'TablePrefix="'.$TableName.'"');
|
---|
473 | if ($DbResult->num_rows == 0)
|
---|
474 | {
|
---|
475 |
|
---|
476 | $this->System->Database->query('CREATE TABLE IF NOT EXISTS `'.$TableName.'` (
|
---|
477 | `ID` int(11) NOT NULL AUTO_INCREMENT,
|
---|
478 | `Entry` int(11) NOT NULL,
|
---|
479 | `Name` varchar(255) NOT NULL,
|
---|
480 | `Language` int(11) NOT NULL DEFAULT "0",
|
---|
481 | `User` int(11) DEFAULT NULL,
|
---|
482 | `Complete` int(11) NOT NULL,
|
---|
483 | `CompleteParts` int(11) NOT NULL,
|
---|
484 | `Take` int(11) DEFAULT NULL,
|
---|
485 | `VersionStart` int(11) NOT NULL,
|
---|
486 | `VersionEnd` int(11) NOT NULL,
|
---|
487 | `ModifyTime` datetime NOT NULL,
|
---|
488 | PRIMARY KEY (`ID`),
|
---|
489 | KEY `Entry` (`Entry`),
|
---|
490 | KEY `User` (`User`),
|
---|
491 | KEY `Take` (`Take`),
|
---|
492 | KEY `Language` (`Language`),
|
---|
493 | KEY `Complete` (`Complete`),
|
---|
494 | KEY `VersionStart` (`VersionStart`),
|
---|
495 | KEY `VersionEnd` (`VersionEnd`),
|
---|
496 | KEY `ModifyTime` (`ModifyTime`)
|
---|
497 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
|
---|
498 |
|
---|
499 | $this->System->Database->query('ALTER TABLE `'.$TableName.'`
|
---|
500 | ADD CONSTRAINT `'.$TableName.'_ibfk_1` FOREIGN KEY (`Language`) REFERENCES `Language` (`Id`),
|
---|
501 | ADD CONSTRAINT `'.$TableName.'_ibfk_2` FOREIGN KEY (`User`) REFERENCES `User` (`ID`),
|
---|
502 | ADD CONSTRAINT `'.$TableName.'_ibfk_3` FOREIGN KEY (`Take`) REFERENCES `'.$TableName.'` (`ID`);');
|
---|
503 | $DbResult = $this->System->Database->insert('Group', array('Name' => $_POST['Name'],
|
---|
504 | 'TablePrefix' => $TableName, 'PrimaryKeyItem' => 'Entry'));
|
---|
505 | $Group = $this->System->Database->insert_id;
|
---|
506 | $this->System->Database->insert('GroupItem', array('Group' => $Group,
|
---|
507 | 'Name' => 'Jméno', 'Column' => 'Name', 'Visible' => 1));
|
---|
508 | $Output = ShowMessage('Překladová skupina vytvořena', MESSAGE_INFORMATION);
|
---|
509 | } else $Output = ShowMessage('Překladová skupina '.$TableName.' již existuje', MESSAGE_CRITICAL);
|
---|
510 | $Output .= $this->ShowList();
|
---|
511 | } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
---|
512 | return $Output;
|
---|
513 | }
|
---|
514 |
|
---|
515 | function ShowGroupDelete()
|
---|
516 | {
|
---|
517 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
---|
518 | if ($User->Licence(LICENCE_ADMIN))
|
---|
519 | {
|
---|
520 | $DbResult = $this->System->Database->select('Group', '*', '`Id`='.$_GET['id']);
|
---|
521 | if ($DbResult->num_rows == 1)
|
---|
522 | {
|
---|
523 | $Group = $DbResult->fetch_assoc();
|
---|
524 | $this->Database->query('DROP TABLE `'.$Group['TablePrefix'].'`');
|
---|
525 | $this->Database->query('DELETE FROM `GroupItem` WHERE `Group`='.$Group['Id']);
|
---|
526 | $this->Database->query('DELETE FROM `Group` WHERE `Id`='.$Group['Id']);
|
---|
527 | $Output = ShowMessage('Překladová skupina '.$Group['Name'].' smazána', MESSAGE_INFORMATION);
|
---|
528 | } else $Output = ShowMessage('Překladová skupina nenalezena', MESSAGE_CRITICAL);
|
---|
529 | } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
---|
530 | $Output .= $this->ShowList();
|
---|
531 | return $Output;
|
---|
532 | }
|
---|
533 |
|
---|
534 | function Show(): string
|
---|
535 | {
|
---|
536 | $this->Title = T('Translation groups');
|
---|
537 | $Action = GetParameter('action', '');
|
---|
538 | if ($Action == 'groupadd') $Output = $this->ShowGroupAdd();
|
---|
539 | else if ($Action == 'groupdelete') $Output = $this->ShowGroupDelete();
|
---|
540 | else if ($Action == 'groupaddfinish') $Output = $this->ShowGroupAddFinish();
|
---|
541 | else $Output = $this->ShowList();
|
---|
542 | return $Output;
|
---|
543 | }
|
---|
544 | }
|
---|