Changeset 455 for trunk/import
- Timestamp:
- Apr 13, 2010, 10:03:12 AM (15 years ago)
- Location:
- trunk/import
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/import/import.php
r443 r455 6 6 var $Group; 7 7 var $NewItemCount; 8 var $System; 9 10 function __construct($System) 11 { 12 $this->System = &$System; 13 } 8 14 9 15 function SetVersion($Version) … … 16 22 17 23 function InsertItem($Value) 18 { 19 global $Database; 20 24 { 21 25 $Columns = ''; 22 26 foreach($this->Group['Items'] as $GroupItem) … … 28 32 //print_r($Value); 29 33 30 $DbResult2 = $ Database->SQLCommand('SELECT `VersionEnd`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND (`Language`=0) ORDER BY `VersionStart` DESC LIMIT 1');34 $DbResult2 = $this->System->Database->query('SELECT `VersionEnd`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND (`Language`=0) ORDER BY `VersionStart` DESC LIMIT 1'); 31 35 //echo('SELECT `VersionEnd`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND (`Language`=0) ORDER BY `VersionStart` DESC LIMIT 1'); 32 if(isset($DbResult2) and ( mysql_num_rows($DbResult2)> 0))36 if(isset($DbResult2) and ($DbResult2->num_rows > 0)) 33 37 { 34 38 // Update existed text 35 $DbRow2 = mysql_fetch_assoc($DbResult2);39 $DbRow2 = $DbResult2->fetch_assoc(); 36 40 if($this->HaveSameText($this->Group, $DbRow2, $Value)) 37 41 { 38 42 if($DbRow2['VersionEnd'] <> $this->Version['BuildNumber']) 39 43 { 40 $ Database->SQLCommand('UPDATE `'.$this->Group['TablePrefix'].'` SET `VersionEnd` = "'.$this->Version['BuildNumber'].'" WHERE `ID`='.$DbRow2['ID']);44 $this->System->Database->query('UPDATE `'.$this->Group['TablePrefix'].'` SET `VersionEnd` = "'.$this->Version['BuildNumber'].'" WHERE `ID`='.$DbRow2['ID']); 41 45 echo(', '); 42 46 } else echo('. '); … … 50 54 $Values .= ', "'.$Value[$GroupItem['Column']].'"'; 51 55 } 52 $ Database->SQLCommand('INSERT `'.$this->Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')');56 $this->System->Database->query('INSERT `'.$this->Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 53 57 echo('# '); 54 WriteLog('Text <a href="form.php?group='.$this->Group['Id'].'&ID='.mysql_insert_id().'">'.mysql_insert_id().'</a> ('.$DbRow2['Entry'].') ze skupiny '.$this->Group['Name'].' byl v nové verzi '.$this->Version['Version'].' změněn.', LOG_TYPE_IMPORT); 58 $InsertId = $this->System->Database->insert_id; 59 WriteLog('Text <a href="form.php?group='.$this->Group['Id'].'&ID='.$InsertId.'">'.$InsertId.'</a> ('.$DbRow2['Entry'].') ze skupiny '.$this->Group['Name'].' byl v nové verzi '.$this->Version['Version'].' změněn.', LOG_TYPE_IMPORT); 55 60 } 56 61 } else … … 62 67 // Get new unused Entry for tables without numeric id 63 68 $Value['Entry'] = 1; 64 $DbResult = $ Database->SQLCommand('SELECT MAX(`Entry`) FROM `'.$this->Group['TablePrefix'].'`');65 if( mysql_num_rows($DbResult)> 0)66 { 67 $DbRow = mysql_fetch_row($DbResult);69 $DbResult = $this->System->Database->query('SELECT MAX(`Entry`) FROM `'.$this->Group['TablePrefix'].'`'); 70 if($DbResult->num_rows > 0) 71 { 72 $DbRow = $DbResult->fetch_row(); 68 73 $Value['Entry'] += $DbRow[0]; 69 74 } … … 76 81 $Values .= ', "'.$Value[$GroupItem['Column']].'"'; 77 82 } 78 $Database->SQLCommand('INSERT `'.$this->Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 83 $this->System->Database->query('INSERT `'.$this->Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 84 $InsertId = $this->System->Database->insert_id; 79 85 echo('+ '); 80 86 $this->NewItemCount++; 81 WriteLog('Text <a href="form.php?group='.$this->Group['Id'].'&ID='. mysql_insert_id().'">'.mysql_insert_id().'</a> ('.$Value['Entry'].') ze skupiny '.$this->Group['Name'].' byl v nové verzi '.$this->Version['Version'].' přidán.', LOG_TYPE_IMPORT);87 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'].' přidán.', LOG_TYPE_IMPORT); 82 88 } 83 89 } … … 85 91 function ImportLUA() 86 92 { 87 global $ Database, $TranslationTree, $PatchVersion, $Config;93 global $TranslationTree, $PatchVersion; 88 94 89 95 echo('Načítání textů z LUA souboru...'); … … 126 132 } 127 133 echo('<br />Celkem: '.$Count.' Nových: '.$this->NewItemCount.'<br />'); 128 $ Database->SQLCommand('UPDATE `Group` SET `LastVersion` = "'.$this->Version['BuildNumber'].'", `LastImport` = NOW() WHERE `Id`='.$this->Group['Id']);134 $this->System->Database->query('UPDATE `Group` SET `LastVersion` = "'.$this->Version['BuildNumber'].'", `LastImport` = NOW() WHERE `Id`='.$this->Group['Id']); 129 135 } else echo('Již importován pro verzi '.$this->Version['Version']); 130 136 } else echo('Není definováno jméno zdrojového souboru'); … … 134 140 function UpdateTranslated() 135 141 { 136 global $ Database, $TranslationTree, $PatchVersion, $Config;142 global $TranslationTree, $PatchVersion, $Config; 137 143 138 144 echo('<br /><br />Začínám se synchronizací VersionEnd u přeložených textů<br />'); … … 140 146 { 141 147 echo('<br />'.$Group['Name'].' '); 142 $DbResult = $ Database->SQLCommand('SELECT `gs_tran`.`ID`, `gs_tran`.`VersionEnd` AS `VersionEnd_tran`, `gs_orig`.`VersionEnd` AS `VersionEnd_orig` FROM `'.$Group['TablePrefix'].'` AS `gs_tran` JOIN `'.$Group['TablePrefix'].'` AS `gs_orig` ON `gs_orig`.`ID` = `gs_tran`.`Take` WHERE `gs_tran`.`VersionEnd` <> `gs_orig`.`VersionEnd`');143 while($DbRow = mysql_fetch_assoc($DbResult))148 $DbResult = $this->System->Database->query('SELECT `gs_tran`.`ID`, `gs_tran`.`VersionEnd` AS `VersionEnd_tran`, `gs_orig`.`VersionEnd` AS `VersionEnd_orig` FROM `'.$Group['TablePrefix'].'` AS `gs_tran` JOIN `'.$Group['TablePrefix'].'` AS `gs_orig` ON `gs_orig`.`ID` = `gs_tran`.`Take` WHERE `gs_tran`.`VersionEnd` <> `gs_orig`.`VersionEnd`'); 149 while($DbRow = $DbResult->fetch_assoc()) 144 150 { 145 $ Database->SQLCommand('UPDATE `'.$Group['TablePrefix'].'` SET `VersionEnd` = '.$DbRow['VersionEnd_orig'].' WHERE `ID` = '.$DbRow['ID']);151 $this->System->Database->query('UPDATE `'.$Group['TablePrefix'].'` SET `VersionEnd` = '.$DbRow['VersionEnd_orig'].' WHERE `ID` = '.$DbRow['ID']); 146 152 echo('. '); 147 153 } … … 253 259 function ImportSQL() 254 260 { 255 global $ Database, $TranslationTree, $PatchVersion, $Config;261 global $TranslationTree, $PatchVersion; 256 262 257 263 $File = new FileStream(); … … 357 363 } 358 364 echo('<br />Celkem: '.$Count.' Nových: '.$this->NewItemCount.'<br />'); 359 $ Database->SQLCommand('UPDATE `Group` SET `LastVersion` = "'.$this->Version['BuildNumber'].'", `LastImport` = NOW() WHERE `Id`='.$this->Group['Id']);365 $this->System->Database->query('UPDATE `Group` SET `LastVersion` = "'.$this->Version['BuildNumber'].'", `LastImport` = NOW() WHERE `Id`='.$this->Group['Id']); 360 366 } 361 367 } -
trunk/import/index.php
r443 r455 34 34 function ShowImportGroup() 35 35 { 36 global $ Config;36 global $System; 37 37 38 38 if(array_key_exists('id', $_GET)) … … 41 41 42 42 $GroupId = (int)$_GET['id']; 43 $Import = new Import( );44 $Import->SetVersion($ Config['Web']['GameVersion']);43 $Import = new Import($System); 44 $Import->SetVersion($System->Config['Web']['GameVersion']); 45 45 $Import->ImportGroup($GroupId); 46 46 … … 52 52 function ShowMenu() 53 53 { 54 global $TranslationTree, $ Database, $Config;54 global $TranslationTree, $System; 55 55 56 56 echo('</div><div><strong>Import zdrojů:</strong></div>'); … … 58 58 echo('<div><a href="?action=instructions">Instrukce pro přípravu zdrojových souborů</a></div>'); 59 59 echo('<div><a href="?action=update_translated">Zaktualizovat verze přeložených</a></div><br/>'); 60 echo('Verze klienta použitá pro import: <strong>'.$ Config['Web']['GameVersion'].'</strong>');61 $DbResult = $ Database->SQLCommand('SELECT COUNT(*) FROM `Group`');62 $DbRow = mysql_fetch_row($DbResult);60 echo('Verze klienta použitá pro import: <strong>'.$System->Config['Web']['GameVersion'].'</strong>'); 61 $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Group`'); 62 $DbRow = $DbResult->fetch_row(); 63 63 $PageList = GetPageList($DbRow[0]); 64 64 echo('<h3>Seznam překladových skupin</h3>'); … … 78 78 echo($Order['Output']); 79 79 80 $ ID = $Database->SQLCommand('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']);81 while($Group = mysql_fetch_assoc($ID))80 $DbResult = $System->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']); 81 while($Group = $DbResult->fetch_assoc()) 82 82 { 83 83 echo('<tr><td>'.$Group['Name'].'</td><td>'.$Group['SourceType'].'</td><td>'); … … 92 92 function UpdateTranslated() 93 93 { 94 global $System; 95 94 96 echo('<div style="font-size: xx-small;">'); 95 $Import = new Import( );97 $Import = new Import($System); 96 98 $Import->UpdateTranslated(); 97 99 echo('</div>');
Note:
See TracChangeset
for help on using the changeset viewer.