source: trunk/Modules/Import/Import.php@ 880

Last change on this file since 880 was 880, checked in by chronos, 5 years ago
  • Modified: Improved code formatting.
File size: 21.3 KB
Line 
1<?php
2
3include_once(dirname(__FILE__).'/../../includes/dbc.php');
4include_once(dirname(__FILE__).'/Manage.php');
5
6
7class ModuleImport extends AppModule
8{
9 function __construct(System $System)
10 {
11 parent::__construct($System);
12 $this->Name = 'Import';
13 $this->Version = '1.0';
14 $this->Creator = 'Chronos';
15 $this->License = 'GNU/GPL';
16 $this->Description = 'Support for import of data.';
17 $this->Dependencies = array('Translation');
18 }
19
20 function DoStart()
21 {
22 $this->System->RegisterPage('import', 'PageImport');
23 }
24}
25
26class Import
27{
28 var $Version;
29 var $Group;
30 var $NewItemCount;
31 var $System;
32
33 function __construct(System $System)
34 {
35 $this->System = &$System;
36 }
37
38 function SetVersion($Version)
39 {
40 global $System;
41
42 $DbResult = $System->Database->query('SELECT * FROM `ClientVersion` WHERE `Version` = "'.$Version.'"');
43 $this->Version = $DbResult->fetch_assoc();
44 }
45
46 function InsertItem($Value)
47 {
48 $insert = true;
49 $Columns = '';
50 //$Values = '';
51 foreach ($this->Group['Items'] as $GroupItem)
52 {
53 $Columns .= ', `'.$GroupItem['Column'].'` ';
54 // $Values .= ', "'.$Value[$GroupItem['Column']].'"';
55 }
56 $Columns = substr($Columns, 1);
57 $Where = ' (`'.$this->Group['PrimaryKeyItem'].'` = "'.$Value[$this->Group['PrimaryKeyItem']].'") AND (`Language`=0) ' ;
58
59 $DbResultMiddle = $this->System->Database->query('SELECT `VersionEnd`,`VersionStart`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND `VersionStart` <= '.$this->Version['BuildNumber'].' AND `VersionEnd` >= '.$this->Version['BuildNumber'].' ORDER BY `VersionEnd` DESC LIMIT 1');
60 $DbResultBefore = $this->System->Database->query('SELECT `VersionEnd`,`VersionStart`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND `VersionEnd` <= '.$this->Version['BuildNumber'].' ORDER BY `VersionEnd` DESC LIMIT 1');
61 $DbResultAfter = $this->System->Database->query('SELECT `VersionEnd`,`VersionStart`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND `VersionStart` >= '.$this->Version['BuildNumber'].' ORDER BY `VersionStart` LIMIT 1');
62
63 if (($DbResultMiddle->num_rows > 0) or ($DbResultBefore->num_rows > 0) or ($DbResultAfter->num_rows > 0))
64 {
65 // Update existed text
66 $DbRowMiddle = $DbResultMiddle->fetch_assoc();
67 $DbRowAfter = $DbResultAfter->fetch_assoc();
68 $DbRowBefore = $DbResultBefore->fetch_assoc();
69
70 if ($this->HaveSameText($this->Group, $DbRowBefore, $Value) and ($DbResultBefore->num_rows > 0) )
71 {
72 $insert = false;
73 if ($this->Group['Id'] == 1) {
74 $set = ' , EndText = "'.$Value['EndText'].'" , ObjectiveText1 = "'.$Value['ObjectiveText1'].'"'.' , ObjectiveText2 = "'.$Value['ObjectiveText2'].'"'.' , ObjectiveText3 = "'.$Value['ObjectiveText3'].'"'.' , ObjectiveText4 = "'.$Value['ObjectiveText4'].'"';
75 } else $set = '';
76 $this->System->Database->query('UPDATE `'.$this->Group['TablePrefix'].'` SET `VersionEnd` = "'.$this->Version['BuildNumber'].'" '.$set.' WHERE `ID`='.$DbRowBefore['ID']);
77 echo('b ');
78
79 } else
80 if ($this->HaveSameText($this->Group, $DbRowAfter, $Value) and ($DbResultAfter->num_rows > 0))
81 {
82 $insert = false;
83 if ($this->Group['Id'] == 1) {
84 $set = ' , EndText = "'.$Value['EndText'].'" , ObjectiveText1 = "'.$Value['ObjectiveText1'].'"'.' , ObjectiveText2 = "'.$Value['ObjectiveText2'].'"'.' , ObjectiveText3 = "'.$Value['ObjectiveText3'].'"'.' , ObjectiveText4 = "'.$Value['ObjectiveText4'].'"';
85 } else $set = '';
86 $this->System->Database->query('UPDATE `'.$this->Group['TablePrefix'].'` SET `VersionStart` = "'.$this->Version['BuildNumber'].'" '.$set.' WHERE `ID`='.$DbRowAfter['ID']);
87 echo('a ');
88
89 } else
90 {
91
92 if (isset($DbRowAfter['VersionStart'])) {
93 if ($DbRowAfter['VersionStart'] <= $this->Version['BuildNumber']) {
94 echo('Allready imported '.$DbRowBefore['Entry'].' ');
95 $insert = false;
96 }
97 }
98 if (isset($DbRowBefore['VersionEnd'])) {
99 if ($DbRowBefore['VersionEnd'] >= $this->Version['BuildNumber']) {
100 echo('Allready imported '.$DbRowBefore['Entry'].' ');
101 $inserted = false;
102 }
103 }
104
105 //if [DEPRECATED] do not import
106 foreach ($this->Group['Items'] as $GroupItem) {
107 if (false !== strpos($Value[$GroupItem['Column']],'[DEPRECATED')) {
108 echo('d '.$DbRowBefore['Entry'].' ');
109 $insert = false;
110 }
111 }
112
113 if ($insert) {
114 $insert = false;
115 foreach ($this->Group['Items'] as $GroupItem)
116 {
117 if ($Value[$GroupItem['Column']] <> '') $insert = true;
118 }
119 }
120
121 if (isset($DbRowMiddle['Entry'])) $insert = false;
122 if (isset($DbRowAfter['Entry'])) $Value['Entry'] = $DbRowAfter['Entry'];
123 if (isset($DbRowBefore['Entry'])) $Value['Entry'] = $DbRowBefore['Entry'];
124
125 if ($insert)
126 {
127
128 $Columns = '`Entry`, `Language`, `VersionStart`, `VersionEnd`';
129 $Values = $Value['Entry'].', 0, '.$this->Version['BuildNumber'].', '.$this->Version['BuildNumber'];
130 foreach ($this->Group['Items'] as $GroupItem)
131 {
132 $Columns .= ', `'.$GroupItem['Column'].'`';
133 $Values .= ', "'.$Value[$GroupItem['Column']].'"';
134 }
135 $this->System->Database->query('INSERT `'.$this->Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')');
136
137 echo '
138 '.$Value['Entry'].' = '.$DbRowBefore['VersionStart'].'.'.$DbRowBefore['VersionEnd'].'< '.$this->Version['BuildNumber'].' <'.$DbRowAfter['VersionStart'].'.'.$DbRowAfter['VersionEnd'].'... '.$DbRowMiddle['VersionStart'].' '.$DbRowMiddle['VersionEnd'].'
139 ';
140
141 if (false !== strpos($Values,'[DEPRECATED'))
142 echo $Values;
143
144 echo('# ');
145 $InsertId = $this->System->Database->insert_id;
146 $this->System->ModuleManager->Modules['Log']->WriteLog('Text <a href="form.php?group='.$this->Group['Id'].'&amp;ID='.$InsertId.'">'.$InsertId.'</a> ('.$Value['Entry'].') ze skupiny '.$this->Group['Name'].' byl v nové verzi '.$this->Version['Version'].' změněn.', LOG_TYPE_IMPORT);
147 }
148 }
149 } else
150 {
151 // Insert new text
152 if (is_numeric($Value[$this->Group['PrimaryKeyItem']])) $Value['Entry'] = $Value[$this->Group['PrimaryKeyItem']];
153 else
154 {
155 // Get new unused Entry for tables without numeric id
156 $Value['Entry'] = 1;
157 $DbResult = $this->System->Database->query('SELECT MAX(`Entry`) FROM `'.$this->Group['TablePrefix'].'`');
158 if ($DbResult->num_rows > 0)
159 {
160 $DbRow = $DbResult->fetch_row();
161 $Value['Entry'] += $DbRow[0];
162 }
163 }
164 $Columns = '`Entry`, `Language`, `VersionStart`, `VersionEnd`';
165 $Values = $Value['Entry'].', 0, '.$this->Version['BuildNumber'].', '.$this->Version['BuildNumber'];
166 $insert = false;
167 foreach ($this->Group['Items'] as $GroupItem)
168 {
169 $Columns .= ', `'.$GroupItem['Column'].'`';
170 $Values .= ', "'.$Value[$GroupItem['Column']].'"';
171 if ($Value[$GroupItem['Column']] <> '') $insert = true;
172 }
173 if ($insert) {
174 $this->System->Database->query('INSERT `'.$this->Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')');
175 $InsertId = $this->System->Database->insert_id;
176 echo('+ ');
177 $this->NewItemCount++;
178 $this->System->ModuleManager->Modules['Log']->WriteLog('Text <a href="form.php?group='.$this->Group['Id'].'&amp;ID='.$InsertId.'">'.$InsertId.'</a> ('.$Value['Entry'].') ze skupiny '.$this->Group['Name'].' byl v nové verzi '.$this->Version['Version'].' přidán.', LOG_TYPE_IMPORT);
179 }
180 }
181 }
182
183 function ImportLUA()
184 {
185 global $PatchVersion;
186
187 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
188 $Output = 'Načítání textů z LUA souboru...';
189
190 if (($this->Group['LuaFileName'] != '') and ($this->Group['TablePrefix'] != ''))
191 {
192
193 $Output .= '<br />'.$this->Group['Name'].'<br />';
194 // if ($this->Group['LastVersion'] < $this->Version['BuildNumber'] + 1)
195 {
196 $File = new FileStream();
197
198 $File->OpenFile(dirname(__FILE__).'/../../source/'.$this->Version['Version'].'/lua/'.$this->Group['LuaFileName'].'.lua');
199 $this->NewItemCount = 0;
200 $Count = 0;
201 while (!$File->EOF())
202 {
203 $Line = $File->ReadLine();
204 if (strpos($Line, '=') !== false)
205 {
206 $LineParts = explode('=', $Line, 2);
207 $Value['ShortCut'] = trim($LineParts[0]);
208 $Line = trim($LineParts[1]);
209 if ($Line[0] == '"')
210 {
211 // Quoted string value
212 $Line = substr($Line, 1); // Skip start qoute
213 $TempLine = str_replace('\"', ' ', $Line); // Temporary remove slashed quotes
214 $Value['Text'] = substr($Line, 0, strpos($TempLine, '"'));
215 $Value['Text'] = str_replace('\n', "\n", $Value['Text']);
216 $Value['Text'] = addslashes(stripslashes($Value['Text']));
217 $Line = trim(substr($Line, strpos($TempLine, '"') + 1)); // Skip closing quote and semicolon
218 } else
219 {
220 // Nonstring value
221 $Value['Text'] = substr($Line, 0, strpos($Line, ';'));
222 }
223 $Line = substr($Line, strpos($Line, ';') + 1);
224 $Value['Comment'] = addslashes(stripslashes(substr($Line, 3))); // Skip " --"
225
226 $this->InsertItem($Value);
227 };
228 $Count++;
229 }
230 $Output .= '<br />Celkem: '.$Count.' Nových: '.$this->NewItemCount.'<br />';
231 $this->UpdateLastVersion();
232 }
233 // else $Output .= ShowMessage('Již importován pro verzi '.$this->Version['Version'], MESSAGE_CRITICAL);
234 } else $Output .= ShowMessage('Není definováno jméno zdrojového souboru', MESSAGE_CRITICAL);
235 $Output .= ShowMessage('Dokončeno.');
236 return $Output;
237 }
238
239 function UpdateTranslated()
240 {
241 global $PatchVersion, $Config;
242
243 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
244 $Output = '<br /><br />Začínám se synchronizací VersionEnd u přeložených textů<br />';
245 foreach ($TranslationTree as $Group)
246 {
247 $Output .= '<br />'.$Group['Name'].' ';
248 $do = true;
249 while ($do)
250 {
251 $DbResult = $this->System->Database->query('SELECT `gs_tran`.`ID`, '.
252 '`gs_tran`.`VersionEnd` AS `VersionEnd_tran`, '.
253 '`gs_tran`.`VersionStart` AS `VersionStart_tran`, '.
254 '`gs_orig`.`VersionEnd` AS `VersionEnd_orig`, '.
255 '`gs_orig`.`VersionStart` AS `VersionStart_orig` FROM `'.
256 $Group['TablePrefix'].'` AS `gs_tran` JOIN `'.$Group['TablePrefix'].
257 '` AS `gs_orig` ON `gs_orig`.`ID` = `gs_tran`.`Take` WHERE '.
258 '`gs_tran`.`VersionEnd` <> `gs_orig`.`VersionEnd` OR `gs_tran`.`VersionStart` <> `gs_orig`.`VersionStart`');
259 $do = ($DbResult->num_rows > 0);
260 while ($DbRow = $DbResult->fetch_assoc())
261 {
262 echo('`');
263 $this->System->Database->query('UPDATE `'.$Group['TablePrefix'].'` SET `VersionEnd` = '.$DbRow['VersionEnd_orig'].', `VersionStart` = '.$DbRow['VersionStart_orig'].' WHERE `ID` = '.$DbRow['ID']);
264 $Output .= '. ';
265 }
266 }
267 $Output .= '<strong>Dokončeno.</strong>';
268 }
269 return $Output;
270 }
271
272 function HaveSameText($Group, $DbRow2, $Value)
273 {
274 $result = true;
275 foreach ($Group['Items'] as $GroupItem)
276 {
277 $old = $DbRow2[$GroupItem['Column']];
278 $old = str_replace(chr(10), '', $old);
279 $old = str_replace(chr(13), '', $old);
280 $old = str_replace('\n', '', $old);
281 $old = str_replace('\r', '', $old);
282 $old = str_replace('\"', '"', $old);
283 $old = str_replace('\\\\', '\\', $old);
284 $old = str_replace('\32', '32', $old);
285 $old = str_replace('\124', '124', $old);
286 $old = str_replace("\'", "'", $old);
287 $old = str_replace("Â", "", $old);
288 $old = str_replace("�", "", $old);
289 $old = str_replace('-', '', $old);
290 $old = str_replace(' ', '', $old);
291 $old = strtolower($old);
292 $old = str_replace('$b', '', $old);
293
294 if ($this->Group['Id'] == 1)
295 while ($part = substr($old, strpos($old, '<'), strpos($old, '>')-strpos($old, '<')))
296 if ($part <> '') {
297 $old = str_replace($part.'>', '', $old);
298 }
299
300 if (($GroupItem['MangosColumn'] <> '') and ($Group['MangosDatabase'] == 'mangos'))
301 $new = $Value[$GroupItem['MangosColumn']];
302 else $new = $Value[$GroupItem['Column']];
303
304 $new = str_replace(chr(10), '', $new);
305 $new = str_replace(chr(13), '', $new);
306 $new = str_replace('\n', '', $new);
307 $new = str_replace('\r', '', $new);
308 $new = str_replace('\"', '"', $new);
309 $new = str_replace('\\\\', '\\', $new);
310 $new = str_replace('\32', '32', $new);
311 $new = str_replace('\124', '124', $new);
312 $new = str_replace("\'", "'", $new);
313 $new = str_replace("Â", "", $new);
314 $new = str_replace("�", "", $new);
315 $new = str_replace('-', '', $new);
316 $new = str_replace(' ', '', $new);
317 $new = strtolower($new);
318 $new = str_replace('$b', '', $new);
319
320 if ($this->Group['Id'] == 1)
321 while ($part = substr($new, strpos($new, '<'), strpos($new, '>')-strpos($new, '<')))
322 if ($part <> '') {
323 $new = str_replace($part.'>', '', $new);
324 }
325
326 if (($old == 'null') or ($old == 'NULL')) $old = '';
327 if (($new == 'null') or ($new == 'NULL')) $new = '';
328
329 if (($new <> '') and ($old <> $new) and ($GroupItem['Column'] <> 'Comment'))
330 {
331 // echo $old.'X'.$new;
332 if ( ($GroupItem['Column'] <> 'EndText')
333 and ($GroupItem['Column'] <> 'ObjectiveText1')
334 and ($GroupItem['Column'] <> 'ObjectiveText2')
335 and ($GroupItem['Column'] <> 'ObjectiveText3')
336 and ($GroupItem['Column'] <> 'ObjectiveText4') )
337 $result = false;
338 }
339 }
340
341 return $result;
342 }
343
344 function ImportDBC()
345 {
346 global $System, $Config;
347
348 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
349 $Output = 'Načítání textů z DBC souboru...';
350 if (($this->Group['DBCFileName'] != '') and ($this->Group['TablePrefix'] != ''))
351 {
352 $Output .= '<br />'.$this->Group['Name'].'<br />';
353
354 // Load string column index list
355 $DbResult = $System->Database->query('SELECT * FROM `GroupItem` JOIN `GroupItemDBC` ON `GroupItem`.`Id` = `GroupItemDBC`.`GroupItem` AND `GroupItemDBC`.`ClientVersion` = '.$this->Version['Id'].' WHERE `GroupItem`.`Group` = '.$this->Group['Id']);
356
357 $ColumnIndexes = array();
358 $ColumnFormat = array();
359 while ($DbRow = $DbResult->fetch_assoc())
360 {
361 $ColumnFormat[$DbRow['ColumnIndex']] = FORMAT_STRING;
362 $ColumnIndexes[$DbRow['GroupItem']] = $DbRow['ColumnIndex'];
363 }
364
365 $DBCFile = new DBCFile();
366 $DBCFile->OpenFile(dirname(__FILE__).'/../../source/'.$this->Version['Version'].'/dbc/'.$this->Group['DBCFileName'].'.dbc', $ColumnFormat);
367 $ItemCount = $DBCFile->GetRecordCount();
368 $this->NewItemCount = 0;
369 $Count = 0;
370
371 for ($I = 0; $I < $ItemCount; $I++)
372 {
373 foreach ($this->Group['Items'] as $GroupItem)
374 if (array_key_exists($GroupItem['Id'], $ColumnIndexes))
375 {
376 $Value[$GroupItem['Column']] = addslashes($DBCFile->GetString($I, $ColumnIndexes[$GroupItem['Id']]));
377 }
378
379 // Get multicolumn value
380 $Columns = explode(',', $this->Group['DBCIndex']);
381 $ColumnValue = '';
382 foreach ($Columns as $Column)
383 $ColumnValue .= '_'.$DBCFile->GetUint($I, $Column);
384 $ColumnValue = substr($ColumnValue, 1);
385 $Value[$this->Group['PrimaryKeyItem']] = $ColumnValue;
386 $this->InsertItem($Value);
387 $Count++;
388 }
389 $Output .= '<br />Celkem: '.$Count.' Nových: '.$this->NewItemCount.'<br />';
390 $this->UpdateLastVersion();
391 }
392 $Output .= '<strong>Dokončeno.</strong>';
393 return $Output;
394 }
395
396 function ImportGroup($GroupId)
397 {
398 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
399
400 $this->Group = $TranslationTree[$GroupId];
401
402 if ($this->Group['SourceType'] == 'dbc') $Output = $this->ImportDBC();
403 else if ($this->Group['SourceType'] == 'sql') $Output = $this->ImportSQL();
404 else if ($this->Group['SourceType'] == 'lua') $Output = $this->ImportLUA();
405 else $Output = ShowMessage('Neznámý typ zdroje pro import', MESSAGE_CRITICAL);
406 $Output .= $this->UpdateTranslated();
407 return $Output;
408 }
409
410 function ImportSQL()
411 {
412 global $PatchVersion;
413
414 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
415 $Output = '';
416 $File = new FileStream();
417 $File->OpenFile(dirname(__FILE__).'/../../source/'.$this->Version['Version'].'/sql/'.$this->Group['MangosTable'].'.sql');
418 $this->NewItemCount = 0;
419 $Count = 0;
420 $folow_structure = false;
421 $i = 0;
422 while ((!$File->EOF()))
423 {
424 $Line = $File->ReadLine();
425 // Struktura
426 if (strpos($Line, 'CREATE TABLE `'.$this->Group['MangosTable'].'`') !== false)
427 {
428 $Line = '';
429 $folow_structure = true;
430 $i = 0;
431 }
432 if ((strpos($Line, ';') !== false) and ($folow_structure == true))
433 {
434 $folow_structure = false;
435 // echo ('Struktura: <br />');
436 // print_r($structure);
437 // echo ('<br /><br />');
438 }
439 if (($folow_structure == true) and ($Line != ''))
440 {
441 $str = substr($Line, 0, strpos($Line, '`'));
442 $Line = substr($Line, strpos($Line, '`') + 1);
443 $Line = substr($Line, 0, strpos($Line, '`'));
444 if (strlen($str) < 3) $structure[$i] = $Line;
445 $i++;
446 }
447
448 //data
449 if ((strpos($Line, 'INSERT INTO `'.$this->Group['MangosTable'].'`') !== false) and (isset($structure)))
450 {
451 while ((strpos($Line, ');') === false) or ($File->EOF()))
452 $Line = $Line.$File->ReadLine();
453 $Line = str_replace("),\n(", '),(', $Line);
454
455 $Line = substr($Line, strpos($Line, '(') + 1);
456 $Line = substr($Line, 0, strpos($Line, ');'));
457 $LineParts = explode('),(', $Line);
458
459 unset($Line);
460
461 $value_buff = '';
462 $Value = '';
463 foreach ($LineParts as $LinePart)
464 {
465
466 unset($Value, $value_buff);
467 foreach ($structure as $i => $column)
468 {
469 if (substr($LinePart, 0, 1) != "'")
470 {
471 $value_buff = substr($LinePart, 0, strpos($LinePart, ','));
472 $LinePart = substr($LinePart, strlen($value_buff) + 1);
473 } else
474 {
475 $LinePart = substr($LinePart, 1);
476 $value_buff = substr($LinePart, 0, strpos($LinePart, "'"));
477 while (substr($value_buff, strlen($value_buff) - 1, 1) == "\\")
478 {
479 $str = substr($LinePart, strlen($value_buff));
480 $str2 = substr($str, 0, strpos($str, "'", 1));
481 $value_buff = $value_buff.$str2;
482 $str = substr($str, strlen($str2));
483 }
484 $LinePart = substr($LinePart, strlen($value_buff) + 2);
485 }
486 if (($value_buff != 'null') and ($value_buff != 'NULL'))
487 {
488 $str = '';
489 while (substr($value_buff, strlen($value_buff) - 1,1) == " ")
490 {
491 $value_buff = substr($value_buff, 0, strlen($value_buff) - 1);
492 $str .= ' ';
493 }
494 $str2 = '';
495 while (substr($value_buff, 0, 1) == ' ')
496 {
497 $value_buff = substr($value_buff, 1, strlen($value_buff) - 1);
498 $str2 .= ' ';
499 }
500 $Value[$column] = $str2.trim($value_buff).$str;
501 } else
502 {
503 $Value[$column] = '';
504 }
505 // echo ($column.'-"'.$Value[$column].'"<br>');
506 }
507 foreach ($this->Group['Items'] as $GroupItem)
508 {
509 if ($GroupItem['MangosColumn'] != '')
510 if (isset($Value[$GroupItem['MangosColumn']]))
511 $Value[$GroupItem['Column']] = $Value[$GroupItem['MangosColumn']];
512 else {
513 $Value[$GroupItem['Column']] = '';
514 $Value[$GroupItem['MangosColumn']] ='';
515 }
516 }
517
518 // Get multicolumn value
519 $Columns = explode(',', $this->Group['MangosTableIndex']);
520 $ColumnValue = '';
521 foreach ($Columns as $Column)
522 $ColumnValue .= '_'.$Value[$Column];
523 $ColumnValue = substr($ColumnValue, 1);
524 $Value[$this->Group['PrimaryKeyItem']] = $ColumnValue;
525 $this->InsertItem($Value);
526 $Count++;
527 }
528 }
529 }
530 $Output = '<br />Celkem: '.$Count.' Nových: '.$this->NewItemCount.'<br />';
531 $this->UpdateLastVersion();
532 return $Output;
533 }
534
535 function UpdateLastVersion() {
536 $DbResult = $this->System->Database->query('SELECT * FROM `Group` WHERE `Id`='.$this->Group['Id']);
537 $Version = $DbResult->fetch_assoc();
538 if ($Version['LastVersion'] < $this->Version['BuildNumber'])
539 $this->System->Database->query('UPDATE `Group` SET `LastVersion` = "'.$this->Version['BuildNumber'].'", `LastImport` = NOW() WHERE `Id`='.$this->Group['Id']);
540 }
541}
Note: See TracBrowser for help on using the repository browser.