1 | <?php
|
---|
2 |
|
---|
3 | include_once('ExportOutput.php');
|
---|
4 |
|
---|
5 | define('TAB_GENERAL', 0);
|
---|
6 | define('TAB_TRANSLATORS', 1);
|
---|
7 | define('TAB_GROUPS', 2);
|
---|
8 | define('TAB_LANGUAGES', 3);
|
---|
9 | define('TAB_OUTPUT_FORMAT', 4);
|
---|
10 | define('TAB_VERSION', 5);
|
---|
11 | define('TAB_STAT', 6);
|
---|
12 | define('TAB_OUTPUT', 7);
|
---|
13 |
|
---|
14 | class PageExport extends Page
|
---|
15 | {
|
---|
16 | function ExportList()
|
---|
17 | {
|
---|
18 | $Output = '<a href="?Action=ViewList">'.T('All').'</a>';
|
---|
19 | if($this->System->User->Licence(LICENCE_USER))
|
---|
20 | {
|
---|
21 | $Output .= ' <a href="?Action=ViewList&Filter=Others">'.T('Others').'</a>'.
|
---|
22 | ' <a href="?Action=ViewList&Filter=My">'.T('Mine').'</a>';
|
---|
23 | }
|
---|
24 |
|
---|
25 | if($this->System->User->Licence(LICENCE_USER))
|
---|
26 | $Output .= '<br/><div style="text-align: center;"><a href="?Action=Create">'.T('Create new export').'</a></div><br/>';
|
---|
27 |
|
---|
28 | $Filter = '';
|
---|
29 | if(array_key_exists('Filter', $_GET))
|
---|
30 | {
|
---|
31 | if($_GET['Filter'] == 'My') $Filter = ' WHERE `Export`.`User` = '.$this->System->User->Id;
|
---|
32 | if($_GET['Filter'] == 'Others') $Filter = ' WHERE `Export`.`User` != '.$this->System->User->Id;
|
---|
33 | }
|
---|
34 |
|
---|
35 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` '.$Filter);
|
---|
36 | $DbRow = $DbResult->fetch_row();
|
---|
37 | $PageList = GetPageList($DbRow[0]);
|
---|
38 |
|
---|
39 | $Output .= '<h3>'.T('List of export').'</h3>'.
|
---|
40 | $PageList['Output'];
|
---|
41 |
|
---|
42 | $TableColumns = array(
|
---|
43 | array('Name' => 'TimeCreate', 'Title' => T('Time made')),
|
---|
44 | array('Name' => 'UserName', 'Title' => T('Translator')),
|
---|
45 | array('Name' => 'Title', 'Title' => T('Name od export')),
|
---|
46 | // array('Name' => 'UserCount', 'Title' => 'Vybraných překladatelů'),
|
---|
47 | // array('Name' => 'GroupCount', 'Title' => 'Překladových skupin'),
|
---|
48 | array('Name' => 'OutputType', 'Title' => T('Type of output')),
|
---|
49 | array('Name' => 'ClientVersion', 'Title' => T('Client version')),
|
---|
50 | array('Name' => 'UsedCount', 'Title' => T('Viewed count')),
|
---|
51 | array('Name' => '', 'Title' => T('Action')),
|
---|
52 | );
|
---|
53 | $Order = GetOrderTableHeader($TableColumns, 'TimeCreate', 1);
|
---|
54 | $Output .= '<table class="BaseTable">'.
|
---|
55 | $Order['Output'];
|
---|
56 |
|
---|
57 | $DbResult = $this->System->Database->query('SELECT `User`.`Name` AS `UserName`, `Export`.`Id`, `Export`.`TimeCreate`, `Export`.`Title`, `Export`.`User`, `Export`.`UsedCount`, '.
|
---|
58 | '(SELECT Version FROM `ClientVersion` WHERE `ClientVersion`.`Id`=`Export`.`ClientVersion`) AS `ClientVersion`, '.
|
---|
59 | '(SELECT Id FROM `ClientVersion` WHERE `ClientVersion`.`Id`=`Export`.`ClientVersion`) AS `ClientVersionId`, '.
|
---|
60 | '(SELECT Name FROM `ExportOutputType` WHERE `ExportOutputType`.`Id`=`Export`.`OutputType`) AS `OutputType`, '.
|
---|
61 | '(SELECT COUNT(*) FROM `ExportGroup` WHERE `ExportGroup`.`Export`=`Export`.`Id`) AS `GroupCount`, '.
|
---|
62 | '(SELECT COUNT(*) FROM `ExportUser` WHERE `ExportUser`.`Export`=`Export`.`Id`) AS `UserCount` FROM `Export` '.
|
---|
63 | 'LEFT JOIN `User` ON `User`.`ID`=`Export`.`User` '.$Filter.$Order['SQL'].$PageList['SQLLimit']);
|
---|
64 | while($Export = $DbResult->fetch_assoc())
|
---|
65 | {
|
---|
66 | $Action = '<a href="?Action=View&ExportId='.$Export['Id'].'&Tab=0">'.T('View').'</a> '.
|
---|
67 | '<a href="?Action=View&ExportId='.$Export['Id'].'&Tab=7">'.T('Make export').'</a>';
|
---|
68 | if($Export['User'] == $this->System->User->Id) $Action .= ' <a href="?Action=Delete&ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy delete item?').'\');">'.T('Delete').'</a>';
|
---|
69 | if($this->System->User->Id != null) $Action .= ' <a href="?Action=Clone&ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a>';
|
---|
70 | $Output .= '<tr><td>'.HumanDate($Export['TimeCreate']).'</td>'.
|
---|
71 | '<td><a href="'.$this->System->Link('/user/?user='.$Export['User']).'">'.$Export['UserName'].'</a></td>'.
|
---|
72 | '<td>'.$Export['Title'].'</td>'.
|
---|
73 | '<td>'.$Export['OutputType'].'</td>'.
|
---|
74 | '<td><a href="'.$this->System->Link('/client-version/?action=item&id='.$Export['ClientVersionId']).'">'.$Export['ClientVersion'].'</a></td>'.
|
---|
75 | '<td>'.$Export['UsedCount'].'</td>'.
|
---|
76 | '<td>'.$Action.'</td></tr>';
|
---|
77 | }
|
---|
78 | $Output .= '</table>'.
|
---|
79 | $PageList['Output'];
|
---|
80 |
|
---|
81 | return($Output);
|
---|
82 | }
|
---|
83 |
|
---|
84 | function ExportCreate()
|
---|
85 | {
|
---|
86 | if($this->System->User->Licence(LICENCE_USER))
|
---|
87 | {
|
---|
88 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id);
|
---|
89 | $DbRow = $DbResult->fetch_row();
|
---|
90 | if($DbRow[0] < $this->System->Config['MaxExportPerUser'])
|
---|
91 | {
|
---|
92 | $Output = '<form action="?Action=CreateFinish" method="post">'.
|
---|
93 | '<fieldset><legend>'.T('Creation of new export').'</legend>'.
|
---|
94 | '<table><tr><td>'.T('Identification').':</td><td><input type="text" name="Title" /></td></tr>'.
|
---|
95 | '<tr><td>'.T('Description').':</td><td><textarea name="Description" cols="54" rows="10"></textarea></td></tr>'.
|
---|
96 | '<tr><td colspan="2"><input type="submit" value="'.T('Create').'" /></td></tr>'.
|
---|
97 | '</table></fieldset></form>';
|
---|
98 | } else $Output = ShowMessage(sprintf(T('You can\'t create another export. Max for one user is %d.'), $this->System->Config['MaxExportPerUser']), MESSAGE_CRITICAL);
|
---|
99 | } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
---|
100 | return($Output);
|
---|
101 | }
|
---|
102 |
|
---|
103 | function ExportCreateFinish()
|
---|
104 | {
|
---|
105 | if($this->System->User->Licence(LICENCE_USER))
|
---|
106 | {
|
---|
107 | if(array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
|
---|
108 | {
|
---|
109 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id);
|
---|
110 | $DbRow = $DbResult->fetch_row();
|
---|
111 | if($DbRow[0] < $this->System->Config['MaxExportPerUser'])
|
---|
112 | {
|
---|
113 | $this->System->Database->query('INSERT INTO `Export` (`Title`, `User`, `TimeCreate`, `WithDiacritic`, `Description`) VALUES ("'.$_POST['Title'].'", '.$this->System->User->Id.', NOW(), 1, "'.$_POST['Description'].'")');
|
---|
114 | $ExportId = $this->System->Database->insert_id;
|
---|
115 | $Output = ShowMessage(T('New export created.<br />Direct link to export').': <a href="?Action=View&ExportId='.$ExportId.'">'.T('here').'</a>');
|
---|
116 | $this->System->ModuleManager->Modules['Log']->WriteLog(T('New export created').' <a href="'.$this->System->Link('/export/?Action=View&ExportId='.$ExportId).'">'.$ExportId.'</a>.', LOG_TYPE_EXPORT);
|
---|
117 | $_GET['Filter'] = 'my';
|
---|
118 | $this->ExportList();
|
---|
119 | } else $Output = ShowMessage(sprintf(T('You can\'t create another export. Max for one user is %d.'),$this->System->Config['MaxExportPerUser']), MESSAGE_CRITICAL);
|
---|
120 | } else $Output = ShowMessage(T('Missing data in form.'), MESSAGE_CRITICAL);
|
---|
121 | } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
---|
122 | return($Output);
|
---|
123 | }
|
---|
124 |
|
---|
125 | function ExportDelete()
|
---|
126 | {
|
---|
127 | if($this->System->User->Licence(LICENCE_USER))
|
---|
128 | {
|
---|
129 | $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE (`Id`='.($_GET['ExportId'] * 1).') AND (`User`='.$this->System->User->Id.')');
|
---|
130 | if($DbResult->num_rows > 0)
|
---|
131 | {
|
---|
132 | $this->System->Database->query('DELETE FROM `ExportGroup` WHERE `Export`='.$_GET['ExportId']);
|
---|
133 | $this->System->Database->query('DELETE FROM `ExportGroupItem` WHERE `Export`='.$_GET['ExportId']);
|
---|
134 | $this->System->Database->query('DELETE FROM `ExportLanguage` WHERE `Export`='.$_GET['ExportId']);
|
---|
135 | $this->System->Database->query('DELETE FROM `ExportTask` WHERE `Export`='.$_GET['ExportId']);
|
---|
136 | $this->System->Database->query('DELETE FROM `ExportUser` WHERE `Export`='.$_GET['ExportId']);
|
---|
137 | $this->System->Database->query('DELETE FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
138 | DeleteDirectory('../tmp/Export/'.$_GET['ExportId'].'/');
|
---|
139 | $Output = ShowMessage(T('Export deleted.'));
|
---|
140 | $_GET['Filter'] = 'my';
|
---|
141 | $this->System->ModuleManager->Modules['Log']->WriteLog('Smazán export '.$_GET['ExportId'], LOG_TYPE_EXPORT);
|
---|
142 | $Output .= $this->ExportList();
|
---|
143 | } else $Output = ShowMessage(T('Export not found.'), MESSAGE_CRITICAL);
|
---|
144 | } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
---|
145 | return($Output);
|
---|
146 | }
|
---|
147 |
|
---|
148 | function SaveAllUsers()
|
---|
149 | {
|
---|
150 | global $System;
|
---|
151 | $Export = new Export($System);
|
---|
152 | $Export->Id = $_GET['ExportId'];
|
---|
153 | $Export->SaveAllUsers();
|
---|
154 |
|
---|
155 | }
|
---|
156 |
|
---|
157 | function ExportViewTranslators()
|
---|
158 | {
|
---|
159 | global $TranslationTree;
|
---|
160 |
|
---|
161 | $Output = '';
|
---|
162 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
---|
163 | $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
164 | $Export = $DbResult->fetch_assoc();
|
---|
165 | if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
|
---|
166 | else $Editable = false;
|
---|
167 |
|
---|
168 | if(array_key_exists('Operation', $_POST))
|
---|
169 | {
|
---|
170 | if($_POST['Operation'] == 'Save')
|
---|
171 | {
|
---|
172 | //print_r($_POST);
|
---|
173 | // Update user selection page
|
---|
174 | foreach($_POST as $Index => $Value)
|
---|
175 | {
|
---|
176 | if(substr($Index, 0, 3) == 'seq')
|
---|
177 | {
|
---|
178 | $UserId = substr($Index, 3) * 1;
|
---|
179 | if(array_key_exists('sel'.$UserId, $_POST)) $Selected = true;
|
---|
180 | else $Selected = false;
|
---|
181 | $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `User`='.$UserId;
|
---|
182 | $DbResult = $this->System->Database->query('SELECT * FROM `ExportUser` '.$Condition);
|
---|
183 | if($DbResult->num_rows > 0)
|
---|
184 | {
|
---|
185 | if(!$Selected) $this->System->Database->query('DELETE FROM `ExportUser` '.$Condition);
|
---|
186 | else $this->System->Database->query('UPDATE `ExportUser` SET `Sequence`='.$Value.$Condition);
|
---|
187 | } else
|
---|
188 | {
|
---|
189 | if($Selected) $this->System->Database->query('INSERT INTO `ExportUser` (`Export`, `User`, `Sequence`) VALUES ('.$_GET['ExportId'].', '.$UserId.', '.$Value.')');
|
---|
190 | }
|
---|
191 | }
|
---|
192 | }
|
---|
193 |
|
---|
194 | if (array_key_exists('AllUsers', $_POST)) {
|
---|
195 | //add allusers to export
|
---|
196 | $this->System->Database->query('UPDATE `Export` SET `AllUsers`=1 WHERE `Id`='.$_GET['ExportId']);
|
---|
197 |
|
---|
198 | //update export stat
|
---|
199 | $Export['AllUsers'] = 1;
|
---|
200 | $this->SaveAllUsers();
|
---|
201 | } else {
|
---|
202 | //update export stat
|
---|
203 | $Export['AllUsers'] = 0;
|
---|
204 | $this->System->Database->query('UPDATE `Export` SET `AllUsers`=0 WHERE `Id`='.$_GET['ExportId']);
|
---|
205 | }
|
---|
206 |
|
---|
207 | // Recalculate sequence number
|
---|
208 | $this->System->Database->query('SET @I = 0');
|
---|
209 | $this->System->Database->query('UPDATE `ExportUser` SET `Sequence` = (@I := @I + 1) WHERE `Export`='.$_GET['ExportId'].' ORDER BY `Sequence`;');
|
---|
210 | $Output .= ShowMessage(T('Select saved.'));
|
---|
211 | }
|
---|
212 | }
|
---|
213 |
|
---|
214 | $TableColumns = array(
|
---|
215 | array('Name' => 'Name', 'Title' => T('Name')),
|
---|
216 | array('Name' => 'TranslatedCount', 'Title' => T('Translated count')),
|
---|
217 | array('Name' => 'XP', 'Title' => T('Level')),
|
---|
218 | array('Name' => 'XP', 'Title' => T('Experience')),
|
---|
219 | array('Name' => '', 'Title' => T('Select')),
|
---|
220 | array('Name' => 'Sequence2', 'Title' => T('Order')),
|
---|
221 | );
|
---|
222 | $Order = GetOrderTableHeader($TableColumns, 'TranslatedCount', 1);
|
---|
223 | if($Order['Column'] != 'Sequence2') $InitialOrder = ', '.substr($Order['SQL'], 10);
|
---|
224 | else $InitialOrder = '';
|
---|
225 |
|
---|
226 | $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';
|
---|
227 | $Query .=' LEFT JOIN `ExportUser` ON `ExportUser`.`Export` = '.$_GET['ExportId'].' AND `ExportUser`.`User`=`T`.`ID`';
|
---|
228 | $Query .=' WHERE `T`.`TranslatedCount` > 0 ORDER BY COALESCE(`ExportUser`.`Sequence`, 100000000)'.$InitialOrder.') AS `TT`';
|
---|
229 |
|
---|
230 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `X`');
|
---|
231 | $DbRow = $DbResult->fetch_row();
|
---|
232 | $PageList = GetPageList($DbRow[0]);
|
---|
233 |
|
---|
234 | $Output .= '<form name="Translators" action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'.
|
---|
235 | '<h3>'.T('Translators').'</h3>';
|
---|
236 | if($Editable)
|
---|
237 | {
|
---|
238 | $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
|
---|
239 | '<input type="hidden" name="Operation" value="Save"/><br />'.
|
---|
240 | ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' '.T('Select all on page').'</span> <br />'.
|
---|
241 | ' <span>'.CheckBox('AllUsers', $Export['AllUsers']).' '.T('Export allways from all users').'</span> '.
|
---|
242 | '<br />'.
|
---|
243 | T('Select users from list which you want to export from. And edit their order.').'<br />'.
|
---|
244 | T('Order is done by numeric value which is can be edit to desirable order. Lines with same number will be renumbered in ascending order.');
|
---|
245 | }
|
---|
246 |
|
---|
247 | $Output .= $PageList['Output'].
|
---|
248 | '<table class="BaseTable">'.
|
---|
249 | $Order['Output'];
|
---|
250 |
|
---|
251 | $Query = 'SELECT * FROM ('.$Query.') AS `TX` '.$Order['SQL'].$PageList['SQLLimit'];
|
---|
252 | $this->System->Database->query('SET @I = 0');
|
---|
253 | $DbResult = $this->System->Database->query($Query);
|
---|
254 | while($UserLine = $DbResult->fetch_assoc())
|
---|
255 | {
|
---|
256 | $XP = GetLevelMinMax($UserLine['XP']);
|
---|
257 | $Checked = $UserLine['Sequence'] != '';
|
---|
258 | $Selection = CheckBox('sel'.$UserLine['ID'], $Checked, '', 'CheckBox', ((!$Editable) or ($Export['AllUsers'])));
|
---|
259 | $Sequence = '<input type="text" name="seq'.$UserLine['ID'].'" style="text-align: center; width: 40px;" value="'.$UserLine['Sequence2'].'"'.$DisabledInput[$Editable].'/>';
|
---|
260 | $Output .= '<tr>'.
|
---|
261 | '<td><a href="'.$this->System->Link('/TranslationList.php?user='.$UserLine['ID'].'&state=2&group=0').'" title="Zobrazit všechny jeho přeložené texty">'.$UserLine['Name'].'</a></td>'.
|
---|
262 | '<td>'.$UserLine['TranslatedCount'].'</td>'.
|
---|
263 | '<td>'.$XP['Level'].'</td>'.
|
---|
264 | '<td>'.ProgressBar(150, round($XP['XP'] / $XP['MaxXP'] * 100, 2), $XP['XP'].' / '.$XP['MaxXP']).'</td>'.
|
---|
265 | '<td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>';
|
---|
266 | }
|
---|
267 | $Output .= '</table>'.
|
---|
268 | '</form>'.
|
---|
269 | $PageList['Output'];
|
---|
270 | return($Output);
|
---|
271 | }
|
---|
272 |
|
---|
273 | function ExportViewGeneral()
|
---|
274 | {
|
---|
275 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
---|
276 | $DisabledTextArea = array(false => ' readonly="yes"', true => '');
|
---|
277 | $Output = '<h3>Obecná nastavení</h3>';
|
---|
278 | $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
279 | $Export = $DbRows->fetch_assoc();
|
---|
280 | if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
|
---|
281 | else $Editable = false;
|
---|
282 |
|
---|
283 | if(array_key_exists('Operation', $_POST))
|
---|
284 | if($_POST['Operation'] == 'Save') if($Editable and array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
|
---|
285 | {
|
---|
286 | if(array_key_exists('WithDiacritic', $_POST)) $WithDiacritic = 1;
|
---|
287 | else $WithDiacritic = 0;
|
---|
288 | if (array_key_exists('Featured', $_POST)) $Export['Featured'] = 1;
|
---|
289 | $this->System->Database->query('UPDATE `Export` SET `Title`="'.$_POST['Title'].
|
---|
290 | '", `Featured`='.$Export['Featured'].', `Description`="'.$_POST['Description'].
|
---|
291 | '", `WithDiacritic`='.$WithDiacritic.' WHERE `Id`='.$Export['Id']);
|
---|
292 | $Export['Title'] = $_POST['Title'];
|
---|
293 | $Export['Description'] = $_POST['Description'];
|
---|
294 | $Export['WithDiacritic'] = $WithDiacritic;
|
---|
295 | $Output .= ShowMessage('Nastavení uloženo.');
|
---|
296 | }
|
---|
297 |
|
---|
298 | if($Export['WithDiacritic'] == 1) $WithDiacritic = ' checked="checked"';
|
---|
299 | else $WithDiacritic = '';
|
---|
300 | $Output .= '<form action="?Action=View&Tab=0&ExportId='.$Export['Id'].'" method="post">'.
|
---|
301 | '<table>';
|
---|
302 | if($this->System->User->Id != null)
|
---|
303 | {
|
---|
304 | $Output .= '<input type="hidden" name="Operation" value="Save"/>'.
|
---|
305 | '<tr><td colspan="2">';
|
---|
306 | if($Editable) $Output .= ' <input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/>';
|
---|
307 | $Output .= ' <a href="?Action=Clone&ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a> ';
|
---|
308 | if($this->System->User->Licence(LICENCE_ADMIN))
|
---|
309 | $Output .= CheckBox('Featured', $Export['Featured'], '', 'CheckBox', !$Editable). ' '.T('Recommended').' ';
|
---|
310 | $Output .= '</td></tr>';
|
---|
311 | }
|
---|
312 | $Output .= '<tr><td>'.T('Identification').':</td><td><input type="text" style="width: 400px" name="Title" value="'.$Export['Title'].'"'.$DisabledInput[$Editable].'/></td></tr>'.
|
---|
313 | '<tr><td>Popis:</td><td><textarea name="Description" cols="54" rows="10"'.$DisabledTextArea[$Editable].'>'.$Export['Description'].'</textarea></td></tr>'.
|
---|
314 | '<tr><td>'.T('With diacritics').'</td><td><input type="checkbox" name="WithDiacritic" '.$WithDiacritic.''.$DisabledInput[$Editable].'/></td></tr>'.
|
---|
315 | '</table></form>';
|
---|
316 | return($Output);
|
---|
317 | }
|
---|
318 |
|
---|
319 | function ExportViewLanguages()
|
---|
320 | {
|
---|
321 | global $TranslationTree;
|
---|
322 |
|
---|
323 | $Output = '';
|
---|
324 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
---|
325 | $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
326 | $Export = $DbRows->fetch_assoc();
|
---|
327 | if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
|
---|
328 | else $Editable = false;
|
---|
329 |
|
---|
330 | if(array_key_exists('Operation', $_POST))
|
---|
331 | {
|
---|
332 | if($_POST['Operation'] == 'Save')
|
---|
333 | {
|
---|
334 | //print_r($_POST);
|
---|
335 | // Update user selection page
|
---|
336 | foreach($_POST as $Index => $Value)
|
---|
337 | {
|
---|
338 | if(substr($Index, 0, 3) == 'seq')
|
---|
339 | {
|
---|
340 | $LanguageId = substr($Index, 3) * 1;
|
---|
341 | if(array_key_exists('sel'.$LanguageId, $_POST)) $Selected = true;
|
---|
342 | else $Selected = false;
|
---|
343 | $Condition = ' WHERE Export='.$_GET['ExportId'].' AND `Language`='.$LanguageId;
|
---|
344 | $DbResult = $this->System->Database->query('SELECT * FROM `ExportLanguage` '.$Condition);
|
---|
345 | if($DbResult->num_rows > 0)
|
---|
346 | {
|
---|
347 | if(!$Selected) $this->System->Database->query('DELETE FROM `ExportLanguage` '.$Condition);
|
---|
348 | else $this->System->Database->query('UPDATE `ExportLanguage` SET `Sequence`='.$Value.$Condition);
|
---|
349 | } else
|
---|
350 | {
|
---|
351 | if($Selected) $this->System->Database->query('INSERT INTO `ExportLanguage` (`Export`, `Language`, `Sequence`) VALUES ('.$_GET['ExportId'].', '.$LanguageId.', '.$Value.')');
|
---|
352 | }
|
---|
353 | }
|
---|
354 | }
|
---|
355 |
|
---|
356 | // Recalculate sequence number
|
---|
357 | $this->System->Database->query('SET @I = 0');
|
---|
358 | $this->System->Database->query('UPDATE `ExportLanguage` SET `Sequence` = (@I := @I + 1) WHERE `Export`='.$_GET['ExportId'].' ORDER BY `Sequence`;');
|
---|
359 | $Output .= ShowMessage('Výběr uložen.');
|
---|
360 | }
|
---|
361 | }
|
---|
362 |
|
---|
363 | $Query = 'SELECT (@I := @I + 1) AS `Sequence2`, `Sequence`, `Language`.`Id`, `Name` FROM `Language`';
|
---|
364 | $Query .=' LEFT JOIN `ExportLanguage` ON `ExportLanguage`.`Export` = '.$_GET['ExportId'].' AND `ExportLanguage`.`Language`=`Language`.`Id`';
|
---|
365 | $Query .=' WHERE `Language`.`Enabled` = 1 ORDER BY COALESCE(`Sequence`, 100)';
|
---|
366 |
|
---|
367 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS X');
|
---|
368 | $DbRow = $DbResult->fetch_row();
|
---|
369 | $PageList = GetPageList($DbRow[0]);
|
---|
370 |
|
---|
371 | $TableColumns = array(
|
---|
372 | array('Name' => 'Name', 'Title' => T('Name')),
|
---|
373 | array('Name' => '', 'Title' => T('Select')),
|
---|
374 | array('Name' => 'Sequence2', 'Title' => T('Order')),
|
---|
375 | );
|
---|
376 | $Order = GetOrderTableHeader($TableColumns, 'Sequence2');
|
---|
377 | $Output .= '<form action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'.
|
---|
378 | '<h3>'.T('Languages').'</h3>';
|
---|
379 | if($Editable)
|
---|
380 | {
|
---|
381 | $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
|
---|
382 | '<input type="hidden" name="Operation" value="Save"/>'.
|
---|
383 | '<br />'.
|
---|
384 | T('Select languades from list witch you want to export from. And edit theirs order.').'<br />'.
|
---|
385 | T('Order is done by numeric value which is can be edit to desirable order. Lines with same number will be renumbered in ascending order.');
|
---|
386 | }
|
---|
387 |
|
---|
388 | $Output .= $PageList['Output'].
|
---|
389 | '<table class="BaseTable">'.
|
---|
390 | $Order['Output'];
|
---|
391 |
|
---|
392 | $Query = 'SELECT * FROM ('.$Query.') AS TX '.$Order['SQL'].$PageList['SQLLimit'];
|
---|
393 | $this->System->Database->query('SET @I = 0');
|
---|
394 | $DbResult = $this->System->Database->query($Query);
|
---|
395 | while($Langugage = $DbResult->fetch_assoc())
|
---|
396 | {
|
---|
397 | $Checked = $Langugage['Sequence'] != '';
|
---|
398 | $Selection = CheckBox('sel'.$Langugage['Id'], $Checked, '', 'CheckBox', !$Editable);
|
---|
399 | $Sequence = '<input type="text" name="seq'.$Langugage['Id'].'" style="text-align: center; width: 40px;" value="'.$Langugage['Sequence2'].'"'.$DisabledInput[$Editable].'/>';
|
---|
400 | $Output .= '<tr>
|
---|
401 | <td>'.T($Langugage['Name']).'</td>
|
---|
402 | <td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>';
|
---|
403 | }
|
---|
404 | $Output .= '</table>'.
|
---|
405 | '</form>'.
|
---|
406 | $PageList['Output'];
|
---|
407 | return($Output);
|
---|
408 | }
|
---|
409 |
|
---|
410 | function ExportViewGroups()
|
---|
411 | {
|
---|
412 | global $TranslationTree;
|
---|
413 |
|
---|
414 | $Output = '';
|
---|
415 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
---|
416 | $DbRows = $this->System->Database->query('SELECT * FROM Export WHERE Id='.$_GET['ExportId']);
|
---|
417 | $Export = $DbRows->fetch_assoc();
|
---|
418 | if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
|
---|
419 | else $Editable = false;
|
---|
420 |
|
---|
421 | if(array_key_exists('Operation', $_POST))
|
---|
422 | {
|
---|
423 | if($_POST['Operation'] == 'Save')
|
---|
424 | {
|
---|
425 | //print_r($_POST);
|
---|
426 | // Update user selection page
|
---|
427 | foreach($_POST as $Index => $Value)
|
---|
428 | {
|
---|
429 | if(substr($Index, 0, 3) == 'seq')
|
---|
430 | {
|
---|
431 | $GroupId = substr($Index, 3) * 1;
|
---|
432 | if(array_key_exists('sel'.$GroupId, $_POST)) $Selected = true;
|
---|
433 | else $Selected = false;
|
---|
434 | $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `Group`='.$GroupId;
|
---|
435 | $DbResult = $this->System->Database->query('SELECT * FROM `ExportGroup` '.$Condition);
|
---|
436 | if($DbResult->num_rows > 0)
|
---|
437 | {
|
---|
438 | if(!$Selected) $this->System->Database->query('DELETE FROM `ExportGroup` '.$Condition);
|
---|
439 | } else
|
---|
440 | {
|
---|
441 | if($Selected) $this->System->Database->query('INSERT INTO `ExportGroup` (`Export`, `Group`) VALUES ('.$_GET['ExportId'].', '.$GroupId.')');
|
---|
442 | }
|
---|
443 | }
|
---|
444 | }
|
---|
445 | $Output .= ShowMessage(T('Select saved.'));
|
---|
446 | }
|
---|
447 | //items
|
---|
448 | foreach($TranslationTree as $Group)
|
---|
449 | {
|
---|
450 | foreach($TranslationTree[$Group['Id']]['Items'] as $Column) {
|
---|
451 | if(array_key_exists('item'.$Column['Id'], $_POST)) $Selected = true;
|
---|
452 | else $Selected = false;
|
---|
453 | //we will save only forbitten collums and need to be visible
|
---|
454 | $Selected = !$Selected;
|
---|
455 | if (!$Column['Visible']) $Selected = false;
|
---|
456 |
|
---|
457 | $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `GroupItem`='.$Column['Id'];
|
---|
458 | $DbResult = $this->System->Database->query('SELECT * FROM `ExportGroupItem` '.$Condition);
|
---|
459 | if($DbResult->num_rows > 0)
|
---|
460 | {
|
---|
461 | if(!$Selected) $this->System->Database->query('DELETE FROM `ExportGroupItem` '.$Condition);
|
---|
462 | } else
|
---|
463 | {
|
---|
464 | if($Selected) $this->System->Database->query('INSERT INTO `ExportGroupItem` (`Export`, `GroupItem`) VALUES ('.$_GET['ExportId'].', '.$Column['Id'].')');
|
---|
465 | }
|
---|
466 |
|
---|
467 | }
|
---|
468 | }
|
---|
469 | }
|
---|
470 |
|
---|
471 | $Query = 'SELECT `Group`.*, `ExportGroup`.`Id` AS `ExportGroupId` FROM `Group` LEFT JOIN `ExportGroup` ON `ExportGroup`.`Export`='.$_GET['ExportId'].' AND `Group`=`Group`.`Id`';
|
---|
472 |
|
---|
473 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS X');
|
---|
474 | $DbRow = $DbResult->fetch_row();
|
---|
475 | $PageList = GetPageList($DbRow[0]);
|
---|
476 |
|
---|
477 | $TableColumns = array(
|
---|
478 | array('Name' => '', 'Title' => T('Select')),
|
---|
479 | array('Name' => 'Name', 'Title' => T('Name')),
|
---|
480 | array('Name' => 'MangosTable', 'Title' => 'Mangos/DBC/Lua'),
|
---|
481 | // array('Name' => 'DBCFileName', 'Title' => 'DBC soubor'),
|
---|
482 | // array('Name' => 'LuaFileName', 'Title' => 'Lua soubor'),
|
---|
483 | array('Name' => '', 'Title' => T('Items of tranlation')),
|
---|
484 | );
|
---|
485 | $Order = GetOrderTableHeader($TableColumns, 'Name');
|
---|
486 | $Output .= '<form action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'.
|
---|
487 | '<h3>'.T('Translation groups').'</h3>';
|
---|
488 | if($Editable)
|
---|
489 | {
|
---|
490 | $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
|
---|
491 | '<input type="hidden" name="Operation" value="Save"/>'.
|
---|
492 | ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' '.T('Select all').'</span> '.
|
---|
493 | '<br />'.
|
---|
494 | T('Select translation groups witch you want to export.').'<br />';
|
---|
495 | }
|
---|
496 |
|
---|
497 | $Output .= $PageList['Output'].
|
---|
498 | '<table class="BaseTable">'.
|
---|
499 | $Order['Output'];
|
---|
500 |
|
---|
501 | $DbResultItem = $this->System->Database->query('SELECT * FROM `ExportGroupItem` WHERE `Export`='.$_GET['ExportId']);
|
---|
502 | while($GroupItem = $DbResultItem->fetch_assoc())
|
---|
503 | {
|
---|
504 | $GroupItems[$GroupItem['GroupItem']] = 1;
|
---|
505 | }
|
---|
506 |
|
---|
507 | $Query = 'SELECT * FROM ('.$Query.') AS TX '.$Order['SQL'].$PageList['SQLLimit'];
|
---|
508 | $DbResult = $this->System->Database->query($Query);
|
---|
509 | while($Group = $DbResult->fetch_assoc())
|
---|
510 | {
|
---|
511 | $Columns = '';
|
---|
512 | foreach($TranslationTree[$Group['Id']]['Items'] as $Column) {
|
---|
513 | if ($Column['Visible']) $Columns .= CheckBox('item'.$Column['Id'], !isset($GroupItems[$Column['Id']]), '', 'CheckBox', !$Editable).' '.$Column['Name'].' <br />';
|
---|
514 | }
|
---|
515 | $Checked = $Group['ExportGroupId'] != '';
|
---|
516 | $Selection = CheckBox('sel'.$Group['Id'], $Checked, '', 'CheckBox', !$Editable);
|
---|
517 | $Output .= '<tr>'.
|
---|
518 | '<td>'.$Selection.'<input type="hidden" name="seq'.$Group['Id'].'"/></td>'.
|
---|
519 | '<td>'.T($Group['Name']).'</td><td>';
|
---|
520 | if ($Group['MangosTable'] <> '')
|
---|
521 | $Output .= $Group['MangosTable'].'.sql ';
|
---|
522 | if ($Group['LuaFileName'] <> '')
|
---|
523 | $Output .= $Group['LuaFileName'].'.lua ';
|
---|
524 | if ($Group['DBCFileName'] <> '')
|
---|
525 | $Output .= $Group['DBCFileName'].'.dbc ';
|
---|
526 |
|
---|
527 | $Output .= '</td><td>';
|
---|
528 | $Output .= $Columns. '</td>';
|
---|
529 | $Output .= '</tr>';
|
---|
530 | }
|
---|
531 | $Output .= '</table>'.
|
---|
532 | '</form>'.
|
---|
533 | $PageList['Output'];
|
---|
534 | return($Output);
|
---|
535 | }
|
---|
536 |
|
---|
537 | function ExportViewOutputFormat()
|
---|
538 | {
|
---|
539 | $Output = '';
|
---|
540 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
---|
541 | if(array_key_exists('ExportId', $_GET))
|
---|
542 | {
|
---|
543 | $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
544 | if($DbRows->num_rows > 0)
|
---|
545 | {
|
---|
546 | $Export = $DbRows->fetch_assoc();
|
---|
547 | if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
|
---|
548 | else $Editable = false;
|
---|
549 |
|
---|
550 | if(array_key_exists('Operation', $_POST))
|
---|
551 | if($_POST['Operation'] == 'Save')
|
---|
552 | {
|
---|
553 | if(array_key_exists('OutputType', $_POST) and ($_POST['OutputType'] * 1 > 0))
|
---|
554 | {
|
---|
555 | $this->System->Database->query('UPDATE Export SET OutputType='.$_POST['OutputType'].' WHERE Id='.$_GET['ExportId']);
|
---|
556 | $Output .= ShowMessage(T('Select saved.'));
|
---|
557 | } else $Output .= ShowMessage(T('Format wasn\'t selected'), MESSAGE_CRITICAL);
|
---|
558 | }
|
---|
559 |
|
---|
560 | $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
561 | $Export = $DbResult->fetch_assoc();
|
---|
562 |
|
---|
563 | $Output .= '<h3>'.T('Format the generated output').'</h3>'.
|
---|
564 | '<form action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">';
|
---|
565 | if($Editable)
|
---|
566 | {
|
---|
567 | $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
|
---|
568 | '<input type="hidden" name="Operation" value="Save"/>'.
|
---|
569 | '<br />';
|
---|
570 | }
|
---|
571 | $DbResult = $this->System->Database->query('SELECT * FROM `ExportOutputType` ORDER BY `Name`');
|
---|
572 | while($ExportFormat = $DbResult->fetch_assoc())
|
---|
573 | {
|
---|
574 | $Output .= RadioButton('OutputType', $ExportFormat['Id'], $Export['OutputType'] == $ExportFormat['Id'], '', !$Editable).' '.$ExportFormat['Name'].'<br/>';
|
---|
575 | }
|
---|
576 | $Output .= '</form>';
|
---|
577 | } else $Output .= ShowMessage(T('Item not found'), MESSAGE_CRITICAL);
|
---|
578 | } else $Output .= ShowMessage(T('Is isn\'t select'), MESSAGE_CRITICAL);
|
---|
579 | return($Output);
|
---|
580 | }
|
---|
581 |
|
---|
582 | function ExportViewVersion()
|
---|
583 | {
|
---|
584 | $Output = '';
|
---|
585 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
---|
586 | $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
587 | $Export = $DbRows->fetch_assoc();
|
---|
588 | if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
|
---|
589 | else $Editable = false;
|
---|
590 |
|
---|
591 | if(array_key_exists('Operation', $_POST))
|
---|
592 | if(($_POST['Operation'] == 'Save') and (array_key_exists('ClientVersion', $_POST)))
|
---|
593 | {
|
---|
594 | $this->System->Database->query('UPDATE `Export` SET `ClientVersion`='.$_POST['ClientVersion'].' WHERE `Id`='.$_GET['ExportId']);
|
---|
595 | $Output .= ShowMessage(T('Select saved.'));
|
---|
596 | }
|
---|
597 |
|
---|
598 | $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
599 | $Export = $DbResult->fetch_assoc();
|
---|
600 |
|
---|
601 | if($Export['OutputType'] == '') $Output .= ShowMessage('Nevybrán typ exportu', MESSAGE_CRITICAL);
|
---|
602 | else {
|
---|
603 | $Query = 'SELECT `ClientVersion`.* FROM `ExportVersion` '.
|
---|
604 | 'LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id`=`ExportVersion`.`ClientVersion` WHERE `ExportType`='.$Export['OutputType'];
|
---|
605 |
|
---|
606 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `X`');
|
---|
607 | $DbRow = $DbResult->fetch_row();
|
---|
608 | $PageList = GetPageList($DbRow[0]);
|
---|
609 |
|
---|
610 | $TableColumns = array(
|
---|
611 | array('Name' => 'Version', 'Title' => T('Version')),
|
---|
612 | array('Name' => 'BuildNumber', 'Title' => T('Build')),
|
---|
613 | array('Name' => 'ReleaseDate', 'Title' => T('Release date')),
|
---|
614 | array('Name' => 'Title', 'Title' => T('Name2')),
|
---|
615 | array('Name' => '', 'Title' => T('Select')),
|
---|
616 | );
|
---|
617 | $Order = GetOrderTableHeader($TableColumns, 'BuildNumber', 1);
|
---|
618 | $Output .= '<form action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'.
|
---|
619 | '<h3>'.T('Client version').'</h3>';
|
---|
620 |
|
---|
621 | if($Editable)
|
---|
622 | {
|
---|
623 | $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
|
---|
624 | '<input type="hidden" name="Operation" value="Save"/>'.
|
---|
625 | '<br />'.
|
---|
626 | T('Select version of game client witch you want to export.').'<br />';
|
---|
627 | }
|
---|
628 | $Output .= $PageList['Output'].
|
---|
629 | '<table class="BaseTable">'.
|
---|
630 | $Order['Output'];
|
---|
631 |
|
---|
632 | $Query = 'SELECT * FROM ('.$Query.') AS `TX` '.$Order['SQL'].$PageList['SQLLimit'];
|
---|
633 | $DbResult = $this->System->Database->query($Query);
|
---|
634 | while($Version = $DbResult->fetch_assoc())
|
---|
635 | {
|
---|
636 | $Output .= '<tr><td><a href="'.$this->System->Link('/client-version/?action=item&id='.$Version['Id']).'">'.
|
---|
637 | $Version['Version'].'</a></td><td>'.$Version['BuildNumber'].'</td><td>'.
|
---|
638 | HumanDate($Version['ReleaseDate']).'</td><td>'.$Version['Title'].'</td><td>'.
|
---|
639 | RadioButton('ClientVersion', $Version['Id'], $Export['ClientVersion'] == $Version['Id'], '', !$Editable
|
---|
640 | ).'</td></tr>';
|
---|
641 |
|
---|
642 | }
|
---|
643 | $Output .= '</table>'.
|
---|
644 | '</form>'.
|
---|
645 | $PageList['Output'];
|
---|
646 | }
|
---|
647 | return($Output);
|
---|
648 | }
|
---|
649 |
|
---|
650 | function ExportViewOutput()
|
---|
651 | {
|
---|
652 | $Output = '';
|
---|
653 | $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
654 | $Export = $DbResult->fetch_assoc();
|
---|
655 | if($Export['OutputType'] == '') $Output .= ShowMessage('Nevybrán typ exportu', MESSAGE_CRITICAL);
|
---|
656 | else if($Export['ClientVersion'] == '') $Output .= ShowMessage(T('Export don\'t have selected version of client'), MESSAGE_CRITICAL);
|
---|
657 | else {
|
---|
658 | $DbResult = $this->System->Database->query('SELECT * FROM `ExportOutputType` WHERE `Id`='.$Export['OutputType']);
|
---|
659 | if($DbResult->num_rows > 0)
|
---|
660 | {
|
---|
661 | $DbResult = $this->System->Database->query('SELECT * FROM `ExportVersion` WHERE (`ExportType`='.$Export['OutputType'].') AND (`ClientVersion`='.$Export['ClientVersion'].')');
|
---|
662 | if($DbResult->num_rows > 0)
|
---|
663 | {
|
---|
664 | if (array_key_exists('Auto', $_GET) == false)
|
---|
665 | $this->System->Database->query('UPDATE `Export` SET `UsedCount` = `UsedCount` + 1 WHERE `Id`='.$Export['Id']);
|
---|
666 | $Output = ExportOutput($Export['Id'], $Export['OutputType']);
|
---|
667 | } else $Output = ShowMessage(T('Export don\'t have selected version of client'), MESSAGE_CRITICAL);
|
---|
668 | } else $Output = ShowMessage(T('Format output isn\'t select').'.', MESSAGE_CRITICAL);
|
---|
669 | }
|
---|
670 | return($Output);
|
---|
671 | }
|
---|
672 |
|
---|
673 | function ExportViewStat($Where = '')
|
---|
674 | {
|
---|
675 | $Export = new Export($this->System);
|
---|
676 | $Export->Id = $_GET['ExportId'];
|
---|
677 | $Export->Init();
|
---|
678 | $Export->LoadFilters();
|
---|
679 |
|
---|
680 | if(($Export->Export['ClientVersion'] == '') or ($Export->ClientVersion['BuildNumber'] == ''))
|
---|
681 | $Output = ShowMessage(T('Export don\'t have selected version of client'), MESSAGE_CRITICAL);
|
---|
682 | else {
|
---|
683 | $GroupListQuery = 'SELECT `Group`.* FROM `Group` '.
|
---|
684 | ' JOIN `ExportGroup` ON (`ExportGroup`.`Export`='.$Export->Id.') AND (`ExportGroup`.`Group`=`Group`.`Id`)';
|
---|
685 | $Query = '';
|
---|
686 | $UnionItems = array();
|
---|
687 | $DbResult = $this->System->Database->query($GroupListQuery.$Where);
|
---|
688 | while($DbRow = $DbResult->fetch_assoc())
|
---|
689 | {
|
---|
690 | $UnionItems[] = 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
|
---|
691 | ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'.
|
---|
692 | ' JOIN `ExportUser` ON (`ExportUser`.`User`=`T`.`User`) AND (`ExportUser`.`Export`='.$Export->Id.') '.
|
---|
693 | ' JOIN `ExportLanguage` ON (`ExportLanguage`.`Export`='.$Export->Id.')'.
|
---|
694 | ' WHERE (`Complete` = 1) AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
|
---|
695 | ') AS `C1`) AS `Translated`, '.
|
---|
696 | '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
|
---|
697 | ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'.
|
---|
698 | ' WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].') AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
|
---|
699 | ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name`';
|
---|
700 | }
|
---|
701 | $Query = substr($Query, 0, - 6);
|
---|
702 |
|
---|
703 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$GroupListQuery.') AS `T`');
|
---|
704 | $DbRow = $DbResult->fetch_row();
|
---|
705 | $PageList = GetPageList($DbRow[0]);
|
---|
706 | $Output = '<h3>'.T('Statistic of coplection selected groups').'</h3>'.
|
---|
707 | $PageList['Output'];
|
---|
708 |
|
---|
709 | $Output .= '<table class="BaseTable">';
|
---|
710 | $TableColumns = array(
|
---|
711 | array('Name' => 'Name', 'Title' => T('Name')),
|
---|
712 | array('Name' => 'Translated', 'Title' => T('Translated count')),
|
---|
713 | array('Name' => 'Total', 'Title' => T('English')),
|
---|
714 | array('Name' => 'Percent', 'Title' => T('Percent')),
|
---|
715 | );
|
---|
716 |
|
---|
717 | $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
|
---|
718 | $Output .= $Order['Output'];
|
---|
719 |
|
---|
720 | $Translated = 0;
|
---|
721 | $Total = 0;
|
---|
722 | if(count($UnionItems) > 0)
|
---|
723 | {
|
---|
724 | $ID = $this->System->Database->query('SELECT *, ROUND(`Translated` / `Total` * 100, 2) AS `Percent` FROM ('.implode(' UNION ALL ', $UnionItems).') AS `C3` '.$Order['SQL'].$PageList['SQLLimit']);
|
---|
725 | while($Group = $ID->fetch_assoc())
|
---|
726 | {
|
---|
727 | $Output .= '<tr><td>'.T($Group['Name']).'</td><td>'.$Group['Translated'].'</td><td>'.$Group['Total'].'</td><td>'.ProgressBar(150, $Group['Percent']).'</td></tr>';
|
---|
728 | $Translated += $Group['Translated'];
|
---|
729 | $Total += $Group['Total'];
|
---|
730 | }
|
---|
731 | }
|
---|
732 | if($Total > 0) $Percent = $Translated / $Total * 100;
|
---|
733 | else $Percent = 100;
|
---|
734 |
|
---|
735 | $Output .= '<tr><td><strong>'.T('Altogether').'</strong></td><td><strong>'.$Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.ProgressBar(150, round($Percent, 2)).'</strong></td></tr>';
|
---|
736 | $Output .= '</table>';
|
---|
737 | }
|
---|
738 | return($Output);
|
---|
739 | }
|
---|
740 |
|
---|
741 | function ExportView()
|
---|
742 | {
|
---|
743 | $Output = '';
|
---|
744 | if(array_key_exists('ExportId', $_GET) and is_numeric($_GET['ExportId']))
|
---|
745 | {
|
---|
746 | $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
747 | if($DbResult->num_rows > 0)
|
---|
748 | {
|
---|
749 | $Export = $DbResult->fetch_assoc();
|
---|
750 |
|
---|
751 | $DbResult = $this->System->Database->query('SELECT * FROM `User` WHERE `ID`='.$Export['User']);
|
---|
752 | $UserLine = $DbResult->fetch_assoc();
|
---|
753 | $Output .= '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>';
|
---|
754 | $Output .= ShowTabs(array(T('General'), T('Translators'), T('Translations'), T('Languages'), T('Format'), T('Version'), T('Statistic'), T('Output')));
|
---|
755 | $Output .= '<div id="content">';
|
---|
756 | if($_SESSION['Tab'] == TAB_GENERAL) $Output .= $this->ExportViewGeneral();
|
---|
757 | else if($_SESSION['Tab'] == TAB_TRANSLATORS) $Output .= $this->ExportViewTranslators();
|
---|
758 | else if($_SESSION['Tab'] == TAB_GROUPS) $Output .= $this->ExportViewGroups();
|
---|
759 | else if($_SESSION['Tab'] == TAB_LANGUAGES) $Output .= $this->ExportViewLanguages();
|
---|
760 | else if($_SESSION['Tab'] == TAB_OUTPUT_FORMAT) $Output .= $this->ExportViewOutputFormat();
|
---|
761 | else if($_SESSION['Tab'] == TAB_VERSION) $Output .= $this->ExportViewVersion();
|
---|
762 | else if($_SESSION['Tab'] == TAB_STAT) $Output .= $this->ExportViewStat();
|
---|
763 | else if($_SESSION['Tab'] == TAB_OUTPUT) $Output .= $this->ExportViewOutput();
|
---|
764 | else $Output .= $this->ExportViewGeneral();
|
---|
765 |
|
---|
766 | $Output .= '</div>';
|
---|
767 | } else $Output .= ShowMessage(T('Export not found.'), MESSAGE_CRITICAL);
|
---|
768 | } else $Output .= ShowMessage(T('Is isn\'t select'), MESSAGE_CRITICAL);
|
---|
769 | return($Output);
|
---|
770 | }
|
---|
771 |
|
---|
772 | function ExportClone()
|
---|
773 | {
|
---|
774 | if($this->System->User->Licence(LICENCE_USER))
|
---|
775 | {
|
---|
776 | if(array_key_exists('ExportId', $_GET) and is_numeric($_GET['ExportId']))
|
---|
777 | {
|
---|
778 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id);
|
---|
779 | $DbRow = $DbResult->fetch_row();
|
---|
780 | if($DbRow[0] < $this->System->Config['MaxExportPerUser'])
|
---|
781 | {
|
---|
782 | $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
---|
783 | if($DbResult->num_rows > 0)
|
---|
784 | {
|
---|
785 | $DbRow = $DbResult->fetch_assoc();
|
---|
786 | unset($DbRow['Id']);
|
---|
787 | $DbRow['UsedCount'] = '0';
|
---|
788 | $DbRow['User'] = $this->System->User->Id;
|
---|
789 | $DbRow['TimeCreate'] = 'NOW()';
|
---|
790 | $DbRow['Title'] .= ' - '.T('clone');
|
---|
791 | $DbRow['Featured'] = 0;
|
---|
792 | $this->System->Database->insert('Export', $DbRow);
|
---|
793 | $ExportId = $this->System->Database->insert_id;
|
---|
794 | $this->System->Database->query('INSERT INTO `ExportGroup` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `Group` FROM `ExportGroup` WHERE `Export`='.$_GET['ExportId'].')');
|
---|
795 | $this->System->Database->query('INSERT INTO `ExportGroupItem` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `GroupItem` FROM `ExportGroupItem` WHERE `Export`='.$_GET['ExportId'].')');
|
---|
796 | $this->System->Database->query('INSERT INTO `ExportLanguage` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `Language`, `Sequence` FROM `ExportLanguage` WHERE `Export`='.$_GET['ExportId'].')');
|
---|
797 | $this->System->Database->query('INSERT INTO `ExportUser` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `User`, `Sequence` FROM `ExportUser` WHERE `Export`='.$_GET['ExportId'].')');
|
---|
798 | $Output = ShowMessage(T('Clone export created.<br />Direct link to export').': <a href="?Action=View&ExportId='.$ExportId.'">zde</a>');
|
---|
799 | $this->System->ModuleManager->Modules['Log']->WriteLog(T('Clone export created').' <a href="'.$this->System->Link('/export/?Action=View&ExportId='.$ExportId).'">'.$ExportId.'</a>.', LOG_TYPE_EXPORT);
|
---|
800 | $_GET['Filter'] = 'my';
|
---|
801 | $this->ExportList();
|
---|
802 | } else $Output = ShowMessage('Zdrojový export nenalezen', MESSAGE_CRITICAL);
|
---|
803 | } else $Output = ShowMessage(sprintf(T('You can\'t create another export. Max for one user is %d.'),
|
---|
804 | $this->System->Config['MaxExportPerUser']), MESSAGE_CRITICAL);
|
---|
805 | } else $Output = ShowMessage(T('Export not found.'), MESSAGE_CRITICAL);
|
---|
806 | } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
---|
807 | return($Output);
|
---|
808 | }
|
---|
809 |
|
---|
810 | function Show()
|
---|
811 | {
|
---|
812 | $this->Title = T('Export');
|
---|
813 | if(array_key_exists('Action', $_GET))
|
---|
814 | {
|
---|
815 | if($_GET['Action'] == 'Create') $Output = $this->ExportCreate();
|
---|
816 | else if($_GET['Action'] == 'CreateFinish') $Output = $this->ExportCreateFinish();
|
---|
817 | else if($_GET['Action'] == 'View') $Output = $this->ExportView();
|
---|
818 | else if($_GET['Action'] == 'Delete') $Output = $this->ExportDelete();
|
---|
819 | else if($_GET['Action'] == 'Clone') $Output = $this->ExportClone();
|
---|
820 | else $Output = $this->ExportList();
|
---|
821 | } else $Output = $this->ExportList();
|
---|
822 | return($Output);
|
---|
823 | }
|
---|
824 | }
|
---|