Changeset 816 for trunk/Modules/Import
- Timestamp:
- Feb 22, 2015, 11:20:50 PM (10 years ago)
- Location:
- trunk/Modules/Import
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Import/Import.php
r756 r816 7 7 class ModuleImport extends AppModule 8 8 { 9 10 11 12 13 14 15 16 17 $this->Dependencies = array(); 18 19 20 21 22 $this->System->RegisterPage('import', 'PageImport'); 23 9 function __construct($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(); 18 } 19 20 function Start() 21 { 22 $this->System->RegisterPage('import', 'PageImport'); 23 } 24 24 } 25 25 26 26 class Import 27 27 { 28 var $Version; 28 var $Version; 29 29 var $Group; 30 30 var $NewItemCount; 31 31 var $System; 32 32 33 33 function __construct($System) 34 34 { 35 35 $this->System = &$System; 36 36 } 37 37 38 38 function SetVersion($Version) 39 39 { 40 40 global $System; 41 41 42 42 $DbResult = $System->Database->query('SELECT * FROM `ClientVersion` WHERE `Version` = "'.$Version.'"'); 43 $this->Version = $DbResult->fetch_assoc(); 44 } 45 43 $this->Version = $DbResult->fetch_assoc(); 44 } 45 46 46 function InsertItem($Value) 47 { 47 { 48 48 $insert = true; 49 49 $Columns = ''; … … 58 58 $Where = ' (`'.$this->Group['PrimaryKeyItem'].'` = "'.$Value[$this->Group['PrimaryKeyItem']].'") AND (`Language`=0) ' ; 59 59 //print_r($Value); 60 61 $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 61 $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'); 62 62 $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'); 63 63 $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'); … … 69 69 $DbRowAfter = $DbResultAfter->fetch_assoc(); 70 70 $DbRowBefore = $DbResultBefore->fetch_assoc(); 71 72 if($this->HaveSameText($this->Group, $DbRowBefore, $Value) and ($DbResultBefore->num_rows > 0) ) 71 72 if($this->HaveSameText($this->Group, $DbRowBefore, $Value) and ($DbResultBefore->num_rows > 0) ) 73 73 { 74 74 $insert = false; 75 75 if ($this->Group['Id'] == 1) { 76 76 $set = ' , EndText = "'.$Value['EndText'].'" , ObjectiveText1 = "'.$Value['ObjectiveText1'].'"'.' , ObjectiveText2 = "'.$Value['ObjectiveText2'].'"'.' , ObjectiveText3 = "'.$Value['ObjectiveText3'].'"'.' , ObjectiveText4 = "'.$Value['ObjectiveText4'].'"'; 77 } else $set = ''; 77 } else $set = ''; 78 78 $this->System->Database->query('UPDATE `'.$this->Group['TablePrefix'].'` SET `VersionEnd` = "'.$this->Version['BuildNumber'].'" '.$set.' WHERE `ID`='.$DbRowBefore['ID']); 79 echo('b '); 80 81 } else 82 if($this->HaveSameText($this->Group, $DbRowAfter, $Value) and ($DbResultAfter->num_rows > 0)) 79 echo('b '); 80 81 } else 82 if($this->HaveSameText($this->Group, $DbRowAfter, $Value) and ($DbResultAfter->num_rows > 0)) 83 83 { 84 84 $insert = false; 85 85 if ($this->Group['Id'] == 1) { 86 86 $set = ' , EndText = "'.$Value['EndText'].'" , ObjectiveText1 = "'.$Value['ObjectiveText1'].'"'.' , ObjectiveText2 = "'.$Value['ObjectiveText2'].'"'.' , ObjectiveText3 = "'.$Value['ObjectiveText3'].'"'.' , ObjectiveText4 = "'.$Value['ObjectiveText4'].'"'; 87 } else $set = ''; 87 } else $set = ''; 88 88 $this->System->Database->query('UPDATE `'.$this->Group['TablePrefix'].'` SET `VersionStart` = "'.$this->Version['BuildNumber'].'" '.$set.' WHERE `ID`='.$DbRowAfter['ID']); 89 echo('a '); 90 91 } else 92 { 93 94 if (isset($DbRowAfter['VersionStart'])) { 89 echo('a '); 90 91 } else 92 { 93 94 if (isset($DbRowAfter['VersionStart'])) { 95 95 if ($DbRowAfter['VersionStart'] <= $this->Version['BuildNumber']) { 96 96 echo('Allready imported '.$DbRowBefore['Entry'].' '); … … 103 103 $inserted = false; 104 104 } 105 } 106 105 } 106 107 107 //if [DEPRECATED] do not import 108 foreach($this->Group['Items'] as $GroupItem) { 108 foreach($this->Group['Items'] as $GroupItem) { 109 109 if (false !== strpos($Value[$GroupItem['Column']],'[DEPRECATED')) { 110 110 echo('d '.$DbRowBefore['Entry'].' '); 111 111 $insert = false; 112 } 113 } 112 } 113 } 114 114 115 115 if ($insert) { 116 116 $insert = false; 117 117 foreach($this->Group['Items'] as $GroupItem) 118 { 118 { 119 119 if ($Value[$GroupItem['Column']] <> '') $insert = true; 120 120 } 121 121 } 122 122 123 123 if (isset($DbRowMiddle['Entry'])) $insert = false; 124 124 if (isset($DbRowAfter['Entry'])) $Value['Entry'] = $DbRowAfter['Entry']; 125 125 if (isset($DbRowBefore['Entry'])) $Value['Entry'] = $DbRowBefore['Entry']; 126 126 127 if ($insert) 128 { 129 127 if ($insert) 128 { 129 130 130 $Columns = '`Entry`, `Language`, `VersionStart`, `VersionEnd`'; 131 131 $Values = $Value['Entry'].', 0, '.$this->Version['BuildNumber'].', '.$this->Version['BuildNumber']; 132 foreach($this->Group['Items'] as $GroupItem) 133 { 132 foreach($this->Group['Items'] as $GroupItem) 133 { 134 134 $Columns .= ', `'.$GroupItem['Column'].'`'; 135 135 $Values .= ', "'.$Value[$GroupItem['Column']].'"'; 136 136 } 137 137 $this->System->Database->query('INSERT `'.$this->Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 138 138 139 139 echo ' 140 '.$Value['Entry'].' = '.$DbRowBefore['VersionStart'].'.'.$DbRowBefore['VersionEnd'].'< '.$this->Version['BuildNumber'].' <'.$DbRowAfter['VersionStart'].'.'.$DbRowAfter['VersionEnd'].'... '.$DbRowMiddle['VersionStart'].' '.$DbRowMiddle['VersionEnd'].' 140 '.$Value['Entry'].' = '.$DbRowBefore['VersionStart'].'.'.$DbRowBefore['VersionEnd'].'< '.$this->Version['BuildNumber'].' <'.$DbRowAfter['VersionStart'].'.'.$DbRowAfter['VersionEnd'].'... '.$DbRowMiddle['VersionStart'].' '.$DbRowMiddle['VersionEnd'].' 141 141 '; 142 143 if (false !== strpos($Values,'[DEPRECATED')) 142 143 if (false !== strpos($Values,'[DEPRECATED')) 144 144 echo $Values; 145 145 146 146 echo('# '); 147 147 $InsertId = $this->System->Database->insert_id; 148 148 $this->System->ModuleManager->Modules['Log']->WriteLog('Text <a href="form.php?group='.$this->Group['Id'].'&ID='.$InsertId.'">'.$InsertId.'</a> ('.$Value['Entry'].') ze skupiny '.$this->Group['Name'].' byl v nové verzi '.$this->Version['Version'].' změněn.', LOG_TYPE_IMPORT); 149 149 } 150 } 151 } else 150 } 151 } else 152 152 { 153 153 // Insert new text … … 162 162 $DbRow = $DbResult->fetch_row(); 163 163 $Value['Entry'] += $DbRow[0]; 164 } 164 } 165 165 } 166 166 $Columns = '`Entry`, `Language`, `VersionStart`, `VersionEnd`'; … … 168 168 $insert = false; 169 169 foreach($this->Group['Items'] as $GroupItem) 170 { 170 { 171 171 $Columns .= ', `'.$GroupItem['Column'].'`'; 172 172 $Values .= ', "'.$Value[$GroupItem['Column']].'"'; … … 182 182 } 183 183 } 184 184 185 185 function ImportLUA() 186 186 { 187 187 global $TranslationTree, $PatchVersion; 188 188 $Output = 'Načítání textů z LUA souboru...'; 189 189 190 190 if(($this->Group['LuaFileName'] != '') and ($this->Group['TablePrefix'] != '')) 191 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 195 { 196 196 $File = new FileStream(); 197 197 198 198 $File->OpenFile(dirname(__FILE__).'/../../source/'.$this->Version['Version'].'/lua/'.$this->Group['LuaFileName'].'.lua'); 199 199 $this->NewItemCount = 0; … … 215 215 $Value['Text'] = str_replace('\n', "\n", $Value['Text']); 216 216 $Value['Text'] = addslashes(stripslashes($Value['Text'])); 217 $Line = trim(substr($Line, strpos($TempLine, '"') + 1)); // Skip closing quote and semicolon 218 } else 217 $Line = trim(substr($Line, strpos($TempLine, '"') + 1)); // Skip closing quote and semicolon 218 } else 219 219 { 220 220 // Nonstring value … … 224 224 $Value['Comment'] = addslashes(stripslashes(substr($Line, 3))); // Skip " --" 225 225 //print_r($Value); 226 226 227 227 $this->InsertItem($Value); 228 }; 228 }; 229 229 $Count++; 230 230 } … … 237 237 return ($Output); 238 238 } 239 239 240 240 function UpdateTranslated() 241 241 { 242 242 global $TranslationTree, $PatchVersion, $Config; 243 243 244 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) 245 foreach($TranslationTree as $Group) 246 { 247 $Output .= '<br />'.$Group['Name'].' '; 248 $do = true; 249 while($do) 250 250 { 251 251 $DbResult = $this->System->Database->query('SELECT `gs_tran`.`ID`, '. 252 253 254 255 256 257 258 259 260 while($DbRow = $DbResult->fetch_assoc()) 261 { 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 262 echo '`'; 263 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 } 264 $Output .= '. '; 265 } 266 } 267 267 $Output .= '<strong>Dokončeno.</strong>'; 268 268 } 269 269 return($Output); 270 270 } 271 271 272 272 function HaveSameText($Group, $DbRow2, $Value) 273 273 { 274 274 $result = true; 275 foreach($Group['Items'] as $GroupItem) 276 { 275 foreach($Group['Items'] as $GroupItem) 276 { 277 277 $old = $DbRow2[$GroupItem['Column']]; 278 278 $old = str_replace(chr(10), '', $old); … … 291 291 $old = strtolower($old); 292 292 $old = str_replace('$b', '', $old); 293 294 if ($this->Group['Id'] == 1) 293 294 if ($this->Group['Id'] == 1) 295 295 while ($part = substr($old, strpos($old, '<'), strpos($old, '>')-strpos($old, '<'))) 296 if ($part <> '') { 296 if ($part <> '') { 297 297 $old = str_replace($part.'>', '', $old); 298 298 } 299 299 300 300 if (($GroupItem['MangosColumn'] <> '') and ($Group['MangosDatabase'] == 'mangos')) 301 301 $new = $Value[$GroupItem['MangosColumn']]; 302 302 else $new = $Value[$GroupItem['Column']]; 303 303 304 304 $new = str_replace(chr(10), '', $new); 305 305 $new = str_replace(chr(13), '', $new); … … 318 318 $new = str_replace('$b', '', $new); 319 319 320 if ($this->Group['Id'] == 1) 320 if ($this->Group['Id'] == 1) 321 321 while ($part = substr($new, strpos($new, '<'), strpos($new, '>')-strpos($new, '<'))) 322 if ($part <> '') { 322 if ($part <> '') { 323 323 $new = str_replace($part.'>', '', $new); 324 324 } 325 325 326 326 if(($old == 'null') or ($old == 'NULL')) $old = ''; 327 327 if(($new == 'null') or ($new == 'NULL')) $new = ''; 328 329 if(($new <> '') and ($old <> $new) and ($GroupItem['Column'] <> 'Comment')) 328 329 if(($new <> '') and ($old <> $new) and ($GroupItem['Column'] <> 'Comment')) 330 330 { 331 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') ) 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 337 $result = false; 338 338 } 339 339 } 340 340 341 341 return($result); 342 342 } 343 343 344 344 function ImportDBC() 345 345 { 346 346 global $System, $TranslationTree, $Config; 347 347 348 348 $Output = 'Načítání textů z DBC souboru...'; 349 349 if(($this->Group['DBCFileName'] != '') and ($this->Group['TablePrefix'] != '')) 350 350 { 351 $Output .= '<br />'.$this->Group['Name'].'<br />'; 351 $Output .= '<br />'.$this->Group['Name'].'<br />'; 352 352 353 353 // Load string column index list 354 $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']); 355 354 $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']); 355 356 356 $ColumnIndexes = array(); 357 357 $ColumnFormat = array(); … … 361 361 $ColumnIndexes[$DbRow['GroupItem']] = $DbRow['ColumnIndex']; 362 362 } 363 363 364 364 $DBCFile = new DBCFile(); 365 365 $DBCFile->OpenFile(dirname(__FILE__).'/../../source/'.$this->Version['Version'].'/dbc/'.$this->Group['DBCFileName'].'.dbc', $ColumnFormat); 366 366 $ItemCount = $DBCFile->GetRecordCount(); 367 367 $this->NewItemCount = 0; 368 $Count = 0; 369 368 $Count = 0; 369 370 370 for($I = 0; $I < $ItemCount; $I++) 371 371 { … … 373 373 if(array_key_exists($GroupItem['Id'], $ColumnIndexes)) 374 374 { 375 $Value[$GroupItem['Column']] = addslashes($DBCFile->GetString($I, $ColumnIndexes[$GroupItem['Id']])); 376 } 377 375 $Value[$GroupItem['Column']] = addslashes($DBCFile->GetString($I, $ColumnIndexes[$GroupItem['Id']])); 376 } 377 378 378 // Get multicolumn value 379 379 $Columns = explode(',', $this->Group['DBCIndex']); … … 381 381 foreach($Columns as $Column) 382 382 $ColumnValue .= '_'.$DBCFile->GetUint($I, $Column); 383 $ColumnValue = substr($ColumnValue, 1); 384 $Value[$this->Group['PrimaryKeyItem']] = $ColumnValue; 383 $ColumnValue = substr($ColumnValue, 1); 384 $Value[$this->Group['PrimaryKeyItem']] = $ColumnValue; 385 385 $this->InsertItem($Value); 386 386 $Count++; 387 } 387 } 388 388 $Output .= '<br />Celkem: '.$Count.' Nových: '.$this->NewItemCount.'<br />'; 389 389 $this->UpdateLastVersion(); … … 396 396 { 397 397 global $TranslationTree; 398 398 399 399 $this->Group = $TranslationTree[$GroupId]; 400 400 401 401 if($this->Group['SourceType'] == 'dbc') $Output = $this->ImportDBC(); 402 402 else if($this->Group['SourceType'] == 'sql') $Output = $this->ImportSQL(); … … 406 406 return($Output); 407 407 } 408 408 409 409 function ImportSQL() 410 410 { 411 411 global $TranslationTree, $PatchVersion; 412 412 413 413 $Output= ''; 414 414 $File = new FileStream(); … … 422 422 $Line = $File->ReadLine(); 423 423 // Struktura 424 if(strpos($Line, 'CREATE TABLE `'.$this->Group['MangosTable'].'`') !== false) 424 if(strpos($Line, 'CREATE TABLE `'.$this->Group['MangosTable'].'`') !== false) 425 425 { 426 426 $Line = ''; … … 428 428 $i = 0; 429 429 } 430 if((strpos($Line, ';') !== false) and ($folow_structure == true)) 430 if((strpos($Line, ';') !== false) and ($folow_structure == true)) 431 431 { 432 432 $folow_structure = false; … … 443 443 $i++; 444 444 } 445 445 446 446 //data 447 447 if((strpos($Line, 'INSERT INTO `'.$this->Group['MangosTable'].'`') !== false) and (isset($structure))) 448 { 448 { 449 449 while ((strpos($Line, ');') === false) or ($File->EOF())) 450 450 $Line = $Line.$File->ReadLine(); 451 451 $Line = str_replace("),\n(", '),(', $Line); 452 452 453 453 $Line = substr($Line, strpos($Line, '(') + 1); 454 454 $Line = substr($Line, 0, strpos($Line, ');')); 455 455 $LineParts = explode('),(', $Line); 456 456 457 457 unset($Line); 458 458 459 459 $value_buff = ''; 460 460 $Value = ''; 461 461 foreach($LineParts as $LinePart) 462 462 { 463 463 464 464 unset($Value, $value_buff); 465 465 foreach($structure as $i => $column) … … 469 469 $value_buff = substr($LinePart, 0, strpos($LinePart, ',')); 470 470 $LinePart = substr($LinePart, strlen($value_buff) + 1); 471 } else 471 } else 472 472 { 473 473 $LinePart = substr($LinePart, 1); 474 474 $value_buff = substr($LinePart, 0, strpos($LinePart, "'")); 475 while(substr($value_buff, strlen($value_buff) - 1, 1) == "\\") 475 while(substr($value_buff, strlen($value_buff) - 1, 1) == "\\") 476 476 { 477 477 $str = substr($LinePart, strlen($value_buff)); … … 479 479 $value_buff = $value_buff.$str2; 480 480 $str = substr($str, strlen($str2)); 481 } 481 } 482 482 $LinePart = substr($LinePart, strlen($value_buff) + 2); 483 } 483 } 484 484 if(($value_buff != 'null') and ($value_buff != 'NULL')) 485 485 { 486 486 $str = ''; 487 while(substr($value_buff, strlen($value_buff) - 1,1) == " ") 487 while(substr($value_buff, strlen($value_buff) - 1,1) == " ") 488 488 { 489 489 $value_buff = substr($value_buff, 0, strlen($value_buff) - 1); … … 491 491 } 492 492 $str2 = ''; 493 while(substr($value_buff, 0, 1) == ' ') 493 while(substr($value_buff, 0, 1) == ' ') 494 494 { 495 495 $value_buff = substr($value_buff, 1, strlen($value_buff) - 1); … … 497 497 } 498 498 $Value[$column] = $str2.trim($value_buff).$str; 499 } else 500 { 499 } else 500 { 501 501 $Value[$column] = ''; 502 502 } … … 513 513 } 514 514 } 515 515 516 516 // Get multicolumn value 517 517 $Columns = explode(',', $this->Group['MangosTableIndex']); … … 519 519 foreach($Columns as $Column) 520 520 $ColumnValue .= '_'.$Value[$Column]; 521 $ColumnValue = substr($ColumnValue, 1); 521 $ColumnValue = substr($ColumnValue, 1); 522 522 $Value[$this->Group['PrimaryKeyItem']] = $ColumnValue; 523 523 $this->InsertItem($Value); 524 524 $Count++; 525 525 } 526 } 526 } 527 527 } 528 528 $Output = '<br />Celkem: '.$Count.' Nových: '.$this->NewItemCount.'<br />'; … … 530 530 return($Output); 531 531 } 532 532 533 533 function UpdateLastVersion() { 534 534 $DbResult = $this->System->Database->query('SELECT * FROM `Group` WHERE `Id`='.$this->Group['Id']); 535 $Version = $DbResult->fetch_assoc(); 535 $Version = $DbResult->fetch_assoc(); 536 536 if ($Version['LastVersion'] < $this->Version['BuildNumber']) 537 537 $this->System->Database->query('UPDATE `Group` SET `LastVersion` = "'.$this->Version['BuildNumber'].'", `LastImport` = NOW() WHERE `Id`='.$this->Group['Id']); -
trunk/Modules/Import/Manage.php
r636 r816 26 26 { 27 27 global $System; 28 29 if(array_key_exists('id', $_GET)) 28 29 if(array_key_exists('id', $_GET)) 30 30 { 31 31 $Output = '<div style="font-size: xx-small;">'; 32 32 33 33 $GroupId = (int)$_GET['id']; 34 34 $Import = new Import($System); 35 35 $Import->SetVersion($System->Config['Web']['GameVersion']); 36 36 $Output .= $Import->ImportGroup($GroupId); 37 37 38 38 $this->System->ModuleManager->Modules['Log']->WriteLog('Plnění databáze', LOG_TYPE_MODERATOR); 39 39 $Output .= '</div>'; … … 45 45 { 46 46 global $TranslationTree, $System; 47 48 $Output = '</div><div><strong>Import zdrojů:</strong></div>'. 47 48 $Output = '</div><div><strong>Import zdrojů:</strong></div>'. 49 49 '<div><a href="?action=instructions">Instrukce pro přípravu zdrojových souborů</a></div>'. 50 50 '<div><a href="?action=update_translated">Zaktualizovat verze přeložených</a></div><br/>'. … … 52 52 $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Group`'); 53 53 $DbRow = $DbResult->fetch_row(); 54 $PageList = GetPageList($DbRow[0]); 54 $PageList = GetPageList($DbRow[0]); 55 55 $Output .= '<h3>Seznam překladových skupin</h3>'; 56 56 $Output .= $PageList['Output']; 57 57 58 58 $Output .= '<table class="BaseTable">'; 59 59 $TableColumns = array( 60 array('Name' => 'Name', 'Title' => 'Jméno'), 61 array('Name' => 'SourceType', 'Title' => 'Typ zdroje'), 62 array('Name' => 'SourceName', 'Title' => 'Jméno zdroje'), 63 array('Name' => 'LastImport', 'Title' => 'Datum'), 60 array('Name' => 'Name', 'Title' => 'Jméno'), 61 array('Name' => 'SourceType', 'Title' => 'Typ zdroje'), 62 array('Name' => 'SourceName', 'Title' => 'Jméno zdroje'), 63 array('Name' => 'LastImport', 'Title' => 'Datum'), 64 64 array('Name' => 'LastVersion', 'Title' => 'Verze'), 65 array('Name' => '', 'Title' => 'Akce'), 65 array('Name' => '', 'Title' => 'Akce'), 66 66 ); 67 67 … … 70 70 71 71 $DbResult = $System->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']); 72 while($Group = $DbResult->fetch_assoc()) 72 while($Group = $DbResult->fetch_assoc()) 73 73 { 74 74 $Output .= '<tr><td>'.$Group['Name'].'</td><td>'.$Group['SourceType'].'</td><td>'; … … 85 85 { 86 86 global $System; 87 87 88 88 $Output = '<div style="font-size: xx-small;">'; 89 89 $Import = new Import($System); … … 93 93 } 94 94 95 96 97 95 function Show() 96 { 97 $this->Title = T('Import'); 98 98 $Output = ''; 99 99 if($this->System->User->Licence(LICENCE_ADMIN)) … … 104 104 else if($_GET['action'] == 'importgroup') $Output .= $this->ShowImportGroup(); 105 105 else if($_GET['action'] == 'update_translated') $Output .= $this->UpdateTranslated(); 106 else $Output .= $this->ShowMenu(); 106 else $Output .= $this->ShowMenu(); 107 107 } else $Output .= $this->ShowMenu(); 108 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 108 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 109 109 return($Output); 110 110 } 111 111 } -
trunk/Modules/Import/cmd.php
r805 r816 7 7 $System = new System(); 8 8 $System->DoNotShowPage = true; 9 9 $System->Run(); 10 10 $Import = new Import($System); 11 11 12 12 $Output = ''; 13 13 14 if(defined('STDIN') == false) 14 if(defined('STDIN') == false) 15 15 { 16 16 $Output = T('Access denied'); 17 17 exit($Output); 18 } 18 } 19 19 20 20 foreach($_SERVER['argv'] as $parameter) … … 32 32 { 33 33 $Output .= ' 34 34 35 35 1. Pripojíme se pres SSH na server (wowpreklad.zdechov.net) napríklad pres program putty.exe nebo terminál v linuxu. 36 2. Nejprve je potreba získat zdrojová data. Není zapotrebí mít všechny typy textu. 36 2. Nejprve je potreba získat zdrojová data. Není zapotrebí mít všechny typy textu. 37 37 a) SQL databázi UDB seženeme na fóru: http://udbforums.kicks-ass.net/index.php?board=5.0 , sobor rozbalíme a uložíme do adresáre "wowpreklad/source/císlo_verze/sql/" 38 38 b) DBC a LUA soubory exportujeme přímo ze hry z souboru "World of Warcraft\Data\enGB\locale-enGB.MPQ" a všechny soubory "wow-update-enGB-<buildnumber>.MPQ". Tyto soubory je nutné otevřít najednou v merge modu programu "MPQEditor.exe", který je ke stažení v adresáři "wowpreklad/download". DBC soubory jsou v MPQ souboru uloženy ve složce "DBFilesClient". Lua ve složce "Interface". Tyto soubory zkopírujte do složky "wowpreklad/source/císlo_verze/dbc/" nebo "lua" … … 41 41 5. Až máme všechno pripraveno spustíme v konzoli script príkazem "php wowpreklad/import/cmd.php" kde jsou popsané možnosti paremetu s kterýma se tento script spoucí pro ruzné importy. 42 42 6. Po provedení importu je potreba nekolikrát spustit script na aktualizaci verze u prekladu. Je potreba ho prováde opakovane dokud nezmizí tecky oznacující že byly provedeny zmeny. 43 44 43 44 45 45 Parametry: 46 46 '; … … 48 48 $Output .= ' version=<version> - nastaví verzi importu default: '.$System->Config['Web']['GameVersion'].'<br /><br />'; 49 49 $Output .= ' <id_import_group>:'; 50 foreach($TranslationTree as $Group) 50 foreach($TranslationTree as $Group) 51 51 { 52 $Output .= '<br /> '.$Group['Id'].' '; 53 $Output .= ' '.$Group['Name'].' '; 52 $Output .= '<br /> '.$Group['Id'].' '; 53 $Output .= ' '.$Group['Name'].' '; 54 54 } 55 55 … … 61 61 else 62 62 $Import->SetVersion($System->Config['Web']['GameVersion']); 63 63 64 64 $Output .= $Import->ImportGroup($_GET['id']); //$Config['Web']['GameVersion'] 65 65 // $Import->UpdateTranslated(); … … 72 72 $Output .= '<br />'. 73 73 'aktuálně nastavená importovávaná verze: '.$_GET['version'].'<br />'; 74 else 74 else 75 75 $Output .= '<br />'. 76 76 'aktuálně nastavená importovávaná verze: '.$Config['Web']['GameVersion'].'<br />'; … … 79 79 $Output = str_replace('<br />',' 80 80 ',$Output); 81 echo($Output); 82 //ShowFooter(); 81 echo($Output); 82 //ShowFooter();
Note:
See TracChangeset
for help on using the changeset viewer.