Changeset 894 for trunk/Modules/Import
- Timestamp:
- Mar 6, 2023, 12:16:38 PM (3 years ago)
- Location:
- trunk/Modules/Import
- Files:
-
- 2 edited
-
Import.php (modified) (23 diffs)
-
generatecodeXML.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Import/Import.php
r888 r894 3 3 include_once(dirname(__FILE__).'/../../includes/dbc.php'); 4 4 include_once(dirname(__FILE__).'/Manage.php'); 5 6 5 7 6 class ModuleImport extends Module … … 38 37 function SetVersion($Version) 39 38 { 40 global $System; 41 42 $DbResult = $System->Database->query('SELECT * FROM `ClientVersion` WHERE `Version` = "'.$Version.'"'); 39 $DbResult = $this->System->Database->query('SELECT * FROM `ClientVersion` WHERE `Version` = "'.$Version.'"'); 43 40 $this->Version = $DbResult->fetch_assoc(); 44 41 } … … 68 65 $DbRowBefore = $DbResultBefore->fetch_assoc(); 69 66 70 if ($this->HaveSameText($this->Group, $DbRowBefore, $Value) and ($DbResultBefore->num_rows > 0) )67 if ($this->HaveSameText($this->Group, $DbRowBefore, $Value) and ($DbResultBefore->num_rows > 0)) 71 68 { 72 69 $insert = false; 73 if ($this->Group['Id'] == 1) { 70 if ($this->Group['Id'] == 1) 71 { 74 72 $set = ' , EndText = "'.$Value['EndText'].'" , ObjectiveText1 = "'.$Value['ObjectiveText1'].'"'.' , ObjectiveText2 = "'.$Value['ObjectiveText2'].'"'.' , ObjectiveText3 = "'.$Value['ObjectiveText3'].'"'.' , ObjectiveText4 = "'.$Value['ObjectiveText4'].'"'; 75 73 } else $set = ''; … … 80 78 if ($this->HaveSameText($this->Group, $DbRowAfter, $Value) and ($DbResultAfter->num_rows > 0)) 81 79 { 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 80 $insert = false; 81 if ($this->Group['Id'] == 1) 82 { 83 $set = ' , EndText = "'.$Value['EndText'].'" , ObjectiveText1 = "'.$Value['ObjectiveText1'].'"'.' , ObjectiveText2 = "'.$Value['ObjectiveText2'].'"'.' , ObjectiveText3 = "'.$Value['ObjectiveText3'].'"'.' , ObjectiveText4 = "'.$Value['ObjectiveText4'].'"'; 84 } else $set = ''; 85 $this->System->Database->query('UPDATE `'.$this->Group['TablePrefix'].'` SET `VersionStart` = "'.$this->Version['BuildNumber'].'" '.$set.' WHERE `ID`='.$DbRowAfter['ID']); 86 echo('a '); 89 87 } else 90 88 { 91 92 if (isset($DbRowAfter['VersionStart'])) { 93 if ($DbRowAfter['VersionStart'] <= $this->Version['BuildNumber']) { 89 if (isset($DbRowAfter['VersionStart'])) 90 { 91 if ($DbRowAfter['VersionStart'] <= $this->Version['BuildNumber']) 92 { 94 93 echo('Allready imported '.$DbRowBefore['Entry'].' '); 95 94 $insert = false; 96 95 } 97 96 } 98 if (isset($DbRowBefore['VersionEnd'])) { 99 if ($DbRowBefore['VersionEnd'] >= $this->Version['BuildNumber']) { 97 if (isset($DbRowBefore['VersionEnd'])) 98 { 99 if ($DbRowBefore['VersionEnd'] >= $this->Version['BuildNumber']) 100 { 100 101 echo('Allready imported '.$DbRowBefore['Entry'].' '); 101 102 $inserted = false; … … 103 104 } 104 105 105 //if [DEPRECATED] do not import 106 foreach ($this->Group['Items'] as $GroupItem) { 107 if (false !== strpos($Value[$GroupItem['Column']],'[DEPRECATED')) { 106 // if [DEPRECATED] do not import 107 foreach ($this->Group['Items'] as $GroupItem) 108 { 109 if (false !== strpos($Value[$GroupItem['Column']],'[DEPRECATED')) 110 { 108 111 echo('d '.$DbRowBefore['Entry'].' '); 109 112 $insert = false; … … 111 114 } 112 115 113 if ($insert) { 116 if ($insert) 117 { 114 118 $insert = false; 115 119 foreach ($this->Group['Items'] as $GroupItem) … … 125 129 if ($insert) 126 130 { 127 128 131 $Columns = '`Entry`, `Language`, `VersionStart`, `VersionEnd`'; 129 132 $Values = $Value['Entry'].', 0, '.$this->Version['BuildNumber'].', '.$this->Version['BuildNumber']; … … 135 138 $this->System->Database->query('INSERT `'.$this->Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 136 139 137 echo '140 echo(' 138 141 '.$Value['Entry'].' = '.$DbRowBefore['VersionStart'].'.'.$DbRowBefore['VersionEnd'].'< '.$this->Version['BuildNumber'].' <'.$DbRowAfter['VersionStart'].'.'.$DbRowAfter['VersionEnd'].'... '.$DbRowMiddle['VersionStart'].' '.$DbRowMiddle['VersionEnd'].' 139 ' ;142 '); 140 143 141 144 if (false !== strpos($Values,'[DEPRECATED')) 142 echo $Values;145 echo($Values); 143 146 144 147 echo('# '); … … 171 174 if ($Value[$GroupItem['Column']] <> '') $insert = true; 172 175 } 173 if ($insert) { 176 if ($insert) 177 { 174 178 $this->System->Database->query('INSERT `'.$this->Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 175 179 $InsertId = $this->System->Database->insert_id; … … 183 187 function ImportLUA() 184 188 { 185 global $PatchVersion;186 187 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();188 189 $Output = 'Načítání textů z LUA souboru...'; 189 190 190 191 if (($this->Group['LuaFileName'] != '') and ($this->Group['TablePrefix'] != '')) 191 192 { 192 193 $Output .= '<br />'.$this->Group['Name'].'<br />'; 193 $Output .= '<br />'.$this->Group['Name'].'<br />'; 194 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 value212 $Line = substr($Line, 1); // Skip start qoute213 $TempLine = str_replace('\"', ' ', $Line); // Temporary remove slashed quotes214 $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 semicolon218 } else219 {220 // Nonstring value221 $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);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 235 $Output .= ShowMessage('Dokončeno.'); 236 236 return $Output; … … 239 239 function UpdateTranslated() 240 240 { 241 global $PatchVersion, $Config;242 243 241 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); 244 242 $Output = '<br /><br />Začínám se synchronizací VersionEnd u přeložených textů<br />'; … … 249 247 while ($do) 250 248 { 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 `'.249 $DbResult = $this->System->Database->query('SELECT `gs_tran`.`ID`, '. 250 '`gs_tran`.`VersionEnd` AS `VersionEnd_tran`, '. 251 '`gs_tran`.`VersionStart` AS `VersionStart_tran`, '. 252 '`gs_orig`.`VersionEnd` AS `VersionEnd_orig`, '. 253 '`gs_orig`.`VersionStart` AS `VersionStart_orig` FROM `'. 256 254 $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`');255 '` AS `gs_orig` ON `gs_orig`.`ID` = `gs_tran`.`Take` WHERE '. 256 '`gs_tran`.`VersionEnd` <> `gs_orig`.`VersionEnd` OR `gs_tran`.`VersionStart` <> `gs_orig`.`VersionStart`'); 259 257 $do = ($DbResult->num_rows > 0); 260 258 while ($DbRow = $DbResult->fetch_assoc()) … … 293 291 294 292 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 } 293 { 294 while ($part = substr($old, strpos($old, '<'), strpos($old, '>')-strpos($old, '<'))) 295 { 296 if ($part <> '') 297 { 298 $old = str_replace($part.'>', '', $old); 299 } 300 } 301 } 299 302 300 303 if (($GroupItem['MangosColumn'] <> '') and ($Group['MangosDatabase'] == 'mangos')) … … 319 322 320 323 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 } 324 { 325 while ($part = substr($new, strpos($new, '<'), strpos($new, '>')-strpos($new, '<'))) 326 { 327 if ($part <> '') 328 { 329 $new = str_replace($part.'>', '', $new); 330 } 331 } 332 } 325 333 326 334 if (($old == 'null') or ($old == 'NULL')) $old = ''; … … 344 352 function ImportDBC() 345 353 { 346 global $System, $Config; 347 348 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); 354 global $System; 355 349 356 $Output = 'Načítání textů z DBC souboru...'; 350 357 if (($this->Group['DBCFileName'] != '') and ($this->Group['TablePrefix'] != '')) … … 381 388 $ColumnValue = ''; 382 389 foreach ($Columns as $Column) 390 { 383 391 $ColumnValue .= '_'.$DBCFile->GetUint($I, $Column); 392 } 384 393 $ColumnValue = substr($ColumnValue, 1); 385 394 $Value[$this->Group['PrimaryKeyItem']] = $ColumnValue; … … 410 419 function ImportSQL() 411 420 { 412 global $PatchVersion;413 414 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();415 421 $Output = ''; 416 422 $File = new FileStream(); … … 418 424 $this->NewItemCount = 0; 419 425 $Count = 0; 420 $ folow_structure = false;426 $FollowStructure = false; 421 427 $i = 0; 422 428 while ((!$File->EOF())) … … 427 433 { 428 434 $Line = ''; 429 $ folow_structure = true;435 $FollowStructure = true; 430 436 $i = 0; 431 437 } 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 != '')) 438 if ((strpos($Line, ';') !== false) and ($FollowStructure == true)) 439 { 440 $FollowStructure = false; 441 } 442 if (($FollowStructure == true) and ($Line != '')) 440 443 { 441 444 $str = substr($Line, 0, strpos($Line, '`')); … … 446 449 } 447 450 448 // data451 // data 449 452 if ((strpos($Line, 'INSERT INTO `'.$this->Group['MangosTable'].'`') !== false) and (isset($structure))) 450 453 { … … 503 506 $Value[$column] = ''; 504 507 } 505 // echo ($column.'-"'.$Value[$column].'"<br>');506 508 } 507 509 foreach ($this->Group['Items'] as $GroupItem) 508 510 { 509 511 if ($GroupItem['MangosColumn'] != '') 512 { 510 513 if (isset($Value[$GroupItem['MangosColumn']])) 514 { 511 515 $Value[$GroupItem['Column']] = $Value[$GroupItem['MangosColumn']]; 512 else { 516 } 517 else 518 { 513 519 $Value[$GroupItem['Column']] = ''; 514 520 $Value[$GroupItem['MangosColumn']] =''; 515 521 } 522 } 516 523 } 517 524 … … 520 527 $ColumnValue = ''; 521 528 foreach ($Columns as $Column) 529 { 522 530 $ColumnValue .= '_'.$Value[$Column]; 531 } 523 532 $ColumnValue = substr($ColumnValue, 1); 524 533 $Value[$this->Group['PrimaryKeyItem']] = $ColumnValue; … … 533 542 } 534 543 535 function UpdateLastVersion() { 544 function UpdateLastVersion() 545 { 536 546 $DbResult = $this->System->Database->query('SELECT * FROM `Group` WHERE `Id`='.$this->Group['Id']); 537 547 $Version = $DbResult->fetch_assoc(); -
trunk/Modules/Import/generatecodeXML.php
r880 r894 1 1 <?php 2 2 3 $depth = array(); 3 4 //$xml_buffer = array();
Note:
See TracChangeset
for help on using the changeset viewer.
