Changeset 455 for trunk/import/import.php
- Timestamp:
- Apr 13, 2010, 10:03:12 AM (15 years ago)
- File:
-
- 1 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 }
Note:
See TracChangeset
for help on using the changeset viewer.