1 | <?php
|
---|
2 |
|
---|
3 | class Export extends Model
|
---|
4 | {
|
---|
5 | var $Id;
|
---|
6 | var $AnoNe = array('Ne', 'Ano');
|
---|
7 | var $WhereLang;
|
---|
8 | var $WhereUsers;
|
---|
9 | var $SelectedUsers;
|
---|
10 | var $UserNames;
|
---|
11 | var $ClientVersion;
|
---|
12 | var $OrderByUserList;
|
---|
13 | var $TempDir;
|
---|
14 | var $SourceDir;
|
---|
15 |
|
---|
16 | function Init()
|
---|
17 | {
|
---|
18 | $this->TempDir = dirname(__FILE__).'/../../'.$this->System->Config['Web']['TempFolder'].'Export/'.$this->Id.'/';
|
---|
19 | if (!file_exists($this->TempDir)) mkdir($this->TempDir, 0777, true);
|
---|
20 | $this->TempDirRelative = $this->System->Config['Web']['TempFolder'].'Export/'.$this->Id.'/';
|
---|
21 | $this->SourceDir = dirname(__FILE__).'/../../'.$this->System->Config['Web']['SourceFolder'];
|
---|
22 | $this->SourceDirRelative = $this->System->Config['Web']['SourceFolder'];
|
---|
23 | if (!file_exists($this->SourceDir)) mkdir($this->SourceDir, 0777, true);
|
---|
24 | }
|
---|
25 |
|
---|
26 | function SaveAllUsers()
|
---|
27 | {
|
---|
28 | $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$this->Id);
|
---|
29 | $Export = $DbResult->fetch_assoc();
|
---|
30 | if ($Export['AllUsers'])
|
---|
31 | {
|
---|
32 | $DbResult2 = $this->System->Database->query('SELECT ID FROM `User` WHERE `ID` NOT IN(SELECT `User` FROM `ExportUser` WHERE `Export`='.$this->Id.')');
|
---|
33 | while ($UserLine = $DbResult2->fetch_assoc())
|
---|
34 | {
|
---|
35 | $Condition = ' WHERE `Export`='.$this->Id.' AND `User`='.$UserLine['ID'];
|
---|
36 | $DbResult = $this->System->Database->query('SELECT * FROM `ExportUser` '.$Condition); //,MAX(`Sequence`) as MaxSequence
|
---|
37 | if ($DbResult->num_rows > 0)
|
---|
38 | {
|
---|
39 | // $this->System->Database->query('UPDATE `ExportUser` SET `Sequence`='.$Value.$Condition);
|
---|
40 | } else
|
---|
41 | {
|
---|
42 | $this->System->Database->query('INSERT INTO `ExportUser` (`Export`, `User`, `Sequence`) VALUES ('.$this->Id.', '.$UserLine['ID'].', 0)');
|
---|
43 | }
|
---|
44 | }
|
---|
45 |
|
---|
46 | $this->System->Database->query('SET @I = 0');
|
---|
47 | $this->System->Database->query('UPDATE `ExportUser` SET `Sequence` = (@I := @I + 1) WHERE `Export`='.$this->Id.' ORDER BY `Sequence`;');
|
---|
48 | }
|
---|
49 | }
|
---|
50 |
|
---|
51 | function LoadFilters()
|
---|
52 | {
|
---|
53 | $DbResult = $this->Database->query('SELECT * FROM `Export` WHERE `Id`='.$this->Id);
|
---|
54 | if ($DbResult->num_rows == 0) throw new Exception('Export '.$this->Id.' neexistuje');
|
---|
55 | $this->Export = $DbResult->fetch_assoc();
|
---|
56 |
|
---|
57 | // Filter selected users
|
---|
58 | $this->UserNames = '';
|
---|
59 | $DbResult = $this->Database->query('SELECT `ExportUser`.*, `User`.`Name`, `User`.`ID` FROM `ExportUser` '.
|
---|
60 | 'LEFT JOIN `User` ON `User`.`ID`=`ExportUser`.`User` '.
|
---|
61 | 'WHERE `ExportUser`.`Export`='.$this->Id.' ORDER BY `ExportUser`.`Sequence`');
|
---|
62 | while ($UserLine = $DbResult->fetch_assoc())
|
---|
63 | {
|
---|
64 | $this->UserNames .= ', '.$UserLine['Name'];
|
---|
65 | }
|
---|
66 | $this->UserNames = substr($this->UserNames, 2);
|
---|
67 |
|
---|
68 | if ($this->Export['ClientVersion'] != '')
|
---|
69 | {
|
---|
70 | $DbResult = $this->Database->query('SELECT * FROM `ClientVersion` WHERE `Id`='.$this->Export['ClientVersion']);
|
---|
71 | $this->ClientVersion = $DbResult->fetch_assoc();
|
---|
72 | } else $this->ClientVersion = '';
|
---|
73 | }
|
---|
74 |
|
---|
75 | function BuildQuery($Group, $Version = '')
|
---|
76 | {
|
---|
77 | $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
|
---|
78 | $this->SaveAllUsers();
|
---|
79 |
|
---|
80 | if ($Version <> '')
|
---|
81 | $ExportVersion = $Version;
|
---|
82 | else
|
---|
83 | $ExportVersion = $this->ClientVersion['BuildNumber'];
|
---|
84 |
|
---|
85 | $DbResultItem = $this->System->Database->query('SELECT * FROM `ExportGroupItem` WHERE `Export`='.$this->Id);
|
---|
86 | while ($GroupItem = $DbResultItem->fetch_assoc())
|
---|
87 | {
|
---|
88 | $GroupItems[$GroupItem['GroupItem']] = 1;
|
---|
89 | }
|
---|
90 | // Build selected columns
|
---|
91 | $Columns = '';
|
---|
92 | foreach ($TranslationTree[$Group['Id']]['Items'] as $Column)
|
---|
93 | {
|
---|
94 | if (!isset($GroupItems[$Column['Id']])) $Columns .= ' `T`.`'.$Column['Column'].'` AS `'.$Column['Column'].'`, ';
|
---|
95 | }
|
---|
96 | // $Columns = substr($Columns, 0, -2);
|
---|
97 |
|
---|
98 | $Query = 'SELECT * FROM (SELECT ANY_VALUE(`TT`.`ID`) AS `TTID` FROM (SELECT '.$Columns.' T.`ID`,T.`Language`,T.`User`,T.`Entry`,T.`VersionEnd`,T.`VersionStart`, `User`.`Name` AS `UserName` FROM `'.$Group['TablePrefix'].'` AS `T`'.
|
---|
99 | ' JOIN `ExportUser` ON (`ExportUser`.`User`=`T`.`User`) AND (`ExportUser`.`Export`='.$this->Id.') '.
|
---|
100 | ' JOIN `User` ON `User`.`ID`=`T`.`User`'.
|
---|
101 | ' JOIN `ExportLanguage` ON (`ExportLanguage`.`Export`='.$this->Id.')'.
|
---|
102 | ' WHERE (`Complete` = 1) AND (`VersionStart` <= '.$ExportVersion.') AND (`VersionEnd` >= '.$ExportVersion.')'.
|
---|
103 | ' ORDER BY `ExportLanguage`.`Sequence`, `ExportUser`.`Sequence`) AS `TT` GROUP BY `TT`.`Entry`) AS `TK`'.
|
---|
104 | ' LEFT JOIN `'.$Group['TablePrefix'].'` AS `TJ` ON `TJ`.`ID` = `TK`.`TTID` ';
|
---|
105 |
|
---|
106 | // Build columns for english texts
|
---|
107 | $OriginalColumns = '';
|
---|
108 | foreach ($TranslationTree[$Group['Id']]['Items'] as $Column)
|
---|
109 | {
|
---|
110 | $OriginalColumns .= ' `T3`.`'.$Column['Column'].'` AS `En'.$Column['Column'].'`, ';
|
---|
111 | if (isset($GroupItems[$Column['Id']]))
|
---|
112 | $OriginalColumns .= ' `T3`.`'.$Column['Column'].'` AS `'.$Column['Column'].'`, ';
|
---|
113 | }
|
---|
114 | $OriginalColumns = substr($OriginalColumns, 0, -2);
|
---|
115 |
|
---|
116 | // Expand query for loading english texts
|
---|
117 | $Query = 'SELECT `T4`.*, '.$OriginalColumns.' FROM ('.$Query.') AS `T4` '.
|
---|
118 | ' LEFT JOIN `'.$Group['TablePrefix'].'` AS `T3` ON (`T3`.`Entry` = `T4`.`Entry`) '.
|
---|
119 | 'AND (`T3`.`Language` = '.$this->System->Config['OriginalLanguage'].') AND '.
|
---|
120 | '(`T3`.`VersionStart` = `T4`.`VersionStart`) AND (`T3`.`VersionEnd` = `T4`.`VersionEnd`)';
|
---|
121 |
|
---|
122 | return $Query;
|
---|
123 | }
|
---|
124 |
|
---|
125 | function NeedGeneration()
|
---|
126 | {
|
---|
127 | $this->LoadFilters();
|
---|
128 | $file = '';
|
---|
129 | if ($this->Export['OutputType'] == 10) $file = $this->TempDir.'Instalace_CzechWoW_'.$this->ClientVersion['Version'].'.exe';
|
---|
130 | if ($this->Export['OutputType'] == 9) $file = $this->TempDir.'CzWoW_DBC.zip';
|
---|
131 |
|
---|
132 | if (file_exists($file))
|
---|
133 | $date = date('Y-m-d H:i',(filemtime($file)));
|
---|
134 | else return true;
|
---|
135 |
|
---|
136 | $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` '.
|
---|
137 | 'JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id);
|
---|
138 | $result = false;
|
---|
139 | while ($Group = $DbResult->fetch_assoc())
|
---|
140 | {
|
---|
141 | $Query = 'SELECT * FROM `'.$Group['TablePrefix'].'` AS `T`'.
|
---|
142 | ' JOIN `ExportUser` ON (`ExportUser`.`User`=`T`.`User`) AND (`ExportUser`.`Export`='.$this->Id.') '.
|
---|
143 | ' JOIN `User` ON `User`.`ID`=`T`.`User`'.
|
---|
144 | ' JOIN `ExportLanguage` ON (`ExportLanguage`.`Export`='.$this->Id.')'.
|
---|
145 | ' WHERE ( \''.$date.'\' < `T`.`ModifyTime`) AND (`Complete` = 1) AND (`VersionStart` <= '.$this->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$this->ClientVersion['BuildNumber'].')'.
|
---|
146 | ' ';
|
---|
147 |
|
---|
148 | $DbResult2 = $this->Database->query($Query);
|
---|
149 | if ($DbResult2->num_rows > 0)
|
---|
150 | {
|
---|
151 | $result = true;
|
---|
152 | }
|
---|
153 | }
|
---|
154 | return $result;
|
---|
155 | }
|
---|
156 |
|
---|
157 | function ExportToMangosSQL()
|
---|
158 | {
|
---|
159 | $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
|
---|
160 |
|
---|
161 | $this->LoadFilters();
|
---|
162 |
|
---|
163 | $Buffer =
|
---|
164 | "-- Generováno projektem wowpreklad.zdechov.net\n".
|
---|
165 | "-- ===========================================\n".
|
---|
166 | "--\n".
|
---|
167 | "-- Web projektu: ".$this->System->Config['Web']['Host'].$this->System->Link('/')."\n".
|
---|
168 | "-- Datum exportu: ".date("j.n.Y H:i:s")."\n".
|
---|
169 | "-- Znaková sada: ".$this->System->Config['Database']['Charset']." / ".$this->System->Config['Web']['Charset']."\n".
|
---|
170 | "-- Diakritika: ".$this->AnoNe[$this->Export['WithDiacritic']]."\n".
|
---|
171 | "-- Vygeneroval uživatel: ".$this->System->User->Name."\n".
|
---|
172 | "-- Vzato od uživatelů: ".$this->UserNames."\n".
|
---|
173 | "-- Generované tabulky: ";
|
---|
174 |
|
---|
175 | $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` '.
|
---|
176 | 'JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id);
|
---|
177 | while ($Group = $DbResult->fetch_assoc())
|
---|
178 | {
|
---|
179 | $Buffer .= $Group['TablePrefix'].', ';
|
---|
180 | }
|
---|
181 | $Buffer .= "\n\n";
|
---|
182 |
|
---|
183 | $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` '.
|
---|
184 | 'JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id);
|
---|
185 | while ($Group = $DbResult->fetch_assoc())
|
---|
186 | {
|
---|
187 | if ($Group['MangosTable'] != '')
|
---|
188 | {
|
---|
189 | $Buffer .= "\n\n-- ".$Group['Name']."\n\n";
|
---|
190 | $DbResult2 = $this->Database->query($this->BuildQuery($Group));
|
---|
191 | if ($DbResult2->num_rows > 0)
|
---|
192 | while ($Line = $DbResult2->fetch_array())
|
---|
193 | {
|
---|
194 | $Values = '';
|
---|
195 | foreach ($TranslationTree[$Group['Id']]['Items'] as $GroupItem)
|
---|
196 | if ($GroupItem['Column'] != $Group['PrimaryKeyItem']) // Do not update primary key
|
---|
197 | {
|
---|
198 | if ($GroupItem['MangosColumn'] == '') $GroupItem['MangosColumn'] = $GroupItem['Column'];
|
---|
199 | $Values .= ', `'.$GroupItem['MangosColumn'].'`="'.addslashes($Line[$GroupItem['Column']]).'"';
|
---|
200 | }
|
---|
201 | $Values = substr($Values, 2);
|
---|
202 |
|
---|
203 | // Get multicolumn index
|
---|
204 | $ColumnItems = explode(',', $Group['MangosTableIndex']);
|
---|
205 | if (count($ColumnItems) > 1)
|
---|
206 | {
|
---|
207 | $Where = 'CONCAT(';
|
---|
208 | foreach ($ColumnItems as $ColumnItem)
|
---|
209 | $Where .= '`'.$ColumnItem.'`, "_", ';
|
---|
210 | $Where = substr($Where, 0, -7).')';
|
---|
211 | } else $Where = '`'.$Group['MangosTableIndex'].'`';
|
---|
212 | $Where .= ' = "'.$Line[$Group['PrimaryKeyItem']].'";';
|
---|
213 |
|
---|
214 | $Line = 'UPDATE `'.$Group['MangosTable'].'` SET '.$Values.' WHERE '.$Where;
|
---|
215 | $Line = str_replace("\n", '\n', $Line);
|
---|
216 | $Line = str_replace("\r", '', $Line);
|
---|
217 | $Buffer .= $Line."\n";
|
---|
218 | }
|
---|
219 | }
|
---|
220 | }
|
---|
221 | if ($this->Export['WithDiacritic'] != 1) $Buffer = utf2ascii($Buffer);
|
---|
222 | return $Buffer;
|
---|
223 | }
|
---|
224 |
|
---|
225 | function ExportToAoWoWSQL()
|
---|
226 | {
|
---|
227 | global $AoWoWconf;
|
---|
228 |
|
---|
229 | $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
|
---|
230 |
|
---|
231 | //require_once('../aowow/configs/config.php');
|
---|
232 |
|
---|
233 | $Buffer = $this->ExportToMangosSQL();
|
---|
234 |
|
---|
235 | /*
|
---|
236 | // Data to aowow
|
---|
237 | $Database2 = new mysqli($this->System->Config['Database']['Host'],
|
---|
238 | $this->System->Config['Database']['User'],
|
---|
239 | $this->System->Config['Database']['Password'],
|
---|
240 | $this->System->Config['Database']['Database']);
|
---|
241 | $Database2->query('SET NAMES '.$this->System->Config['Database']['Charset']);
|
---|
242 | $Database2->select_db($AoWoWconf['mangos']['db']);
|
---|
243 | $AoWoWTables = array(
|
---|
244 | 'aowow_resistances' => 'Id',
|
---|
245 | 'aowow_spelldispeltype' => 'Id',
|
---|
246 | 'aowow_skill' => 'skillID',
|
---|
247 | );
|
---|
248 | foreach ($AoWoWTables as $AoWoWTable => $IndexColum)
|
---|
249 | {
|
---|
250 | $Buffer .= '--'.$AoWoWTable.', ';
|
---|
251 | $Buffer .= "\n\n";
|
---|
252 | $Query = 'SELECT `name`,`'.$IndexColum.'` FROM `'.$AoWoWTable.'`';
|
---|
253 | $DbResult = $Database2->query($Query);
|
---|
254 | while ($Line = $DbResult->fetch_assoc())
|
---|
255 | {
|
---|
256 | $Ori_text = $Line['name'];
|
---|
257 | $DbResult2 = $Database2->query('SELECT `Text` AS `En`,
|
---|
258 | (SELECT `Text` FROM `'.$this->System->Config['Database']['Database'].'`.`TextGlobalString` AS `TableTran`
|
---|
259 | WHERE `TableEn`.`Entry` = `TableTran`.`Entry` AND (`Complete` = 1) AND '.$this->WhereLang.' AND '.$this->WhereUsers.$this->OrderByUserList.' LIMIT 1) AS `Tran`
|
---|
260 | FROM `'.$this->System->Config['Database']['Database'].'`.`TextGlobalString` AS `TableEn` WHERE
|
---|
261 | `Text` = "'.addslashes($Ori_text).'" LIMIT 1');
|
---|
262 | $Tran = $DbResult2->fetch_assoc();
|
---|
263 | //echo ($Line['name'].'='.$Tran['tran']);
|
---|
264 | if ($Tran['Tran'] == '')
|
---|
265 | {
|
---|
266 | $DbResult2 = $Database2->query('SELECT `OptionText` AS `En`,
|
---|
267 | (SELECT `OptionText` FROM `'.$this->System->Config['Database']['Database'].'`.`TextNPCOption` AS `TableTran`
|
---|
268 | WHERE `TableEn`.`Entry` = `TableTran`.`Entry` AND (`Complete` = 1) AND '.$this->WhereLang.'
|
---|
269 | AND '.$this->WhereUsers.$this->OrderByUserList.' LIMIT 1) AS `Tran`
|
---|
270 | FROM `'.$this->System->Config['Database']['Database'].'`.`TextNPCOption` AS `TableEn` WHERE
|
---|
271 | `OptionText` = "'.addslashes($Ori_text).'" LIMIT 1');
|
---|
272 | $Tran = $DbResult2->fetch_assoc();
|
---|
273 | }
|
---|
274 |
|
---|
275 | if ($Tran['Tran'] <> '')
|
---|
276 | $Buffer .= 'UPDATE `'.$AoWoWTable.'` SET `name` = "'.addslashes($Tran['Tran']).'" WHERE '.$IndexColum.' = '.$Line[$IndexColum].' ;'."\n";
|
---|
277 | }
|
---|
278 | $Buffer .= "\n\n";
|
---|
279 | }
|
---|
280 | */
|
---|
281 | if ($this->Export['WithDiacritic'] != 1) $Buffer = utf2ascii($Buffer);
|
---|
282 | return $Buffer;
|
---|
283 | }
|
---|
284 |
|
---|
285 | // Export only if translate have same varible %
|
---|
286 | function HaveVarible($String1, $String2, $StartChar = '$')
|
---|
287 | {
|
---|
288 | if (strpos($String1, $StartChar) !== false)
|
---|
289 | {
|
---|
290 | while (strpos($String1, $StartChar) !== false)
|
---|
291 | {
|
---|
292 | $pos = strpos($String1, $StartChar);
|
---|
293 | $String1 = substr($String1, $pos + 1);
|
---|
294 | $varible = $String1;
|
---|
295 | if (strpos($varible, ' ')) $varible = substr($varible, 0, strpos($varible, ' '));
|
---|
296 | if (strpos($varible, '.')) $varible = substr($varible, 0, strpos($varible, '.'));
|
---|
297 | if (strpos($varible, ',')) $varible = substr($varible, 0, strpos($varible, ','));
|
---|
298 | if (strpos($varible, '%')) $varible = substr($varible, 0, strpos($varible, '%'));
|
---|
299 | if (strpos($varible, chr(10))) $varible = substr($varible, 0, strpos($varible, chr(10)));
|
---|
300 |
|
---|
301 | if (false === strpos($String2, $varible))
|
---|
302 | {
|
---|
303 | return false;
|
---|
304 | }
|
---|
305 | }
|
---|
306 | }
|
---|
307 | return true;
|
---|
308 | }
|
---|
309 |
|
---|
310 | function AddProgress($add = 1)
|
---|
311 | {
|
---|
312 | $DbResult = $this->System->Database->query('SELECT Progress FROM `ExportTask` WHERE `Export`='.$this->Id);
|
---|
313 | $Task = $DbResult->fetch_assoc();
|
---|
314 | $per = $Task['Progress']+$add;
|
---|
315 | $this->System->Database->query('UPDATE `ExportTask` SET `Progress`='.$per.' WHERE `Export`='.$this->Id);
|
---|
316 | }
|
---|
317 |
|
---|
318 | function ExportToDBC()
|
---|
319 | {
|
---|
320 | $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
|
---|
321 |
|
---|
322 | $this->LoadFilters();
|
---|
323 |
|
---|
324 | $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` '.
|
---|
325 | 'JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` '.
|
---|
326 | 'WHERE `ExportGroup`.`Export`='.$this->Id.' AND `Group`.`DBCFileName` != ""');
|
---|
327 | $Output = 'Počet generovaných skupin: '.$DbResult->num_rows."\n";
|
---|
328 | while ($Group = $DbResult->fetch_assoc())
|
---|
329 | {
|
---|
330 | $this->AddProgress(2);
|
---|
331 | $Output .= $Group['Name'].', ';
|
---|
332 | if (file_exists($this->SourceDir.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc'))
|
---|
333 | {
|
---|
334 | // Load string column index list
|
---|
335 | $DbResult2 = $this->Database->query('SELECT * FROM `GroupItem` '.
|
---|
336 | 'JOIN `GroupItemDBC` ON `GroupItem`.`Id` = `GroupItemDBC`.`GroupItem` AND `GroupItemDBC`.`ClientVersion` = '.$this->ClientVersion['Id'].' WHERE `GroupItem`.`Group` = '.$Group['Id']);
|
---|
337 | $ColumnIndexes = array();
|
---|
338 | $ColumnFormat = array();
|
---|
339 | while ($DbRow = $DbResult2->fetch_assoc())
|
---|
340 | {
|
---|
341 | $ColumnFormat[$DbRow['ColumnIndex']] = FORMAT_STRING;
|
---|
342 | $ColumnIndexes[$DbRow['GroupItem']] = $DbRow['ColumnIndex'];
|
---|
343 | }
|
---|
344 |
|
---|
345 | // Load all data into lookup table
|
---|
346 | $LookupTable = array();
|
---|
347 | $DbResult2 = $this->Database->query($this->BuildQuery($Group));
|
---|
348 | while ($DbRow = $DbResult2->fetch_assoc())
|
---|
349 | {
|
---|
350 | //Export only if translate have same varible %
|
---|
351 | $CanExport = true;
|
---|
352 | foreach ($TranslationTree[$Group['Id']]['Items'] as $Column)
|
---|
353 | {
|
---|
354 | $DbRow[$Column['Column']] = str_replace ( '$ ','$',$DbRow[$Column['Column']]);
|
---|
355 | if (!$this->HaveVarible($DbRow['En'.$Column['Column']],$DbRow[$Column['Column']]))
|
---|
356 | {
|
---|
357 | $CanExport = false;
|
---|
358 | $Output .= ', NE='.$DbRow['ID'];
|
---|
359 | }
|
---|
360 | if (!$this->HaveVarible($DbRow[$Column['Column']],$DbRow['En'.$Column['Column']]))
|
---|
361 | {
|
---|
362 | $CanExport = false;
|
---|
363 | $Output .= ', NE='.$DbRow['ID'];
|
---|
364 | }
|
---|
365 | }
|
---|
366 |
|
---|
367 | if ($CanExport)
|
---|
368 | $LookupTable[$DbRow[$Group['PrimaryKeyItem']]] = $DbRow;
|
---|
369 | }
|
---|
370 |
|
---|
371 | // Open original DBC file
|
---|
372 | $SourceDBCFile = new DBCFile();
|
---|
373 | $SourceDBCFile->OpenFile($this->SourceDir.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc', $ColumnFormat);
|
---|
374 |
|
---|
375 | // Create new DBC file
|
---|
376 | if (!file_exists($this->TempDir.'dbc/')) mkdir($this->TempDir.'dbc/', 0777, true);
|
---|
377 | $NewDBCFile = new DBCFile();
|
---|
378 | $NewDBCFile->CreateFile($this->TempDir.'dbc/'.$Group['DBCFileName'].'.dbc', $ColumnFormat);
|
---|
379 | $NewDBCFile->SetRecordCount($SourceDBCFile->GetRecordCount());
|
---|
380 | $NewDBCFile->SetFieldCount($SourceDBCFile->GetFieldCount());
|
---|
381 | $NewDBCFile->Commit();
|
---|
382 |
|
---|
383 | // Replace translated strings
|
---|
384 | $OldProgress = -1;
|
---|
385 | $Output .= "\n\r";
|
---|
386 | $RowCount = $SourceDBCFile->GetRecordCount();
|
---|
387 | $FieldCount = $SourceDBCFile->GetFieldCount();
|
---|
388 | for ($Row = 0; $Row < $RowCount; $Row++)
|
---|
389 | {
|
---|
390 | $Line = $SourceDBCFile->GetLine($Row);
|
---|
391 |
|
---|
392 | // Get multicolumn index value
|
---|
393 | $PrimaryKeyItem = '';
|
---|
394 | $ColumnItems = explode(',', $Group['DBCIndex']);
|
---|
395 | if (count($ColumnItems) > 1)
|
---|
396 | {
|
---|
397 | foreach ($ColumnItems as $ColumnItem)
|
---|
398 | $PrimaryKeyItem .= $Line[$ColumnItem].'_';
|
---|
399 | $PrimaryKeyItem = substr($PrimaryKeyItem, 0, -1);
|
---|
400 | } else $PrimaryKeyItem = $Line[$Group['DBCIndex']];
|
---|
401 |
|
---|
402 | if (array_key_exists($PrimaryKeyItem, $LookupTable))
|
---|
403 | {
|
---|
404 | // Replace text columns
|
---|
405 | $LookupTableItem = $LookupTable[$PrimaryKeyItem];
|
---|
406 | foreach ($TranslationTree[$Group['Id']]['Items'] as $GroupItem)
|
---|
407 | {
|
---|
408 | if (array_key_exists($GroupItem['Id'], $ColumnIndexes))
|
---|
409 | $Line[$ColumnIndexes[$GroupItem['Id']]] = $LookupTableItem[$GroupItem['Column']];
|
---|
410 | }
|
---|
411 | }
|
---|
412 | $NewDBCFile->SetLine($Row, $Line);
|
---|
413 |
|
---|
414 | // Show completion progress
|
---|
415 | $Progress = round($Row / $RowCount * 100);
|
---|
416 | if ($Progress != $OldProgress)
|
---|
417 | {
|
---|
418 | if (($Group['Id'] == 13) and ($Progress <> 100)) $this->AddProgress(0.01);
|
---|
419 | $Output .= $Progress."%\r";
|
---|
420 | echo($Output);
|
---|
421 | $Output = '';
|
---|
422 | $OldProgress = $Progress;
|
---|
423 | }
|
---|
424 | }
|
---|
425 | $NewDBCFile->Commit();
|
---|
426 | } else $Output .= ShowMessage('Zdrojový soubor '.$this->SourceDirRelative.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc'.' nenalezen.'."\n", MESSAGE_CRITICAL);
|
---|
427 | }
|
---|
428 | $Output .= 'Hotovo <br />';
|
---|
429 | return $Output;
|
---|
430 | }
|
---|
431 |
|
---|
432 | function ExportToLua()
|
---|
433 | {
|
---|
434 | $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
|
---|
435 |
|
---|
436 | $this->LoadFilters();
|
---|
437 |
|
---|
438 | $Output = '';
|
---|
439 | if (!file_exists($this->TempDir.'lua/')) mkdir($this->TempDir.'lua/', 0777, true);
|
---|
440 | $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id.' AND `Group`.`LuaFileName` != ""');
|
---|
441 | while ($Group = $DbResult->fetch_assoc())
|
---|
442 | {
|
---|
443 | $this->AddProgress(1);
|
---|
444 | // $this->AddProgress();
|
---|
445 | $Output .= $Group['Name'].'... ';
|
---|
446 | $File = new FileStream();
|
---|
447 | if (!file_exists($this->SourceDir.$this->ClientVersion['Version'].'/lua/'.$Group['LuaFileName'].'.lua'))
|
---|
448 | continue;
|
---|
449 | $File->OpenFile($this->SourceDir.$this->ClientVersion['Version'].'/lua/'.$Group['LuaFileName'].'.lua');
|
---|
450 | $File2 = new FileStream();
|
---|
451 | $File2->CreateFile($this->TempDir.'lua/'.$Group['LuaFileName'].'.lua');
|
---|
452 |
|
---|
453 | $LookupTable = array();
|
---|
454 | $DbResult2 = $this->Database->query($this->BuildQuery($Group));
|
---|
455 | while ($DbRow = $DbResult2->fetch_assoc())
|
---|
456 | {
|
---|
457 | $CanExport = true;
|
---|
458 | foreach ($TranslationTree[$Group['Id']]['Items'] as $Column)
|
---|
459 | {
|
---|
460 | // if (strpos($DbRow[$Column['Column']],'\\'))
|
---|
461 | // $CanExport = false;
|
---|
462 | // $DbRow[$Column['Column']] = str_replace ( '$ ','$',$DbRow[$Column['Column']]);
|
---|
463 | // $DbRow[$Column['Column']] = $DbRow['En'.$Column['Column']];
|
---|
464 |
|
---|
465 | if (!$this->HaveVarible($DbRow['En'.$Column['Column']],$DbRow[$Column['Column']]))
|
---|
466 | {
|
---|
467 | if ($CanExport) $Output .= ', NE='.$DbRow['ID'];
|
---|
468 | $CanExport = false;
|
---|
469 | }
|
---|
470 | if (!$this->HaveVarible($DbRow[$Column['Column']],$DbRow['En'.$Column['Column']]))
|
---|
471 | {
|
---|
472 | if ($CanExport) $Output .= ', NE='.$DbRow['ID'];
|
---|
473 | $CanExport = false;
|
---|
474 | }
|
---|
475 | if (!$this->HaveVarible($DbRow['En'.$Column['Column']],$DbRow[$Column['Column']],'%'))
|
---|
476 | {
|
---|
477 | if ($CanExport) $Output .= ', NE='.$DbRow['ID'];
|
---|
478 | $CanExport = false;
|
---|
479 | }
|
---|
480 | if (!$this->HaveVarible($DbRow[$Column['Column']],$DbRow['En'.$Column['Column']],'%'))
|
---|
481 | {
|
---|
482 | if ($CanExport) $Output .= ', NE='.$DbRow['ID'];
|
---|
483 | $CanExport = false;
|
---|
484 | }
|
---|
485 | if (!$this->HaveVarible($DbRow[$Column['Column']],$DbRow['En'.$Column['Column']],'\\'))
|
---|
486 | {
|
---|
487 | if ($CanExport) $Output .= ', NE='.$DbRow['ID'];
|
---|
488 | $CanExport = false;
|
---|
489 | }
|
---|
490 | if (!$this->HaveVarible($DbRow['En'.$Column['Column']],$DbRow[$Column['Column']],'\\'))
|
---|
491 | {
|
---|
492 | if ($CanExport) $Output .= ', NE='.$DbRow['ID'];
|
---|
493 | $CanExport = false;
|
---|
494 | }
|
---|
495 | if (!$this->HaveVarible($DbRow[$Column['Column']],$DbRow['En'.$Column['Column']],'|'))
|
---|
496 | {
|
---|
497 | if ($CanExport) $Output .= ', NE='.$DbRow['ID'];
|
---|
498 | $CanExport = false;
|
---|
499 | }
|
---|
500 | if (!$this->HaveVarible($DbRow['En'.$Column['Column']],$DbRow[$Column['Column']],'|'))
|
---|
501 | {
|
---|
502 | if ($CanExport) $Output .= ', NE='.$DbRow['ID'];
|
---|
503 | $CanExport = false;
|
---|
504 | }
|
---|
505 | if (!$this->HaveVarible($DbRow[$Column['Column']],$DbRow['En'.$Column['Column']],chr(10)))
|
---|
506 | {
|
---|
507 | if ($CanExport) $Output .= ', NE='.$DbRow['ID'];
|
---|
508 | $CanExport = false;
|
---|
509 | }
|
---|
510 | if (!$this->HaveVarible($DbRow['En'.$Column['Column']],$DbRow[$Column['Column']],chr(10)))
|
---|
511 | {
|
---|
512 | if ($CanExport) $Output .= ', NE='.$DbRow['ID'];
|
---|
513 | $CanExport = false;
|
---|
514 | }
|
---|
515 | }
|
---|
516 |
|
---|
517 | if ($CanExport)
|
---|
518 | $LookupTable[$DbRow['ShortCut']] = $DbRow;
|
---|
519 | }
|
---|
520 |
|
---|
521 | while (!$File->EOF())
|
---|
522 | {
|
---|
523 | $Line = $File->ReadLine();
|
---|
524 | if (strpos($Line, '=') !== false)
|
---|
525 | {
|
---|
526 | $LineParts = explode('=', $Line, 2);
|
---|
527 | $Value['ShortCut'] = trim($LineParts[0]);
|
---|
528 | $Line = trim($LineParts[1]);
|
---|
529 |
|
---|
530 | if ($Line[0] == '"')
|
---|
531 | {
|
---|
532 | // Quoted string value
|
---|
533 | $Line = substr($Line, 1); // Skip start qoute
|
---|
534 | $TempLine = str_replace('\"', ' ', $Line); // Temporary remove slashed quotes
|
---|
535 | if (strpos($TempLine, '"'))
|
---|
536 | {
|
---|
537 | $Value['Text'] = substr($Line, 0, strpos($TempLine, '"'));
|
---|
538 | } else {
|
---|
539 | $Value['Text'] = substr($Line, 0, strpos($Line, '"'));
|
---|
540 | }
|
---|
541 | // $Value['Text'] = str_replace('\n', "\n", $Value['Text']);
|
---|
542 | // $Value['Text'] = addslashes(stripslashes($Value['Text']));
|
---|
543 | $Line = trim(substr($Line, strpos($TempLine, '"') + 1)); // Skip closing quote and semicolon {
|
---|
544 | } else
|
---|
545 | {
|
---|
546 | // Nonstring value
|
---|
547 | $Value['Text'] = substr($Line, 0, strpos($Line, ';'));
|
---|
548 | }
|
---|
549 | $Line = substr($Line, strpos($Line, ';') + 1);
|
---|
550 | $Value['Comment'] = addslashes(stripslashes(substr($Line, 3))); // Skip " --"
|
---|
551 |
|
---|
552 | if (array_key_exists($Value['ShortCut'], $LookupTable))
|
---|
553 | {
|
---|
554 | $DbRow = $LookupTable[$Value['ShortCut']];
|
---|
555 | $Value['Text'] = $DbRow['Text'];
|
---|
556 | //addslashes
|
---|
557 | $Value['Text'] = str_replace('"', '\"', $Value['Text']);
|
---|
558 | // Escape new line control characters
|
---|
559 | $Value['Text'] = str_replace("\n", '\n', $Value['Text']);
|
---|
560 | $Value['Text'] = str_replace("\r", '', $Value['Text']);
|
---|
561 | $Value['Comment'] = $DbRow['Comment'];
|
---|
562 | // Only one line comments allowed
|
---|
563 | $Value['Comment'] = str_replace("\n", ' ', $Value['Comment']);
|
---|
564 | $Value['Comment'] = str_replace("\r", '', $Value['Comment']);
|
---|
565 | //echo('.');
|
---|
566 | }
|
---|
567 | $NewLine = $Value['ShortCut'].' = "'.$Value['Text'].'";';
|
---|
568 | //if ($Value['Comment'] != '') $NewLine .= ' -- '.$Value['Comment'];
|
---|
569 | $NewLine .= "\r\n";
|
---|
570 | $File2->WriteLine($NewLine);
|
---|
571 | } else $File2->WriteLine($Line);
|
---|
572 | }
|
---|
573 | $Output .= 'Hotovo <br/>';
|
---|
574 | }
|
---|
575 | return $Output;
|
---|
576 | }
|
---|
577 |
|
---|
578 | function GetReadme()
|
---|
579 | {
|
---|
580 | $_GET['ExportId'] = $this->Id;
|
---|
581 | $PageExport = new PageExport($this->System);
|
---|
582 | $this->LoadFilters();
|
---|
583 | $Output = '';
|
---|
584 | //generation readme
|
---|
585 | $Output .= '<?xml version="1.0" encoding="utf-8"?\>'.
|
---|
586 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'.
|
---|
587 | '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs">'.
|
---|
588 | '<head>'.
|
---|
589 | '<STYLE type="text/css">'.
|
---|
590 | '.BaseTable {margin: 2px auto 2px auto;border-width: 1px;border-color: black;border-style: solid;border-collapse: collapse;}'.
|
---|
591 |
|
---|
592 | '.BaseTable tr td{ border-width: 1px; border-color: black; border-style: solid; padding: 2px; text-align: center;}'.
|
---|
593 |
|
---|
594 | '.BaseTable tr th{ border-width: 1px; border-color: black; border-style: solid; padding: 2px; background-color: #F0F0F0; text-align: center;}'.
|
---|
595 | '</STYLE>'.
|
---|
596 | '<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />'.
|
---|
597 | '<title>Čeština pro WoW</title>'.
|
---|
598 | '</head><body>'.
|
---|
599 | '<h1>České WoW - čestina pro klienta hry World of Warcraft</h1>'.
|
---|
600 |
|
---|
601 | '<table cellspacing="10"><tr><td valign="top">'.
|
---|
602 |
|
---|
603 | '<p>Texty přebírány z projektu <a href="http://wowpreklad.zdechov.net/">wowpreklad.zdechov.net</a><br>'.
|
---|
604 | '<a href="http://wowpreklad.zdechov.net/export/?Action=View&ExportId='.$this->Id.'&Tab=0">Export '.$this->Id.'</a></p><br>'.
|
---|
605 |
|
---|
606 |
|
---|
607 | '<p><strong>Vlastnosti</strong>'.
|
---|
608 | '<ul>'.
|
---|
609 | '<li>Požadovaná verze klienta: '.$this->ClientVersion['Version'].'</li>'.
|
---|
610 | '<li>Datum uvolnění: '.date('d.m.Y h:m',time()).'</li>'.
|
---|
611 | '<li>Sestaveno automaticky překladovým systémem <a href="http://wowpreklad.zdechov.net/">WoW překlad</a></li>'.
|
---|
612 | //'<li>Tento soubor se generuje každý den. Pokud se zapojíte do překladu, zítra můžete stáhnout tento soubor znovu včetně svých překladů</li>'.
|
---|
613 | //'<li>Sestavil: Maron</li>'.
|
---|
614 | '</ul>'.
|
---|
615 | '</p>'.
|
---|
616 | '<br>'.
|
---|
617 |
|
---|
618 | '<h2>Nejčastější otázky</h2>'.
|
---|
619 | '<p><strong>Jak mám vyhledávat věci v aukci nebo výpravy na internetu s nainstalovanou češtinou?</strong><br>
|
---|
620 | Pokud používáte addon, který mění názvy předmětů jenom zdánlivě pro vás, potřebujete pro vyhledávání v aukci zjistit původní anglický název. Tento název zjistíte jednoduše držením klávesy shift a kliknutím na předmět při otevřené aukci, nebo chatu. Vytvořený odkaz v chatu, nebo text v aukci je v původním znění. Stejně zjistíte i název výpravy kliknutím se shift na výpravu v "quest logu".
|
---|
621 | Pokud jste na serveru s českou lokalizaci (tedy nepoužíváte addon), musíte využít český název pro vyhledávání. Server by měl mít spuštěnou vlastní obdobu databáze wowhead.</p>'.
|
---|
622 |
|
---|
623 | '<p><strong>Po nainstalování češtiny a spouštění přes soubor WoWlua.exe mi klesl výrazně výkon</strong><br>
|
---|
624 | Problém může být spojen s použitím integrované grafiky místo herní.</p>'.
|
---|
625 |
|
---|
626 | '<p><strong>Při spouštění hry přes soubor WoWLua.exe se mi neukládá žádné nastavení addonů a podobně</strong><br>
|
---|
627 | Problém může být způsoben špatně nastavenými právy u souboru WoWLua.exe. Můžete přenastavit práva, nebo spouštět jako správce.</p>'.
|
---|
628 |
|
---|
629 | '<p><strong>Po spuštění souboru WoWLua.exe mi píše chybu:</strong><br>
|
---|
630 | Cannot stream required archive data. Please check the network connection.
|
---|
631 | Chyba může být způsobena tím, že jste nenainstalovali češtinu do adresáře se hrou.
|
---|
632 | Nebo jste nainstalovali do jiné verze hry, než je požadovaná. Může se vztahovat i na požadovanou lokalizaci (enUS, enGB)</p>'.
|
---|
633 |
|
---|
634 | '<p><strong>Po nainstalování češtiny nemám žádné výpravy (questy) česky</strong><br>
|
---|
635 | Zkontrolujte si v přihlášení, jestli máte povolený addon CzWoW v seznamu addonů.</p>'.
|
---|
636 |
|
---|
637 | '<p><strong>Addon mi hlásí spoustu chyb.</strong><br>
|
---|
638 | Chyba může být způsobena kolizí s jinými addony. Vyzkoušejte spuštění hry pouze s addonem CzWoW.</p>'.
|
---|
639 |
|
---|
640 | '<p><strong>Ve hře se mi špatně zobrazuje diakritika (háčky, čárky)</strong><br>
|
---|
641 | Chyba je způsobena chybějícími fonty do hry. Potřebné fonty si stáhněte mezi soubory ke stažení.</p>'.
|
---|
642 |
|
---|
643 | '<p><strong>Mám nainstalovánu češtinu a nejde mi spustit Wow.exe.</strong><br>
|
---|
644 | Pokud chcete opět spouštět hru přes původní Wow.exe v angličtině, musíte češtinu nejprve odinstalovat ze systému. Především se jedná o soubor Data/enGB/patch-enGB-5.MPQ či Data/enUS/patch-enUS-5.MPQ, který je nutno smazat. U novějších verzí se soubor může jmenovat wow-update-base-50000.MPQ.</p>'.
|
---|
645 |
|
---|
646 | '<p><strong>Jak mám hru spustit?</strong><br>
|
---|
647 | Hru musíte spustit přes soubor WowLua.exe v kořenovém adresáři hry.</p>'.
|
---|
648 |
|
---|
649 | '<p><strong>Mohu použít tuto češtinu na oficiálních serverech?</strong><br>
|
---|
650 | Ne úplně, protože se vystavujete riziku zablokování vašeho účtu z důvodu použití upravené hry. Na oficiálním serveru lze využít pouze Addon s češtinou CzWoW. Instalační soubor určený pro oficiální servery je už takto přizpůsoben.</p>'.
|
---|
651 |
|
---|
652 | '</td><td>';
|
---|
653 |
|
---|
654 | $Output .= $PageExport->ExportViewStat(' WHERE `DBCFileName` !=\'\' OR `LuaFileName` !=\'\' OR `Group`.`Id` = 1 OR `Group`.`Id` = 2 OR `Group`.`Id` = 3 OR `Group`.`Id` = 16');
|
---|
655 |
|
---|
656 | $Output .= '</td></tr></table>'.
|
---|
657 | '</body></html>';
|
---|
658 | return $Output;
|
---|
659 | }
|
---|
660 |
|
---|
661 | function ExportToXML()
|
---|
662 | {
|
---|
663 | $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
|
---|
664 |
|
---|
665 | $this->LoadFilters();
|
---|
666 |
|
---|
667 | $Buffer = '<?xml version="1.0" encoding="utf-8"?>'."\n".
|
---|
668 | "<document>\n".
|
---|
669 | " <meta>\n".
|
---|
670 | " <projecturl>".$this->System->Config['Web']['Host'].$this->System->Link('/')."</projecturl>\n".
|
---|
671 | " <time>".date('r')."</time>\n".
|
---|
672 | " <diacritics mode=".'"'.$this->Export['WithDiacritic'].'"'." />\n".
|
---|
673 | " <author>".$this->System->User->Name."</author>\n".
|
---|
674 | " <contributors>\n";
|
---|
675 | foreach (explode(',', $this->UserNames) as $UserName)
|
---|
676 | $Buffer .= " <user>".$UserName."</user>\n";
|
---|
677 | $Buffer .=
|
---|
678 | " </contributors>\n".
|
---|
679 | " </meta>\n".
|
---|
680 | " <translation>\n";
|
---|
681 |
|
---|
682 | $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` '.
|
---|
683 | 'JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id);
|
---|
684 | while ($Group = $DbResult->fetch_assoc())
|
---|
685 | {
|
---|
686 | if ($Group['MangosTable'] == '')
|
---|
687 | {
|
---|
688 | $Group['MangosTable'] = $Group['TablePrefix'];
|
---|
689 | $Group['MangosTableIndex'] = 'entry';
|
---|
690 | }
|
---|
691 | $Buffer .= ' <group id="'.$Group['Id'].'" name="'.$Group['TablePrefix'].'">'."\n";
|
---|
692 | $DbResult2 = $this->Database->query($this->BuildQuery($Group));
|
---|
693 | while ($Line = $DbResult2->fetch_assoc())
|
---|
694 | {
|
---|
695 | $Buffer .= ' <item id="'.$Line['Entry'].'" user="'.$Line['UserName'].'">'."\n";
|
---|
696 | $Values = '';
|
---|
697 | foreach ($TranslationTree[$Group['Id']]['Items'] as $GroupItem)
|
---|
698 | {
|
---|
699 | if ($GroupItem['MangosColumn'] == '') $GroupItem['MangosColumn'] = $GroupItem['Column'];
|
---|
700 | if ($Line[$GroupItem['Column']] != '')
|
---|
701 | $Buffer .= ' <text index="'.$GroupItem['Id'].'" name="'.
|
---|
702 | $GroupItem['Column'].'">'.addslashes($Line[$GroupItem['Column']]).'</text>'."\n";
|
---|
703 | }
|
---|
704 | $Buffer .= " </item>\n";
|
---|
705 | }
|
---|
706 | $Buffer .= " </group>\n";
|
---|
707 | }
|
---|
708 | if ($this->Export['WithDiacritic'] != 1) $Buffer = utf2ascii($Buffer);
|
---|
709 | $Buffer .= " </translation>\n".
|
---|
710 | "</document>";
|
---|
711 | return $Buffer;
|
---|
712 | }
|
---|
713 | }
|
---|
714 |
|
---|
715 | include_once(dirname(__FILE__).'/Page.php');
|
---|
716 | include_once(dirname(__FILE__).'/ExportOutput.php');
|
---|
717 |
|
---|
718 | class ModuleExport extends AppModule
|
---|
719 | {
|
---|
720 | function __construct(System $System)
|
---|
721 | {
|
---|
722 | parent::__construct($System);
|
---|
723 | $this->Name = 'Export';
|
---|
724 | $this->Version = '1.0';
|
---|
725 | $this->Creator = 'Chronos';
|
---|
726 | $this->License = 'GNU/GPL';
|
---|
727 | $this->Description = 'Allow parametric export of translated texts to various supported output formats';
|
---|
728 | $this->Dependencies = array('Translation');
|
---|
729 | }
|
---|
730 |
|
---|
731 | function DoStart()
|
---|
732 | {
|
---|
733 | $this->System->RegisterPage('export', 'PageExport');
|
---|
734 | $this->System->RegisterPage(array('export', 'progress'), 'PageExportProgress');
|
---|
735 | $this->System->RegisterMenuItem(array(
|
---|
736 | 'Title' => 'Exporty',
|
---|
737 | 'Hint' => 'Zde si můžete stáhnout přeložené texty',
|
---|
738 | 'Link' => $this->System->Link('/export/'),
|
---|
739 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
740 | 'Icon' => '',
|
---|
741 | ), 2);
|
---|
742 | }
|
---|
743 |
|
---|
744 | function GetTaskProgress($TaskId)
|
---|
745 | {
|
---|
746 | $Output = '';
|
---|
747 | $DbResult = $this->Database->query('SELECT * FROM `ExportTask` '.
|
---|
748 | 'LEFT JOIN `Export` ON `Export`.`Id` = `ExportTask`.`Export` WHERE '.
|
---|
749 | '((`Export`.`OutputType` = 9) OR (`Export`.`OutputType` = 10)) AND '.
|
---|
750 | '(`TimeFinish` IS NULL) OR (`Export` ='.$TaskId.') ORDER BY `TimeQueued`'); // `Export`='.$Export->Id
|
---|
751 | while ($Task = $DbResult->fetch_assoc())
|
---|
752 | {
|
---|
753 | $Export = '<a href="'.$this->System->Link('/export/?Action=View&ExportId='.$Task['Export']).'">'.$Task['Export'].'</a>';
|
---|
754 | if ($TaskId == $Task['Export'])
|
---|
755 | $Export = ''.$Export.' (tento)';
|
---|
756 |
|
---|
757 | // Show progress bar
|
---|
758 | $Output .= ' <strong>Export '.$Export.':</strong> <div id="progress'.$Task['Export'].'">'.
|
---|
759 | '<strong>'.ProgressBar(300, $Task['Progress']).'</strong> ';
|
---|
760 |
|
---|
761 | // Show estimated time to complete
|
---|
762 | $PrefixMultiplier = new PrefixMultiplier();
|
---|
763 | if ($Task['Progress'] > 0) {
|
---|
764 | $ElapsedTime = time() - MysqlDateTimeToTime($Task['TimeStart']);
|
---|
765 | $Output .= T('Elapsed time').': <strong>'.$PrefixMultiplier->Add($ElapsedTime, '', 4, 'Time').'</strong> / ';
|
---|
766 | $EstimatedTime = (time() - MysqlDateTimeToTime($Task['TimeStart'])) / $Task['Progress'] * (100 - $Task['Progress']);
|
---|
767 | $Output .= T('Estimated remaining time').': <strong>'.$PrefixMultiplier->Add($EstimatedTime, '', 4, 'Time').'</strong><br/>';
|
---|
768 | }
|
---|
769 | $Output .= '</div>';
|
---|
770 |
|
---|
771 | if ($Task['Progress'] > 99)
|
---|
772 | $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
|
---|
773 | 'setTimeout("parent.location.href=\''.$this->System->Link('/export/?Action=View&Tab=7&ExportId='.$TaskId).'\'", 500)'.
|
---|
774 | '</script>';
|
---|
775 | }
|
---|
776 | return $Output;
|
---|
777 | }
|
---|
778 | }
|
---|