1 | <?php
|
---|
2 |
|
---|
3 | include_once('../includes/global.php');
|
---|
4 | include_once('export_output.php');
|
---|
5 |
|
---|
6 | function ExportList()
|
---|
7 | {
|
---|
8 | global $System, $User;
|
---|
9 |
|
---|
10 | echo('<a href="?Action=ViewList">Všechny</a>');
|
---|
11 | if($User->Licence(LICENCE_USER))
|
---|
12 | {
|
---|
13 | echo(' <a href="?Action=ViewList&Filter=Others">Ostatních</a>');
|
---|
14 | echo(' <a href="?Action=ViewList&Filter=My">Moje</a>');
|
---|
15 | }
|
---|
16 |
|
---|
17 | $Filter = '';
|
---|
18 | if(array_key_exists('Filter', $_GET))
|
---|
19 | {
|
---|
20 | if($_GET['Filter'] == 'My') $Filter = ' WHERE `Export`.`User` = '.$User->Id;
|
---|
21 | if($_GET['Filter'] == 'Others') $Filter = ' WHERE `Export`.`User` != '.$User->Id;
|
---|
22 | }
|
---|
23 |
|
---|
24 | $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Export` '.$Filter);
|
---|
25 | $DbRow = $DbResult->fetch_row();
|
---|
26 | $PageList = GetPageList($DbRow[0]);
|
---|
27 |
|
---|
28 | echo('<h3>Seznam exportů</h3>');
|
---|
29 | echo($PageList['Output']);
|
---|
30 |
|
---|
31 | $TableColumns = array(
|
---|
32 | array('Name' => 'TimeCreate', 'Title' => 'Čas vytvoření'),
|
---|
33 | array('Name' => 'UserName', 'Title' => 'Překladatel'),
|
---|
34 | array('Name' => 'Title', 'Title' => 'Označení'),
|
---|
35 | // array('Name' => 'UserCount', 'Title' => 'Vybraných překladatelů'),
|
---|
36 | // array('Name' => 'GroupCount', 'Title' => 'Překladových skupin'),
|
---|
37 | array('Name' => 'OutputType', 'Title' => 'Typ výstupu'),
|
---|
38 | array('Name' => 'ClientVersion', 'Title' => 'Verze klienta'),
|
---|
39 | array('Name' => 'UsedCount', 'Title' => 'Prohlédnutí výstupu'),
|
---|
40 | array('Name' => '', 'Title' => 'Akce'),
|
---|
41 | );
|
---|
42 | $Order = GetOrderTableHeader($TableColumns, 'TimeCreate', 1);
|
---|
43 | echo('<table class="BaseTable">');
|
---|
44 | echo($Order['Output']);
|
---|
45 |
|
---|
46 | $DbResult = $System->Database->query('SELECT `User`.`Name` AS `UserName`, `Export`.`Id`, `Export`.`TimeCreate`, `Export`.`Title`, `Export`.`User`, `Export`.`UsedCount`, (SELECT Version FROM `ClientVersion` WHERE `ClientVersion`.`Id`=`Export`.`ClientVersion`) AS `ClientVersion`,(SELECT Name FROM `ExportOutputType` WHERE `ExportOutputType`.`Id`=`Export`.`OutputType`) AS `OutputType`, (SELECT COUNT(*) FROM `ExportGroup` WHERE `ExportGroup`.`Export`=`Export`.`Id`) AS `GroupCount`, (SELECT COUNT(*) FROM `ExportUser` WHERE `ExportUser`.`Export`=`Export`.`Id`) AS `UserCount` FROM `Export` LEFT JOIN `User` ON `User`.`ID`=`Export`.`User` '.$Filter.$Order['SQL'].$PageList['SQLLimit']);
|
---|
47 | while($Export = $DbResult->fetch_assoc())
|
---|
48 | {
|
---|
49 | $Action = '<a href="?Action=View&ExportId='.$Export['Id'].'&Tab=0">Zobrazit</a> <a href="?Action=View&ExportId='.$Export['Id'].'&Tab=7">Exportovat</a>';
|
---|
50 | if($Export['User'] == $User->Id) $Action .= ' <a href="?Action=Delete&ExportId='.$Export['Id'].'" onclick="return confirmAction(\'Opravdu smazat položku?\');">Smazat</a>';
|
---|
51 | echo('<tr><td>'.HumanDate($Export['TimeCreate']).'</td><td>'.$Export['UserName'].'</td><td>'.$Export['Title'].'</td><td>'.$Export['OutputType'].'</td><td>'.$Export['ClientVersion'].'</td><td>'.$Export['UsedCount'].'</td><td>'.$Action.'</td></tr>');
|
---|
52 | }
|
---|
53 | echo('</table>');
|
---|
54 | echo($PageList['Output']);
|
---|
55 |
|
---|
56 | if($User->Licence(LICENCE_USER)) echo('<br/><div style="text-align: center;"><a href="?Action=Create">Vytvořit nový export</a></div>');
|
---|
57 | }
|
---|
58 |
|
---|
59 | function ExportCreate()
|
---|
60 | {
|
---|
61 | global $System, $User;
|
---|
62 |
|
---|
63 | if($User->Licence(LICENCE_USER))
|
---|
64 | {
|
---|
65 | $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$User->Id);
|
---|
66 | $DbRow = $DbResult->fetch_row();
|
---|
67 | if($DbRow[0] < $System->Config['MaxExportPerUser'])
|
---|
68 | {
|
---|
69 | echo('<form action="?Action=CreateFinish" method="post">'.
|
---|
70 | '<fieldset><legend>Vytvoření nového exportu</legend>'.
|
---|
71 | '<table><tr><td>Označení:</td><td><input type="text" name="Title" /></td></tr>'.
|
---|
72 | '<tr><td>Popis:</td><td><textarea name="Description" cols="54" rows="10"></textarea></td></tr>'.
|
---|
73 | '<tr><td colspan="2"><input type="submit" value="Vytvořit" /></td></tr>'.
|
---|
74 | '</table></fieldset></form>');
|
---|
75 | } else echo('Nemůžete vytvářet další export. Max. počet na uživatele je '.$System->Config['MaxExportPerUser'].'.');
|
---|
76 | } else echo('Nemáte oprávnění');
|
---|
77 | }
|
---|
78 |
|
---|
79 | function ExportCreateFinish()
|
---|
80 | {
|
---|
81 | global $User, $System;
|
---|
82 |
|
---|
83 | if($User->Licence(LICENCE_USER))
|
---|
84 | {
|
---|
85 | if(array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
|
---|
86 | {
|
---|
87 | $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$User->Id);
|
---|
88 | $DbRow = $DbResult->fetch_row();
|
---|
89 | if($DbRow[0] < $System->Config['MaxExportPerUser'])
|
---|
90 | {
|
---|
91 | $System->Database->query('INSERT INTO `Export` (`Title`, `User`, `TimeCreate`, `WithDiacritic`, `Description`) VALUES ("'.$_POST['Title'].'", '.$User->Id.', NOW(), 1, "'.$_POST['Description'].'")');
|
---|
92 | $ExportId = $System->Database->insert_id;
|
---|
93 | echo('Nový export vytvořen.<br/>Přímý odkaz na tento export: <a href="?Action=View&ExportId='.$ExportId.'">zde</a><br/><br/>');
|
---|
94 | WriteLog('Vytvořen nový export <a href="'.$System->Link('/export/?Action=View&ExportId='.$ExportId).'">'.$ExportId.'</a>.', LOG_TYPE_EXPORT);
|
---|
95 | $_GET['Filter'] = 'my';
|
---|
96 | ExportList();
|
---|
97 | } else echo('Nemůžete vytvářet další export. Max. počet na uživatele je '.$System->Config['MaxExportPerUser'].'.');
|
---|
98 | } else echo('Chybí údaje formuláře');
|
---|
99 | } else echo('Nemáte oprávnění');
|
---|
100 | }
|
---|
101 |
|
---|
102 | function ExportDelete()
|
---|
103 | {
|
---|
104 | global $System, $User;
|
---|
105 |
|
---|
106 | if($User->Licence(LICENCE_USER))
|
---|
107 | {
|
---|
108 | $System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId'].' AND `User`='.$User->Id);
|
---|
109 | $System->Database->query('DELETE FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
110 | DeleteDirectory('../tmp/Export/'.$_GET['ExportId'].'/');
|
---|
111 | echo('Export smazán.<br/><br/>');
|
---|
112 | $_GET['Filter'] = 'my';
|
---|
113 | WriteLog('Smazán export '.$_GET['ExportId'], LOG_TYPE_EXPORT);
|
---|
114 | ExportList();
|
---|
115 | } else echo('Nemáte oprávnění');
|
---|
116 | }
|
---|
117 |
|
---|
118 | function ExportViewTranslators()
|
---|
119 | {
|
---|
120 | global $TranslationTree, $User, $System;
|
---|
121 |
|
---|
122 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
---|
123 | $DbResult = $System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
124 | $Export = $DbResult->fetch_assoc();
|
---|
125 | if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
|
---|
126 | else $Editable = false;
|
---|
127 |
|
---|
128 | if(array_key_exists('Operation', $_GET))
|
---|
129 | {
|
---|
130 | if($_GET['Operation'] == 'Save')
|
---|
131 | {
|
---|
132 | //print_r($_POST);
|
---|
133 | // Update user selection page
|
---|
134 | foreach($_POST as $Index => $Value)
|
---|
135 | {
|
---|
136 | if(substr($Index, 0, 3) == 'seq')
|
---|
137 | {
|
---|
138 | $UserId = substr($Index, 3) * 1;
|
---|
139 | if(array_key_exists('sel'.$UserId, $_POST)) $Selected = true;
|
---|
140 | else $Selected = false;
|
---|
141 | $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `User`='.$UserId;
|
---|
142 | $DbResult = $System->Database->query('SELECT * FROM `ExportUser` '.$Condition);
|
---|
143 | if($DbResult->num_rows > 0)
|
---|
144 | {
|
---|
145 | if(!$Selected) $System->Database->query('DELETE FROM `ExportUser` '.$Condition);
|
---|
146 | else $System->Database->query('UPDATE `ExportUser` SET `Sequence`='.$Value.$Condition);
|
---|
147 | } else
|
---|
148 | {
|
---|
149 | if($Selected) $System->Database->query('INSERT INTO `ExportUser` (`Export`, `User`, `Sequence`) VALUES ('.$_GET['ExportId'].', '.$UserId.', '.$Value.')');
|
---|
150 | }
|
---|
151 | }
|
---|
152 | }
|
---|
153 |
|
---|
154 | // Recalculate sequence number
|
---|
155 | $System->Database->query('SET @I = 0');
|
---|
156 | $System->Database->query('UPDATE `ExportUser` SET `Sequence` = (@I := @I + 1) WHERE `Export`='.$_GET['ExportId'].' ORDER BY `Sequence`;');
|
---|
157 | }
|
---|
158 | }
|
---|
159 |
|
---|
160 | $TableColumns = array(
|
---|
161 | array('Name' => 'Name', 'Title' => 'Jméno'),
|
---|
162 | array('Name' => 'TranslatedCount', 'Title' => 'Překladů'),
|
---|
163 | array('Name' => 'XP', 'Title' => 'Úroveň'),
|
---|
164 | array('Name' => 'XP', 'Title' => 'Zkušenost'),
|
---|
165 | array('Name' => '', 'Title' => 'Výběr'),
|
---|
166 | array('Name' => 'Sequence2', 'Title' => 'Pořadí'),
|
---|
167 | );
|
---|
168 | $Order = GetOrderTableHeader($TableColumns, 'TranslatedCount', 1);
|
---|
169 | if($Order['Column'] != 'Sequence2') $InitialOrder = ', '.substr($Order['SQL'], 10);
|
---|
170 | else $InitialOrder = '';
|
---|
171 |
|
---|
172 | $Query = 'SELECT (@I := @I + 1) AS `Sequence2`, `TT`.* FROM (SELECT `ExportUser`.`Sequence`, `T`.`ID`, `T`.`TranslatedCount`, `T`.`Name`, `T`.`XP` FROM (SELECT `User`.`ID`, `User`.`Name`, `User`.`XP`, `TranslatedCount` FROM `User`) AS T';
|
---|
173 | $Query .=' LEFT JOIN `ExportUser` ON `ExportUser`.`Export` = '.$_GET['ExportId'].' AND `ExportUser`.`User`=`T`.`ID`';
|
---|
174 | $Query .=' WHERE `T`.`TranslatedCount` > 0 ORDER BY COALESCE(`ExportUser`.`Sequence`, 100000000)'.$InitialOrder.') AS `TT`';
|
---|
175 |
|
---|
176 | $DbResult = $System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `X`');
|
---|
177 | $DbRow = $DbResult->fetch_row();
|
---|
178 | $PageList = GetPageList($DbRow[0]);
|
---|
179 |
|
---|
180 | echo('<form name="Translators" action="?Action=View&ExportId='.$_GET['ExportId'].'&Operation=Save" method="post">');
|
---|
181 | echo('<h3>Překladatelé</h3>');
|
---|
182 | if($Editable)
|
---|
183 | {
|
---|
184 | echo('<input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/>'.
|
---|
185 | ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' Zatrhnout vše</span> '.
|
---|
186 | '<br />'.
|
---|
187 | 'Zvolte ze seznamu uživatele, od kterých chcete načítat překlady a upravte jejich pořadí.<br />'.
|
---|
188 | 'Pořadí řádků je dáno číselnou hodnotou, kterou lze změnit na požadované pořadí. Řádky se stejným pořadovým číslem budou přečíslovány vzestupně.');
|
---|
189 | }
|
---|
190 |
|
---|
191 | echo($PageList['Output']);
|
---|
192 | echo('<table class="BaseTable">');
|
---|
193 | echo($Order['Output']);
|
---|
194 |
|
---|
195 | $Query = 'SELECT * FROM ('.$Query.') AS `TX` '.$Order['SQL'].$PageList['SQLLimit'];
|
---|
196 | $System->Database->query('SET @I = 0');
|
---|
197 | $DbResult = $System->Database->query($Query);
|
---|
198 | while($UserLine = $DbResult->fetch_assoc())
|
---|
199 | {
|
---|
200 | $XP = GetLevelMinMax($UserLine['XP']);
|
---|
201 | $Checked = $UserLine['Sequence'] != '';
|
---|
202 | $Selection = CheckBox('sel'.$UserLine['ID'], $Checked, '', 'CheckBox', !$Editable);
|
---|
203 | $Sequence = '<input type="text" name="seq'.$UserLine['ID'].'" style="text-align: center; width: 40px;" value="'.$UserLine['Sequence2'].'"'.$DisabledInput[$Editable].'/>';
|
---|
204 | echo('<tr>'.
|
---|
205 | '<td><a href="'.$System->Link('/TranslationList.php?user='.$UserLine['ID'].'&state=2&group=0').'" title="Zobrazit všechny jeho přeložené texty">'.$UserLine['Name'].'</a></td>'.
|
---|
206 | '<td>'.$UserLine['TranslatedCount'].'</td>'.
|
---|
207 | '<td>'.$XP['Level'].'</td>'.
|
---|
208 | '<td>'.ProgressBar(150, round($XP['XP'] / $XP['MaxXP'] * 100, 2), $XP['XP'].' / '.$XP['MaxXP']).'</td>'.
|
---|
209 | '<td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>');
|
---|
210 | }
|
---|
211 | echo('</table>');
|
---|
212 | echo('</form>');
|
---|
213 | echo($PageList['Output']);
|
---|
214 | }
|
---|
215 |
|
---|
216 | function ExportViewGeneral()
|
---|
217 | {
|
---|
218 | global $System, $User;
|
---|
219 |
|
---|
220 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
---|
221 | $DisabledTextArea = array(false => ' readonly="yes"', true => '');
|
---|
222 | echo('<h3>Obecná nastavení</h3>');
|
---|
223 | $DbRows = $System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
224 | $Export = $DbRows->fetch_assoc();
|
---|
225 | if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
|
---|
226 | else $Editable = false;
|
---|
227 | if($Editable and array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
|
---|
228 | {
|
---|
229 | if(array_key_exists('WithDiacritic', $_POST)) $WithDiacritic = 1;
|
---|
230 | else $WithDiacritic = 0;
|
---|
231 | $System->Database->query('UPDATE `Export` SET `Title`="'.$_POST['Title'].'", `Description`="'.$_POST['Description'].'", `WithDiacritic`='.$WithDiacritic.' WHERE Id='.$Export['Id']);
|
---|
232 | $Export['Title'] = $_POST['Title'];
|
---|
233 | $Export['Description'] = $_POST['Description'];
|
---|
234 | $Export['WithDiacritic'] = $WithDiacritic;
|
---|
235 | }
|
---|
236 |
|
---|
237 | if($Export['WithDiacritic'] == 1) $WithDiacritic = ' checked="checked"'; else $WithDiacritic = '';
|
---|
238 | echo('<form action="?Action=View&Tab=0&ExportId='.$Export['Id'].'" method="post">'.
|
---|
239 | '<table>');
|
---|
240 | if($Editable)
|
---|
241 | {
|
---|
242 | echo('<tr><td colspan="2"><input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/></td></tr>');
|
---|
243 | }
|
---|
244 | echo('<tr><td>Označení:</td><td><input type="text" style="width: 400px" name="Title" value="'.$Export['Title'].'"'.$DisabledInput[$Editable].'/></td></tr>'.
|
---|
245 | '<tr><td>Popis:</td><td><textarea name="Description" cols="54" rows="10"'.$DisabledTextArea[$Editable].'>'.$Export['Description'].'</textarea></td></tr>'.
|
---|
246 | '<tr><td>Včetně háčků a čárek</td><td><input type="checkbox" name="WithDiacritic" '.$WithDiacritic.''.$DisabledInput[$Editable].'/></td></tr>'.
|
---|
247 | '</table></form>');
|
---|
248 | }
|
---|
249 |
|
---|
250 | function ExportViewLanguages()
|
---|
251 | {
|
---|
252 | global $System, $TranslationTree, $User;
|
---|
253 |
|
---|
254 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
---|
255 | $DbRows = $System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
256 | $Export = $DbRows->fetch_assoc();
|
---|
257 | if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
|
---|
258 | else $Editable = false;
|
---|
259 |
|
---|
260 | if(array_key_exists('Operation', $_GET))
|
---|
261 | {
|
---|
262 | if($_GET['Operation'] == 'Save')
|
---|
263 | {
|
---|
264 | //print_r($_POST);
|
---|
265 | // Update user selection page
|
---|
266 | foreach($_POST as $Index => $Value)
|
---|
267 | {
|
---|
268 | if(substr($Index, 0, 3) == 'seq')
|
---|
269 | {
|
---|
270 | $LanguageId = substr($Index, 3) * 1;
|
---|
271 | if(array_key_exists('sel'.$LanguageId, $_POST)) $Selected = true;
|
---|
272 | else $Selected = false;
|
---|
273 | $Condition = ' WHERE Export='.$_GET['ExportId'].' AND `Language`='.$LanguageId;
|
---|
274 | $DbResult = $System->Database->query('SELECT * FROM `ExportLanguage` '.$Condition);
|
---|
275 | if($DbResult->num_rows > 0)
|
---|
276 | {
|
---|
277 | if(!$Selected) $System->Database->query('DELETE FROM `ExportLanguage` '.$Condition);
|
---|
278 | else $System->Database->query('UPDATE `ExportLanguage` SET `Sequence`='.$Value.$Condition);
|
---|
279 | } else
|
---|
280 | {
|
---|
281 | if($Selected) $System->Database->query('INSERT INTO `ExportLanguage` (`Export`, `Language`, `Sequence`) VALUES ('.$_GET['ExportId'].', '.$LanguageId.', '.$Value.')');
|
---|
282 | }
|
---|
283 | }
|
---|
284 | }
|
---|
285 |
|
---|
286 | // Recalculate sequence number
|
---|
287 | $System->Database->query('SET @I = 0');
|
---|
288 | $System->Database->query('UPDATE `ExportLanguage` SET `Sequence` = (@I := @I + 1) WHERE `Export`='.$_GET['ExportId'].' ORDER BY `Sequence`;');
|
---|
289 | }
|
---|
290 | }
|
---|
291 |
|
---|
292 | $Query = 'SELECT (@I := @I + 1) AS `Sequence2`, `Sequence`, `Language`.`Id`, `Name` FROM `Language`';
|
---|
293 | $Query .=' LEFT JOIN `ExportLanguage` ON `ExportLanguage`.`Export` = '.$_GET['ExportId'].' AND `ExportLanguage`.`Language`=`Language`.`Id`';
|
---|
294 | $Query .=' WHERE `Language`.`Enabled` = 1 ORDER BY COALESCE(`Sequence`, 100)';
|
---|
295 |
|
---|
296 | $DbResult = $System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS X');
|
---|
297 | $DbRow = $DbResult->fetch_row();
|
---|
298 | $PageList = GetPageList($DbRow[0]);
|
---|
299 |
|
---|
300 | $TableColumns = array(
|
---|
301 | array('Name' => 'Name', 'Title' => 'Název'),
|
---|
302 | array('Name' => '', 'Title' => 'Výběr'),
|
---|
303 | array('Name' => 'Sequence2', 'Title' => 'Pořadí'),
|
---|
304 | );
|
---|
305 | $Order = GetOrderTableHeader($TableColumns, 'Sequence2');
|
---|
306 | echo('<form action="?Action=View&ExportId='.$_GET['ExportId'].'&Operation=Save" method="post">');
|
---|
307 | echo('<h3>Jazyky</h3>');
|
---|
308 | if($Editable)
|
---|
309 | {
|
---|
310 | echo('<input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/>'.
|
---|
311 | '<br />'.
|
---|
312 | 'Zvolte ze seznamu dostupných jazyků, ze kterých chcete sestavit překlady a upravte jejich pořadí.<br />'.
|
---|
313 | 'Pořadí řádků je dáno číselnou hodnotou, kterou lze změnit na požadované pořadí. Řádky se stejným pořadovým číslem budou přečíslovány vzestupně.');
|
---|
314 | }
|
---|
315 |
|
---|
316 | echo($PageList['Output']);
|
---|
317 | echo('<table class="BaseTable">');
|
---|
318 | echo($Order['Output']);
|
---|
319 |
|
---|
320 | $Query = 'SELECT * FROM ('.$Query.') AS TX '.$Order['SQL'].$PageList['SQLLimit'];
|
---|
321 | $System->Database->query('SET @I = 0');
|
---|
322 | $DbResult = $System->Database->query($Query);
|
---|
323 | while($Langugage = $DbResult->fetch_assoc())
|
---|
324 | {
|
---|
325 | $Checked = $Langugage['Sequence'] != '';
|
---|
326 | $Selection = CheckBox('sel'.$Langugage['Id'], $Checked, '', 'CheckBox', !$Editable);
|
---|
327 | $Sequence = '<input type="text" name="seq'.$Langugage['Id'].'" style="text-align: center; width: 40px;" value="'.$Langugage['Sequence2'].'"'.$DisabledInput[$Editable].'/>';
|
---|
328 | echo('<tr>
|
---|
329 | <td>'.$Langugage['Name'].'</a></td>
|
---|
330 | <td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>');
|
---|
331 | }
|
---|
332 | echo('</table>');
|
---|
333 | echo('</form>');
|
---|
334 | echo($PageList['Output']);
|
---|
335 | }
|
---|
336 |
|
---|
337 | function ExportViewGroups()
|
---|
338 | {
|
---|
339 | global $System, $TranslationTree, $User;
|
---|
340 |
|
---|
341 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
---|
342 | $DbRows = $System->Database->query('SELECT * FROM Export WHERE Id='.$_GET['ExportId']);
|
---|
343 | $Export = $DbRows->fetch_assoc();
|
---|
344 | if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
|
---|
345 | else $Editable = false;
|
---|
346 |
|
---|
347 | if(array_key_exists('Operation', $_GET))
|
---|
348 | {
|
---|
349 | if($_GET['Operation'] == 'Save')
|
---|
350 | {
|
---|
351 | //print_r($_POST);
|
---|
352 | // Update user selection page
|
---|
353 | foreach($_POST as $Index => $Value)
|
---|
354 | {
|
---|
355 | if(substr($Index, 0, 3) == 'seq')
|
---|
356 | {
|
---|
357 | $GroupId = substr($Index, 3) * 1;
|
---|
358 | if(array_key_exists('sel'.$GroupId, $_POST)) $Selected = true;
|
---|
359 | else $Selected = false;
|
---|
360 | $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `Group`='.$GroupId;
|
---|
361 | $DbResult = $System->Database->query('SELECT * FROM `ExportGroup` '.$Condition);
|
---|
362 | if($DbResult->num_rows > 0)
|
---|
363 | {
|
---|
364 | if(!$Selected) $System->Database->query('DELETE FROM `ExportGroup` '.$Condition);
|
---|
365 | } else
|
---|
366 | {
|
---|
367 | if($Selected) $System->Database->query('INSERT INTO `ExportGroup` (`Export`, `Group`) VALUES ('.$_GET['ExportId'].', '.$GroupId.')');
|
---|
368 | }
|
---|
369 | }
|
---|
370 | }
|
---|
371 | }
|
---|
372 | }
|
---|
373 |
|
---|
374 | $Query = 'SELECT `Group`.*, `ExportGroup`.`Id` AS `ExportGroupId` FROM `Group` LEFT JOIN `ExportGroup` ON `ExportGroup`.`Export`='.$_GET['ExportId'].' AND `Group`=`Group`.`Id`';
|
---|
375 |
|
---|
376 | $DbResult = $System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS X');
|
---|
377 | $DbRow = $DbResult->fetch_row();
|
---|
378 | $PageList = GetPageList($DbRow[0]);
|
---|
379 |
|
---|
380 | $TableColumns = array(
|
---|
381 | array('Name' => 'Name', 'Title' => 'Jméno'),
|
---|
382 | array('Name' => 'MangosTable', 'Title' => 'Tabulka MaNGOSu'),
|
---|
383 | array('Name' => 'DBCFileName', 'Title' => 'DBC soubor'),
|
---|
384 | array('Name' => 'LuaFileName', 'Title' => 'Lua soubor'),
|
---|
385 | array('Name' => '', 'Title' => 'Výběr'),
|
---|
386 | );
|
---|
387 | $Order = GetOrderTableHeader($TableColumns, 'Name');
|
---|
388 | echo('<form action="?Action=View&ExportId='.$_GET['ExportId'].'&Operation=Save" method="post">');
|
---|
389 | echo('<h3>Překladové skupiny</h3>');
|
---|
390 | if($Editable)
|
---|
391 | {
|
---|
392 | echo('<input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/>'.
|
---|
393 | ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' Zatrhnout vše</span> '.
|
---|
394 | '<br />'.
|
---|
395 | 'Zvolte ze překladových skupin, ze kterých chcete načítat překlady.<br />');
|
---|
396 | }
|
---|
397 |
|
---|
398 | echo($PageList['Output']);
|
---|
399 | echo('<table class="BaseTable">');
|
---|
400 | echo($Order['Output']);
|
---|
401 |
|
---|
402 | $Query = 'SELECT * FROM ('.$Query.') AS TX '.$Order['SQL'].$PageList['SQLLimit'];
|
---|
403 | $DbResult = $System->Database->query($Query);
|
---|
404 | while($Group = $DbResult->fetch_assoc())
|
---|
405 | {
|
---|
406 | $Checked = $Group['ExportGroupId'] != '';
|
---|
407 | $Selection = CheckBox('sel'.$Group['Id'], $Checked, '', 'CheckBox', !$Editable);
|
---|
408 | echo('<tr>'.
|
---|
409 | '<td>'.$Group['Name'].'</td>'.
|
---|
410 | '<td>'.$Group['MangosTable'].'</td>'.
|
---|
411 | '<td>'.$Group['DBCFileName'].'</td>'.
|
---|
412 | '<td>'.$Group['LuaFileName'].'</td>'.
|
---|
413 | '<td>'.$Selection.'<input type="hidden" name="seq'.$Group['Id'].'"/></td></tr>');
|
---|
414 | }
|
---|
415 | echo('</table>');
|
---|
416 | echo('</form>');
|
---|
417 | echo($PageList['Output']);
|
---|
418 | }
|
---|
419 |
|
---|
420 | function ExportViewOutputFormat()
|
---|
421 | {
|
---|
422 | global $System, $User;
|
---|
423 |
|
---|
424 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
---|
425 | if(array_key_exists('ExportId', $_GET))
|
---|
426 | {
|
---|
427 | $DbRows = $System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
428 | if($DbRows->num_rows > 0)
|
---|
429 | {
|
---|
430 | $Export = $DbRows->fetch_assoc();
|
---|
431 | if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
|
---|
432 | else $Editable = false;
|
---|
433 |
|
---|
434 | if(array_key_exists('OutputType', $_POST))
|
---|
435 | {
|
---|
436 | $System->Database->query('UPDATE Export SET OutputType='.$_POST['OutputType'].' WHERE Id='.$_GET['ExportId']);
|
---|
437 | }
|
---|
438 |
|
---|
439 | $DbResult = $System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
440 | $Export = $DbResult->fetch_assoc();
|
---|
441 |
|
---|
442 | echo('<h3>Formát generovaného výstupu</h3>');
|
---|
443 | echo('<form action="?Action=View&ExportId='.$_GET['ExportId'].'&Operation=Save" method="post">');
|
---|
444 | if($Editable)
|
---|
445 | {
|
---|
446 | echo('<input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/>'.
|
---|
447 | '<br />');
|
---|
448 | }
|
---|
449 | $DbResult = $System->Database->query('SELECT * FROM `ExportOutputType` ORDER BY `Name`');
|
---|
450 | while($ExportFormat = $DbResult->fetch_assoc())
|
---|
451 | {
|
---|
452 | echo(RadioButton('OutputType', $ExportFormat['Id'], $Export['OutputType'] == $ExportFormat['Id'], '', !$Editable).' '.$ExportFormat['Name'].'<br/>');
|
---|
453 | }
|
---|
454 | echo('</form>');
|
---|
455 | } else echo('Položka nenalezena');
|
---|
456 | } else echo('Nebylo zadáno Id');
|
---|
457 | }
|
---|
458 |
|
---|
459 | function ExportViewVersion()
|
---|
460 | {
|
---|
461 | global $System, $User;
|
---|
462 |
|
---|
463 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
---|
464 | $DbRows = $System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
465 | $Export = $DbRows->fetch_assoc();
|
---|
466 | if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
|
---|
467 | else $Editable = false;
|
---|
468 |
|
---|
469 | if(array_key_exists('ClientVersion', $_POST))
|
---|
470 | {
|
---|
471 | $System->Database->query('UPDATE `Export` SET `ClientVersion`='.$_POST['ClientVersion'].' WHERE `Id`='.$_GET['ExportId']);
|
---|
472 | }
|
---|
473 |
|
---|
474 | $DbResult = $System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
475 | $Export = $DbResult->fetch_assoc();
|
---|
476 |
|
---|
477 | $Query = 'SELECT `ClientVersion`.* FROM `ExportVersion` LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id`=`ExportVersion`.`ClientVersion` WHERE `ExportType`='.$Export['OutputType'];
|
---|
478 |
|
---|
479 | $DbResult = $System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `X`');
|
---|
480 | $DbRow = $DbResult->fetch_row();
|
---|
481 | $PageList = GetPageList($DbRow[0]);
|
---|
482 |
|
---|
483 | $TableColumns = array(
|
---|
484 | array('Name' => 'Version', 'Title' => 'Verze'),
|
---|
485 | array('Name' => 'BuildNumber', 'Title' => 'Sestavení'),
|
---|
486 | array('Name' => 'ReleaseDate', 'Title' => 'Datum uvolnění'),
|
---|
487 | array('Name' => 'Title', 'Title' => 'Titutek'),
|
---|
488 | array('Name' => '', 'Title' => 'Výběr'),
|
---|
489 | );
|
---|
490 | $Order = GetOrderTableHeader($TableColumns, 'BuildNumber', 1);
|
---|
491 | echo('<form action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">');
|
---|
492 | echo('<h3>Verze klienta</h3>');
|
---|
493 |
|
---|
494 | if($Editable)
|
---|
495 | {
|
---|
496 | echo('<input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/>'.
|
---|
497 | '<br />'.
|
---|
498 | 'Vyberte pro jakou verzi herního klienta se budou texty exportovat.<br />');
|
---|
499 | }
|
---|
500 | echo($PageList['Output']);
|
---|
501 | echo('<table class="BaseTable">');
|
---|
502 | echo($Order['Output']);
|
---|
503 |
|
---|
504 | $Query = 'SELECT * FROM ('.$Query.') AS `TX` '.$Order['SQL'].$PageList['SQLLimit'];
|
---|
505 | $DbResult = $System->Database->query($Query);
|
---|
506 | while($Version = $DbResult->fetch_assoc())
|
---|
507 | {
|
---|
508 | echo('<tr><td><a href="http://www.wowwiki.com/Patch_'.$Version['Version'].'">'.$Version['Version'].'</a></td><td>'.$Version['BuildNumber'].'</td><td>'.HumanDate($Version['ReleaseDate']).'</td><td>'.$Version['Title'].'</td><td>'.RadioButton('ClientVersion', $Version['Id'], $Export['ClientVersion'] == $Version['Id'], '', !$Editable
|
---|
509 | ).'</td></tr>');
|
---|
510 |
|
---|
511 | }
|
---|
512 | echo('</table>');
|
---|
513 | echo('</form>');
|
---|
514 | echo($PageList['Output']);
|
---|
515 | }
|
---|
516 |
|
---|
517 | function ExportViewOutput()
|
---|
518 | {
|
---|
519 | global $System;
|
---|
520 |
|
---|
521 | $DbResult = $System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
522 | $Export = $DbResult->fetch_assoc();
|
---|
523 | $DbResult = $System->Database->query('SELECT * FROM `ExportOutputType` WHERE `Id`='.$Export['OutputType']);
|
---|
524 | if($DbResult->num_rows > 0)
|
---|
525 | {
|
---|
526 | $DbResult = $System->Database->query('SELECT * FROM `ExportVersion` WHERE `ExportType`='.$Export[ 'OutputType'].' AND `ClientVersion`='.$Export['ClientVersion']);
|
---|
527 | if($DbResult->num_rows > 0)
|
---|
528 | {
|
---|
529 | $System->Database->query('UPDATE Export SET UsedCount = UsedCount + 1 WHERE Id='.$Export['Id']);
|
---|
530 | ExportOutput($Export['Id'], $Export['OutputType']);
|
---|
531 | } else echo('Nebyla vybrána požadovaná verze klienta');
|
---|
532 | } else echo('Nebyl vybrán formát výstupu.');
|
---|
533 | }
|
---|
534 |
|
---|
535 | function ExportViewStat()
|
---|
536 | {
|
---|
537 | global $System;
|
---|
538 |
|
---|
539 | $Export = new Export($System);
|
---|
540 | $Export->Id = $_GET['ExportId'];
|
---|
541 | $Export->Init();
|
---|
542 | $Export->LoadFilters();
|
---|
543 |
|
---|
544 | if($Export->ClientVersion['BuildNumber'] == '') ErrorMessage('Nebyla vybrána verze klienta');
|
---|
545 | $GroupListQuery = 'SELECT `Group`.* FROM `Group` '.
|
---|
546 | ' JOIN `ExportGroup` ON (`ExportGroup`.`Export`='.$Export->Id.') AND (`ExportGroup`.`Group`=`Group`.`Id`)';
|
---|
547 | $Query = '';
|
---|
548 | $UnionItems = array();
|
---|
549 | $DbResult = $System->Database->query($GroupListQuery);
|
---|
550 | while($DbRow = $DbResult->fetch_assoc())
|
---|
551 | {
|
---|
552 | $UnionItems[] = 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
|
---|
553 | ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'.
|
---|
554 | ' JOIN `ExportUser` ON (`ExportUser`.`User`=`T`.`User`) AND (`ExportUser`.`Export`='.$Export->Id.') '.
|
---|
555 | ' JOIN `ExportLanguage` ON (`ExportLanguage`.`Export`='.$Export->Id.')'.
|
---|
556 | ' WHERE (`Complete` = 1) AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
|
---|
557 | ') AS `C1`) AS `Translated`, '.
|
---|
558 | '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
|
---|
559 | ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'.
|
---|
560 | ' WHERE (`Language` = 0) AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
|
---|
561 | ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name`';
|
---|
562 | }
|
---|
563 | $Query = substr($Query, 0, - 6);
|
---|
564 |
|
---|
565 | $DbResult = $System->Database->query('SELECT COUNT(*) FROM ('.$GroupListQuery.') AS `T`');
|
---|
566 | $DbRow = $DbResult->fetch_row();
|
---|
567 | $PageList = GetPageList($DbRow[0]);
|
---|
568 | echo('<h3>Statistika dokončení vybraných skupin</h3>');
|
---|
569 | echo($PageList['Output']);
|
---|
570 |
|
---|
571 | echo('<table class="BaseTable">');
|
---|
572 | $TableColumns = array(
|
---|
573 | array('Name' => 'Name', 'Title' => 'Jméno'),
|
---|
574 | array('Name' => 'Translated', 'Title' => 'Přeložených'),
|
---|
575 | array('Name' => 'Total', 'Title' => 'Anglických'),
|
---|
576 | array('Name' => 'Percent', 'Title' => 'Procenta'),
|
---|
577 | );
|
---|
578 |
|
---|
579 | $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
|
---|
580 | echo($Order['Output']);
|
---|
581 |
|
---|
582 | $Translated = 0;
|
---|
583 | $Total = 0;
|
---|
584 | if(count($UnionItems) > 0)
|
---|
585 | {
|
---|
586 | $ID = $System->Database->query('SELECT *, ROUND(`Translated` / `Total` * 100, 2) AS `Percent` FROM ('.implode(' UNION ALL ', $UnionItems).') AS `C3` '.$Order['SQL'].$PageList['SQLLimit']);
|
---|
587 | while($Group = $ID->fetch_assoc())
|
---|
588 | {
|
---|
589 | echo('<tr><td>'.$Group['Name'].'</td><td>'.$Group['Translated'].'</td><td>'.$Group['Total'].'</td><td>'.ProgressBar(150, $Group['Percent']).'</td></tr>');
|
---|
590 | $Translated += $Group['Translated'];
|
---|
591 | $Total += $Group['Total'];
|
---|
592 | }
|
---|
593 | }
|
---|
594 | if($Total > 0) $Percent = $Translated / $Total * 100;
|
---|
595 | else $Percent = 100;
|
---|
596 |
|
---|
597 | echo('<tr><td><strong>Celkem</strong></td><td><strong>'.$Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.ProgressBar(150, round($Percent, 2)).'</strong></td></tr>');
|
---|
598 | echo('</table>');
|
---|
599 | }
|
---|
600 |
|
---|
601 | function ExportView()
|
---|
602 | {
|
---|
603 | global $System;
|
---|
604 |
|
---|
605 | if(array_key_exists('ExportId', $_GET) and is_numeric($_GET['ExportId']))
|
---|
606 | {
|
---|
607 | $DbResult = $System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
608 | if($DbResult->num_rows > 0)
|
---|
609 | {
|
---|
610 | $Export = $DbResult->fetch_assoc();
|
---|
611 |
|
---|
612 | $DbResult = $System->Database->query('SELECT * FROM `User` WHERE `ID`='.$Export['User']);
|
---|
613 | $UserLine = $DbResult->fetch_assoc();
|
---|
614 | echo('Export <strong><a href="?Action=View&Tab=6&ExportId='.$Export['Id'].'">'.$_GET['ExportId'].'</a></strong> překladatele <strong>'.$UserLine['Name'].'</strong> s označením <strong>'.$Export['Title'].'</strong>');
|
---|
615 | ShowTabs(array('Obecné', 'Překladatelé', 'Překlady', 'Jazyky', 'Formát', 'Verze', 'Statistika', 'Výstup'));
|
---|
616 | echo('<div id="content">');
|
---|
617 | if($_SESSION['Tab'] == 0) ExportViewGeneral();
|
---|
618 | else if($_SESSION['Tab'] == 1) ExportViewTranslators();
|
---|
619 | else if($_SESSION['Tab'] == 2) ExportViewGroups();
|
---|
620 | else if($_SESSION['Tab'] == 3) ExportViewLanguages();
|
---|
621 | else if($_SESSION['Tab'] == 4) ExportViewOutputFormat();
|
---|
622 | else if($_SESSION['Tab'] == 5) ExportViewVersion();
|
---|
623 | else if($_SESSION['Tab'] == 6) ExportViewStat();
|
---|
624 | else if($_SESSION['Tab'] == 7) ExportViewOutput();
|
---|
625 | else ExportViewGeneral();
|
---|
626 |
|
---|
627 | echo('</div>');
|
---|
628 | } else echo('Export nenalezen');
|
---|
629 | } else echo('Nebylo zadáno Id');
|
---|
630 | }
|
---|
631 |
|
---|
632 | ShowPage();
|
---|
633 |
|
---|
634 | if(array_key_exists('Action', $_GET))
|
---|
635 | {
|
---|
636 | if($_GET['Action'] == 'Create') ExportCreate();
|
---|
637 | else if($_GET['Action'] == 'CreateFinish') ExportCreateFinish();
|
---|
638 | else if($_GET['Action'] == 'View') ExportView();
|
---|
639 | else if($_GET['Action'] == 'Delete') ExportDelete();
|
---|
640 | else ExportList();
|
---|
641 | } else ExportList();
|
---|
642 |
|
---|
643 | ShowFooter();
|
---|
644 |
|
---|
645 | ?>
|
---|