Changeset 894 for trunk/Modules/Export/Export.php
- Timestamp:
- Mar 6, 2023, 12:16:38 PM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Export/Export.php
r893 r894 9 9 public int $Id; 10 10 public array $AnoNe = array('Ne', 'Ano'); 11 var $WhereLang; 12 var $WhereUsers; 13 var $SelectedUsers; 14 var $UserNames; 15 var $ClientVersion; 16 var $OrderByUserList; 11 public string $WhereLang; 12 public string $WhereUsers; 13 public string $UserNames; 14 public array $ClientVersion; 15 public string $OrderByUserList; 17 16 public string $TempDir; 18 17 public string $TempDirRelative; … … 23 22 function Init() 24 23 { 25 $this->TempDir = dirname(__FILE__).'/../../'.Core::Cast($this->System)->Config['Web']['TempFolder'].'Export/'.$this->Id.'/';24 $this->TempDir = NormalizePath(dirname(__FILE__).'/../../'.Core::Cast($this->System)->Config['Web']['TempFolder'].'Export/'.$this->Id.'/'); 26 25 if (!file_exists($this->TempDir)) mkdir($this->TempDir, 0777, true); 27 26 $this->TempDirRelative = Core::Cast($this->System)->Config['Web']['TempFolder'].'Export/'.$this->Id.'/'; 28 $this->SourceDir = dirname(__FILE__).'/../../'.Core::Cast($this->System)->Config['Web']['SourceFolder'];27 $this->SourceDir = NormalizePath(dirname(__FILE__).'/../../'.Core::Cast($this->System)->Config['Web']['SourceFolder']); 29 28 $this->SourceDirRelative = Core::Cast($this->System)->Config['Web']['SourceFolder']; 30 29 if (!file_exists($this->SourceDir)) mkdir($this->SourceDir, 0777, true); … … 131 130 } 132 131 133 function NeedGeneration() 132 function NeedGeneration(): bool 134 133 { 135 134 $this->LoadFilters(); 136 $file = ''; 137 if ($this->Export['OutputType'] == 10) $file = $this->TempDir.'Instalace_CzechWoW_'.$this->ClientVersion['Version'].'.exe'; 138 if ($this->Export['OutputType'] == 9) $file = $this->TempDir.'CzWoW_DBC.zip'; 139 140 if (file_exists($file)) 141 $date = date('Y-m-d H:i',(filemtime($file))); 135 $FileName = ''; 136 if ($this->Export['OutputType'] == 10) $FileName = $this->TempDir.'Instalace_CzechWoW_'.$this->ClientVersion['Version'].'.exe'; 137 if ($this->Export['OutputType'] == 9) $FileName = $this->TempDir.'CzWoW_DBC.zip'; 138 139 if (file_exists($FileName)) 140 { 141 $Date = date('Y-m-d H:i',(filemtime($FileName))); 142 } 142 143 else return true; 143 144 144 145 $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` '. 145 146 'JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id); 146 $ result = false;147 $Result = false; 147 148 while ($Group = $DbResult->fetch_assoc()) 148 149 { … … 151 152 ' JOIN `User` ON `User`.`ID`=`T`.`User`'. 152 153 ' JOIN `ExportLanguage` ON (`ExportLanguage`.`Export`='.$this->Id.')'. 153 ' WHERE ( \''.$ date.'\' < `T`.`ModifyTime`) AND (`Complete` = 1) AND (`VersionStart` <= '.$this->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$this->ClientVersion['BuildNumber'].')'.154 ' WHERE ( \''.$Date.'\' < `T`.`ModifyTime`) AND (`Complete` = 1) AND (`VersionStart` <= '.$this->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$this->ClientVersion['BuildNumber'].')'. 154 155 ' '; 155 156 … … 157 158 if ($DbResult2->num_rows > 0) 158 159 { 159 $ result = true;160 } 161 } 162 return $ result;160 $Result = true; 161 } 162 } 163 return $Result; 163 164 } 164 165 … … 206 207 { 207 208 if ($GroupItem['MangosColumn'] == '') $GroupItem['MangosColumn'] = $GroupItem['Column']; 208 $Values .= ', `'.$GroupItem['MangosColumn'].'`="'.addslashes($Line[$GroupItem['Column']]).'"'; 209 $Text = $Line[$GroupItem['Column']]; 210 if ($Text == null) $Text = ''; 211 $Values .= ', `'.$GroupItem['MangosColumn'].'`="'.addslashes($Text).'"'; 209 212 } 210 213 $Values = substr($Values, 2); … … 328 331 } 329 332 330 function ExportToDBC() 333 function ExportToDBC(): string 331 334 { 332 335 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); 333 334 336 $this->LoadFilters(); 335 336 337 $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` '. 337 338 'JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` '. … … 342 343 $this->AddProgress(2); 343 344 $Output .= $Group['Name'].', '; 344 if (file_exists($this->SourceDir.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc')) 345 346 $SourceDbcFileName = $this->SourceDir.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc'; 347 if (file_exists($SourceDbcFileName)) 345 348 { 346 349 // Load string column index list … … 364 367 foreach ($TranslationTree[$Group['Id']]['Items'] as $Column) 365 368 { 366 $DbRow[$Column['Column']] = str_replace ('$ ', '$', $DbRow[$Column['Column']]); 367 if (!$this->HaveVariable($DbRow['En'.$Column['Column']], $DbRow[$Column['Column']])) 369 if ($DbRow[$Column['Column']] != null) 370 { 371 $DbRow[$Column['Column']] = str_replace('$ ', '$', $DbRow[$Column['Column']]); 372 } 373 $EnText = $DbRow['En'.$Column['Column']]; 374 if ($EnText == null) $EnText = ''; 375 $TargetText = $DbRow[$Column['Column']]; 376 if ($TargetText == null) $TargetText = ''; 377 if (!$this->HaveVariable($EnText, $TargetText)) 368 378 { 369 379 $CanExport = false; 370 380 $Output .= ', NE='.$DbRow['ID']; 371 381 } 372 if (!$this->HaveVariable($ DbRow[$Column['Column']], $DbRow['En'.$Column['Column']]))382 if (!$this->HaveVariable($TargetText, $EnText)) 373 383 { 374 384 $CanExport = false; … … 383 393 // Open original DBC file 384 394 $SourceDBCFile = new DBCFile(); 385 $SourceDBCFile->OpenFile($ this->SourceDir.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc', $ColumnFormat);395 $SourceDBCFile->OpenFile($SourceDbcFileName, $ColumnFormat); 386 396 387 397 // Create new DBC file 388 if (!file_exists($this->TempDir.'dbc/')) mkdir($this->TempDir.'dbc/', 0777, true); 398 $DbcDir = $this->TempDir.'dbc/'; 399 if (!file_exists($DbcDir)) mkdir($DbcDir, 0777, true); 389 400 $NewDBCFile = new DBCFile(); 390 $NewDBCFile->CreateFile($ this->TempDir.'dbc/'.$Group['DBCFileName'].'.dbc', $ColumnFormat);401 $NewDBCFile->CreateFile($DbcDir.$Group['DBCFileName'].'.dbc', $ColumnFormat); 391 402 $NewDBCFile->SetRecordCount($SourceDBCFile->GetRecordCount()); 392 403 $NewDBCFile->SetFieldCount($SourceDBCFile->GetFieldCount()); … … 436 447 } 437 448 $NewDBCFile->Commit(); 438 } else $Output .= ShowMessage('Zdrojový soubor '.$ this->SourceDirRelative.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc'.' nenalezen.'."\n", MESSAGE_CRITICAL);449 } else $Output .= ShowMessage('Zdrojový soubor '.$SourceDbcFileName.' nenalezen.'."\n", MESSAGE_CRITICAL); 439 450 } 440 451 $Output .= 'Hotovo <br />'; … … 442 453 } 443 454 444 function ExportToLua() 455 function ExportToLua(): string 445 456 { 446 457 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); … … 449 460 450 461 $Output = ''; 451 if (!file_exists($this->TempDir.'lua/')) mkdir($this->TempDir.'lua/', 0777, true); 462 $LuaDir = $this->TempDir.'lua/'; 463 if (!file_exists($LuaDir)) mkdir($LuaDir, 0777, true); 452 464 $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id.' AND `Group`.`LuaFileName` != ""'); 453 465 while ($Group = $DbResult->fetch_assoc()) 454 466 { 455 467 $this->AddProgress(1); 456 // $this->AddProgress();457 468 $Output .= $Group['Name'].'... '; 458 469 $File = new FileStream(); 459 if (!file_exists($this->SourceDir.$this->ClientVersion['Version'].'/lua/'.$Group['LuaFileName'].'.lua')) 470 $SourceLuaFileName = $this->SourceDir.$this->ClientVersion['Version'].'/lua/'.$Group['LuaFileName'].'.lua'; 471 if (!file_exists($SourceLuaFileName)) 472 { 460 473 continue; 461 $File->OpenFile($this->SourceDir.$this->ClientVersion['Version'].'/lua/'.$Group['LuaFileName'].'.lua'); 474 } 475 $File->OpenFile($SourceLuaFileName); 462 476 $File2 = new FileStream(); 463 $File2->CreateFile($ this->TempDir.'lua/'.$Group['LuaFileName'].'.lua');477 $File2->CreateFile($LuaDir.$Group['LuaFileName'].'.lua'); 464 478 465 479 $LookupTable = array(); … … 722 736 if ($this->Export['WithDiacritic'] != 1) $Buffer = utf2ascii($Buffer); 723 737 $Buffer .= " </translation>\n". 724 "</document>";738 '</document>'; 725 739 return $Buffer; 726 740 }
Note:
See TracChangeset
for help on using the changeset viewer.