Changeset 880 for trunk/Modules/Import
- Timestamp:
- Apr 7, 2020, 10:15:48 PM (5 years ago)
- Location:
- trunk/Modules/Import
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Import/Import.php
r859 r880 49 49 $Columns = ''; 50 50 //$Values = ''; 51 foreach ($this->Group['Items'] as $GroupItem)51 foreach ($this->Group['Items'] as $GroupItem) 52 52 { 53 53 $Columns .= ', `'.$GroupItem['Column'].'` '; … … 61 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 62 63 if (($DbResultMiddle->num_rows > 0) or ($DbResultBefore->num_rows > 0) or ($DbResultAfter->num_rows > 0))63 if (($DbResultMiddle->num_rows > 0) or ($DbResultBefore->num_rows > 0) or ($DbResultAfter->num_rows > 0)) 64 64 { 65 65 // Update existed text … … 68 68 $DbRowBefore = $DbResultBefore->fetch_assoc(); 69 69 70 if ($this->HaveSameText($this->Group, $DbRowBefore, $Value) and ($DbResultBefore->num_rows > 0) )70 if ($this->HaveSameText($this->Group, $DbRowBefore, $Value) and ($DbResultBefore->num_rows > 0) ) 71 71 { 72 72 $insert = false; … … 78 78 79 79 } else 80 if ($this->HaveSameText($this->Group, $DbRowAfter, $Value) and ($DbResultAfter->num_rows > 0))80 if ($this->HaveSameText($this->Group, $DbRowAfter, $Value) and ($DbResultAfter->num_rows > 0)) 81 81 { 82 82 $insert = false; … … 104 104 105 105 //if [DEPRECATED] do not import 106 foreach ($this->Group['Items'] as $GroupItem) {106 foreach ($this->Group['Items'] as $GroupItem) { 107 107 if (false !== strpos($Value[$GroupItem['Column']],'[DEPRECATED')) { 108 108 echo('d '.$DbRowBefore['Entry'].' '); … … 113 113 if ($insert) { 114 114 $insert = false; 115 foreach ($this->Group['Items'] as $GroupItem)115 foreach ($this->Group['Items'] as $GroupItem) 116 116 { 117 117 if ($Value[$GroupItem['Column']] <> '') $insert = true; … … 128 128 $Columns = '`Entry`, `Language`, `VersionStart`, `VersionEnd`'; 129 129 $Values = $Value['Entry'].', 0, '.$this->Version['BuildNumber'].', '.$this->Version['BuildNumber']; 130 foreach ($this->Group['Items'] as $GroupItem)130 foreach ($this->Group['Items'] as $GroupItem) 131 131 { 132 132 $Columns .= ', `'.$GroupItem['Column'].'`'; … … 150 150 { 151 151 // Insert new text 152 if (is_numeric($Value[$this->Group['PrimaryKeyItem']])) $Value['Entry'] = $Value[$this->Group['PrimaryKeyItem']];152 if (is_numeric($Value[$this->Group['PrimaryKeyItem']])) $Value['Entry'] = $Value[$this->Group['PrimaryKeyItem']]; 153 153 else 154 154 { … … 156 156 $Value['Entry'] = 1; 157 157 $DbResult = $this->System->Database->query('SELECT MAX(`Entry`) FROM `'.$this->Group['TablePrefix'].'`'); 158 if ($DbResult->num_rows > 0)158 if ($DbResult->num_rows > 0) 159 159 { 160 160 $DbRow = $DbResult->fetch_row(); … … 165 165 $Values = $Value['Entry'].', 0, '.$this->Version['BuildNumber'].', '.$this->Version['BuildNumber']; 166 166 $insert = false; 167 foreach ($this->Group['Items'] as $GroupItem)167 foreach ($this->Group['Items'] as $GroupItem) 168 168 { 169 169 $Columns .= ', `'.$GroupItem['Column'].'`'; … … 188 188 $Output = 'Načítání textů z LUA souboru...'; 189 189 190 if (($this->Group['LuaFileName'] != '') and ($this->Group['TablePrefix'] != ''))190 if (($this->Group['LuaFileName'] != '') and ($this->Group['TablePrefix'] != '')) 191 191 { 192 192 193 193 $Output .= '<br />'.$this->Group['Name'].'<br />'; 194 // if ($this->Group['LastVersion'] < $this->Version['BuildNumber'] + 1)194 // if ($this->Group['LastVersion'] < $this->Version['BuildNumber'] + 1) 195 195 { 196 196 $File = new FileStream(); … … 199 199 $this->NewItemCount = 0; 200 200 $Count = 0; 201 while (!$File->EOF())201 while (!$File->EOF()) 202 202 { 203 203 $Line = $File->ReadLine(); 204 if (strpos($Line, '=') !== false)204 if (strpos($Line, '=') !== false) 205 205 { 206 206 $LineParts = explode('=', $Line, 2); 207 207 $Value['ShortCut'] = trim($LineParts[0]); 208 208 $Line = trim($LineParts[1]); 209 if ($Line[0] == '"')209 if ($Line[0] == '"') 210 210 { 211 211 // Quoted string value … … 234 234 } else $Output .= ShowMessage('Není definováno jméno zdrojového souboru', MESSAGE_CRITICAL); 235 235 $Output .= ShowMessage('Dokončeno.'); 236 return ($Output);236 return $Output; 237 237 } 238 238 … … 243 243 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); 244 244 $Output = '<br /><br />Začínám se synchronizací VersionEnd u přeložených textů<br />'; 245 foreach ($TranslationTree as $Group)245 foreach ($TranslationTree as $Group) 246 246 { 247 247 $Output .= '<br />'.$Group['Name'].' '; 248 248 $do = true; 249 while ($do)249 while ($do) 250 250 { 251 251 $DbResult = $this->System->Database->query('SELECT `gs_tran`.`ID`, '. … … 258 258 '`gs_tran`.`VersionEnd` <> `gs_orig`.`VersionEnd` OR `gs_tran`.`VersionStart` <> `gs_orig`.`VersionStart`'); 259 259 $do = ($DbResult->num_rows > 0); 260 while ($DbRow = $DbResult->fetch_assoc())260 while ($DbRow = $DbResult->fetch_assoc()) 261 261 { 262 262 echo('`'); … … 267 267 $Output .= '<strong>Dokončeno.</strong>'; 268 268 } 269 return ($Output);269 return $Output; 270 270 } 271 271 … … 273 273 { 274 274 $result = true; 275 foreach ($Group['Items'] as $GroupItem)275 foreach ($Group['Items'] as $GroupItem) 276 276 { 277 277 $old = $DbRow2[$GroupItem['Column']]; … … 324 324 } 325 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'))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 330 { 331 331 // echo $old.'X'.$new; … … 339 339 } 340 340 341 return ($result);341 return $result; 342 342 } 343 343 … … 348 348 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); 349 349 $Output = 'Načítání textů z DBC souboru...'; 350 if (($this->Group['DBCFileName'] != '') and ($this->Group['TablePrefix'] != ''))350 if (($this->Group['DBCFileName'] != '') and ($this->Group['TablePrefix'] != '')) 351 351 { 352 352 $Output .= '<br />'.$this->Group['Name'].'<br />'; … … 357 357 $ColumnIndexes = array(); 358 358 $ColumnFormat = array(); 359 while ($DbRow = $DbResult->fetch_assoc())359 while ($DbRow = $DbResult->fetch_assoc()) 360 360 { 361 361 $ColumnFormat[$DbRow['ColumnIndex']] = FORMAT_STRING; … … 369 369 $Count = 0; 370 370 371 for ($I = 0; $I < $ItemCount; $I++)372 { 373 foreach ($this->Group['Items'] as $GroupItem)374 if (array_key_exists($GroupItem['Id'], $ColumnIndexes))371 for ($I = 0; $I < $ItemCount; $I++) 372 { 373 foreach ($this->Group['Items'] as $GroupItem) 374 if (array_key_exists($GroupItem['Id'], $ColumnIndexes)) 375 375 { 376 376 $Value[$GroupItem['Column']] = addslashes($DBCFile->GetString($I, $ColumnIndexes[$GroupItem['Id']])); … … 380 380 $Columns = explode(',', $this->Group['DBCIndex']); 381 381 $ColumnValue = ''; 382 foreach ($Columns as $Column)382 foreach ($Columns as $Column) 383 383 $ColumnValue .= '_'.$DBCFile->GetUint($I, $Column); 384 384 $ColumnValue = substr($ColumnValue, 1); … … 391 391 } 392 392 $Output .= '<strong>Dokončeno.</strong>'; 393 return ($Output);393 return $Output; 394 394 } 395 395 … … 400 400 $this->Group = $TranslationTree[$GroupId]; 401 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();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 405 else $Output = ShowMessage('Neznámý typ zdroje pro import', MESSAGE_CRITICAL); 406 406 $Output .= $this->UpdateTranslated(); 407 return ($Output);407 return $Output; 408 408 } 409 409 … … 420 420 $folow_structure = false; 421 421 $i = 0; 422 while ((!$File->EOF()))422 while ((!$File->EOF())) 423 423 { 424 424 $Line = $File->ReadLine(); 425 425 // Struktura 426 if (strpos($Line, 'CREATE TABLE `'.$this->Group['MangosTable'].'`') !== false)426 if (strpos($Line, 'CREATE TABLE `'.$this->Group['MangosTable'].'`') !== false) 427 427 { 428 428 $Line = ''; … … 430 430 $i = 0; 431 431 } 432 if ((strpos($Line, ';') !== false) and ($folow_structure == true))432 if ((strpos($Line, ';') !== false) and ($folow_structure == true)) 433 433 { 434 434 $folow_structure = false; … … 437 437 // echo ('<br /><br />'); 438 438 } 439 if (($folow_structure == true) and ($Line != ''))439 if (($folow_structure == true) and ($Line != '')) 440 440 { 441 441 $str = substr($Line, 0, strpos($Line, '`')); 442 442 $Line = substr($Line, strpos($Line, '`') + 1); 443 443 $Line = substr($Line, 0, strpos($Line, '`')); 444 if (strlen($str) < 3) $structure[$i] = $Line;444 if (strlen($str) < 3) $structure[$i] = $Line; 445 445 $i++; 446 446 } 447 447 448 448 //data 449 if ((strpos($Line, 'INSERT INTO `'.$this->Group['MangosTable'].'`') !== false) and (isset($structure)))449 if ((strpos($Line, 'INSERT INTO `'.$this->Group['MangosTable'].'`') !== false) and (isset($structure))) 450 450 { 451 451 while ((strpos($Line, ');') === false) or ($File->EOF())) … … 461 461 $value_buff = ''; 462 462 $Value = ''; 463 foreach ($LineParts as $LinePart)463 foreach ($LineParts as $LinePart) 464 464 { 465 465 466 466 unset($Value, $value_buff); 467 foreach ($structure as $i => $column)467 foreach ($structure as $i => $column) 468 468 { 469 469 if (substr($LinePart, 0, 1) != "'") … … 475 475 $LinePart = substr($LinePart, 1); 476 476 $value_buff = substr($LinePart, 0, strpos($LinePart, "'")); 477 while (substr($value_buff, strlen($value_buff) - 1, 1) == "\\")477 while (substr($value_buff, strlen($value_buff) - 1, 1) == "\\") 478 478 { 479 479 $str = substr($LinePart, strlen($value_buff)); … … 484 484 $LinePart = substr($LinePart, strlen($value_buff) + 2); 485 485 } 486 if (($value_buff != 'null') and ($value_buff != 'NULL'))486 if (($value_buff != 'null') and ($value_buff != 'NULL')) 487 487 { 488 488 $str = ''; 489 while (substr($value_buff, strlen($value_buff) - 1,1) == " ")489 while (substr($value_buff, strlen($value_buff) - 1,1) == " ") 490 490 { 491 491 $value_buff = substr($value_buff, 0, strlen($value_buff) - 1); … … 493 493 } 494 494 $str2 = ''; 495 while (substr($value_buff, 0, 1) == ' ')495 while (substr($value_buff, 0, 1) == ' ') 496 496 { 497 497 $value_buff = substr($value_buff, 1, strlen($value_buff) - 1); … … 505 505 // echo ($column.'-"'.$Value[$column].'"<br>'); 506 506 } 507 foreach ($this->Group['Items'] as $GroupItem)507 foreach ($this->Group['Items'] as $GroupItem) 508 508 { 509 if ($GroupItem['MangosColumn'] != '')509 if ($GroupItem['MangosColumn'] != '') 510 510 if (isset($Value[$GroupItem['MangosColumn']])) 511 511 $Value[$GroupItem['Column']] = $Value[$GroupItem['MangosColumn']]; … … 519 519 $Columns = explode(',', $this->Group['MangosTableIndex']); 520 520 $ColumnValue = ''; 521 foreach ($Columns as $Column)521 foreach ($Columns as $Column) 522 522 $ColumnValue .= '_'.$Value[$Column]; 523 523 $ColumnValue = substr($ColumnValue, 1); … … 530 530 $Output = '<br />Celkem: '.$Count.' Nových: '.$this->NewItemCount.'<br />'; 531 531 $this->UpdateLastVersion(); 532 return ($Output);532 return $Output; 533 533 } 534 534 -
trunk/Modules/Import/Manage.php
r859 r880 19 19 '<li>Po provedení importu je potřeba několikrát spustit skript na aktualizaci verze u překladu. Je potřeba ho provádět opakovaně dokud nezmizí tečky označující, že byly provedeny změny.</li>'. 20 20 '</ol>'; 21 return ($Output);21 return $Output; 22 22 } 23 23 … … 26 26 global $System; 27 27 28 if (array_key_exists('id', $_GET))28 if (array_key_exists('id', $_GET)) 29 29 { 30 30 $Output = '<div style="font-size: xx-small;">'; … … 38 38 $Output .= '</div>'; 39 39 } else $Output = ShowMessage('Nebylo zadáno id skupiny.', MESSAGE_CRITICAL); 40 return ($Output);40 return $Output; 41 41 } 42 42 … … 68 68 69 69 $DbResult = $this->System->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']); 70 while ($Group = $DbResult->fetch_assoc())70 while ($Group = $DbResult->fetch_assoc()) 71 71 { 72 72 $Output .= '<tr><td>'.T($Group['Name']).'</td>'. 73 73 '<td>'.$Group['SourceType'].'</td><td>'; 74 if ($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql ';75 if ($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc ';76 if ($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua ';74 if ($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql '; 75 if ($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc '; 76 if ($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua '; 77 77 $Output .= '</td>'. 78 78 '<td><a title="Změny po posledním importu u vybrané překladové skupiny" href="../log/?group='.$Group['Id'].'&type=11">'.HumanDate($Group['LastImport']).'</a></td>'. … … 82 82 } 83 83 $Output .= '</table>'; 84 return ($Output);84 return $Output; 85 85 } 86 86 … … 93 93 $Output .= $Import->UpdateTranslated(); 94 94 $Output .= '</div>'; 95 return ($Output);95 return $Output; 96 96 } 97 97 … … 100 100 $this->Title = T('Import'); 101 101 $Output = ''; 102 if ($this->System->User->Licence(LICENCE_ADMIN))102 if ($this->System->User->Licence(LICENCE_ADMIN)) 103 103 { 104 if (array_key_exists('action', $_GET))104 if (array_key_exists('action', $_GET)) 105 105 { 106 if ($_GET['action'] == 'instructions') $Output .= $this->ShowInstructions();107 else if ($_GET['action'] == 'importgroup') $Output .= $this->ShowImportGroup();108 else if ($_GET['action'] == 'update_translated') $Output .= $this->UpdateTranslated();106 if ($_GET['action'] == 'instructions') $Output .= $this->ShowInstructions(); 107 else if ($_GET['action'] == 'importgroup') $Output .= $this->ShowImportGroup(); 108 else if ($_GET['action'] == 'update_translated') $Output .= $this->UpdateTranslated(); 109 109 else $Output .= $this->ShowMenu(); 110 110 } else $Output .= $this->ShowMenu(); 111 111 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 112 return ($Output);112 return $Output; 113 113 } 114 114 } -
trunk/Modules/Import/cmd.php
r859 r880 13 13 $Output = ''; 14 14 15 if (defined('STDIN') == false)15 if (defined('STDIN') == false) 16 16 { 17 17 $Output = T('Access denied'); … … 19 19 } 20 20 21 foreach ($_SERVER['argv'] as $parameter)21 foreach ($_SERVER['argv'] as $parameter) 22 22 { 23 if (strpos($parameter, '=') !== false)23 if (strpos($parameter, '=') !== false) 24 24 { 25 25 $index = substr($parameter, 0, strpos($parameter, '=')); … … 30 30 } 31 31 32 if (!array_key_exists('id', $_GET))32 if (!array_key_exists('id', $_GET)) 33 33 { 34 34 $Output .= ' … … 49 49 $Output .= ' version=<version> - nastaví verzi importu default: '.$System->Config['Web']['GameVersion'].'<br /><br />'; 50 50 $Output .= ' <id_import_group>:'; 51 foreach ($TranslationTree as $Group)51 foreach ($TranslationTree as $Group) 52 52 { 53 53 $Output .= '<br /> '.$Group['Id'].' '; -
trunk/Modules/Import/generatecodeXML.php
r815 r880 30 30 31 31 $files = scandir($verze); 32 foreach ($files as $file)32 foreach ($files as $file) 33 33 { 34 34 $end = substr($file, strlen($file) - 3); 35 if ($end == 'xml')35 if ($end == 'xml') 36 36 { 37 37 echo('<br />--'.$file.'<br /><br />');
Note:
See TracChangeset
for help on using the changeset viewer.