Changeset 385 for trunk/import/import.php
- Timestamp:
- Mar 14, 2010, 5:24:06 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/import/import.php
r383 r385 5 5 var $Version; 6 6 var $Group; 7 var $NewItemCount; 7 8 8 9 function SetVersion($Version) … … 25 26 $Columns = substr($Columns, 1); 26 27 $Where = ' (`'.$this->Group['PrimaryKeyItem'].'` = "'.$Value[$this->Group['PrimaryKeyItem']].'")'; 28 //print_r($Value); 27 29 28 30 $DbResult2 = $Database->SQLCommand('SELECT `VersionEnd`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND (`Language`=0) ORDER BY `VersionStart` DESC LIMIT 1'); 31 //echo('SELECT `VersionEnd`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND (`Language`=0) ORDER BY `VersionStart` DESC LIMIT 1'); 29 32 if(isset($DbResult2) and (mysql_num_rows($DbResult2) > 0)) 30 33 { … … 54 57 { 55 58 // Insert new text 56 $Entry = 1; 57 $DbResult = $Database->SQLCommand('SELECT MAX(`Entry`) FROM `'.$this->Group['TablePrefix'].'`'); 58 if(mysql_num_rows($DbResult) > 0) 59 { 60 $DbRow = mysql_fetch_row($DbResult); 61 $Entry += $DbRow[0]; 62 } 59 if(is_numeric($Value[$this->Group['PrimaryKeyItem']])) $Value['Entry'] = $Value[$this->Group['PrimaryKeyItem']]; 60 else 61 { 62 // Get new unused Entry for tables without numeric id 63 $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); 68 $Value['Entry'] += $DbRow[0]; 69 } 70 } 63 71 $Columns = '`Entry`, `Language`, `VersionStart`, `VersionEnd`'; 64 $Values = $ Entry.', 0, '.$BuildNumber.', '.$BuildNumber;72 $Values = $Value['Entry'].', 0, '.$this->Version['BuildNumber'].', '.$this->Version['BuildNumber']; 65 73 foreach($this->Group['Items'] as $GroupItem) 66 74 { … … 70 78 $Database->SQLCommand('INSERT `'.$this->Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 71 79 echo('+ '); 72 $ NewCount++;73 WriteLog('Text <a href="form.php?group='.$this->Group['Id'].'&ID='.mysql_insert_id().'">'.mysql_insert_id().'</a> ('.$ Entry.') ze skupiny '.$this->Group['Name'].' byl v nové verzi '.$this->Version['Version'].' přidán.', LOG_TYPE_IMPORT);80 $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); 74 82 } 75 83 } … … 87 95 $File = new FileStream(); 88 96 $File->OpenFile('../source/'.$this->Version['Version'].'/lua/'.$this->Group['LuaFileName'].'.lua'); 89 $ NewCount = 0;97 $this->NewItemCount = 0; 90 98 $Count = 0; 91 99 while(!$File->EOF()) … … 117 125 $Count++; 118 126 } 119 echo('<br />Celkem: '.$Count.' Nových: '.$ NewCount.'<br />');120 $Database->SQLCommand('UPDATE `Group` SET `LastVersion` = "'.$this->Version['BuildNumber'].'", `LastImport` = NOW() WHERE `Id`='.$ Group['Id']);127 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']); 121 129 } else echo('Již importován pro verzi '.$this->Version['Version']); 122 130 } else echo('Není definováno jméno zdrojového souboru'); … … 201 209 $DBCFile->OpenFile('../source/'.$this->Version['Version'].'/dbc/'.$this->Group['DBCFileName'].'.dbc', GetDBCColumns($this->Version['Version'], $this->Group['DBCFileName'])); 202 210 $ItemCount = $DBCFile->GetRecordCount(); 203 $ NewCount = 0;211 $this->NewItemCount = 0; 204 212 $Count = 0; 205 213 for($i = 0; $i < $ItemCount; $i++) … … 213 221 $Count++; 214 222 } 215 echo('<br />Celkem: '.$Count.' Nových: '.$ NewCount.'<br />');223 echo('<br />Celkem: '.$Count.' Nových: '.$this->NewItemCount.'<br />'); 216 224 $Database->SQLCommand('UPDATE `Group` SET `LastVersion` = "'.$this->Version['BuildNumber'].'", `LastImport` = NOW() WHERE `Id`='.$this->Group['Id']); 217 225 } … … 235 243 global $Database, $TranslationTree, $PatchVersion, $Config; 236 244 237 $files = scandir('../source/'.$this->Version['Version'].'/sql/', 1);238 unset($files[count($files) - 1]);239 unset($files[count($files) - 1]);240 241 245 $File = new FileStream(); 242 $File->OpenFile('../source/'.$this->Version['Version'].'/sql/'.$ files[0]);243 $ NewCount = 0;246 $File->OpenFile('../source/'.$this->Version['Version'].'/sql/'.$this->Group['MangosTable'].'.sql'); 247 $this->NewItemCount = 0; 244 248 $Count = 0; 245 $folow_structure = False;249 $folow_structure = false; 246 250 $i = 0; 247 251 while((!$File->EOF())) 248 252 { 249 253 $Line = $File->ReadLine(); 250 // Struktura254 // Struktura 251 255 if(strpos($Line, 'CREATE TABLE `'.$this->Group['MangosTable'].'`') !== false) 252 256 { 253 257 $Line = ''; 254 $folow_structure = True;258 $folow_structure = true; 255 259 $i = 0; 256 260 } 257 261 if((strpos($Line, ';') !== false) and ($folow_structure == true)) 258 262 { 259 $folow_structure = False;263 $folow_structure = false; 260 264 // echo ('Struktura: <br />'); 261 265 // print_r($structure); … … 301 305 $LinePart = substr($LinePart, strlen($value_buff) + 2); 302 306 } 303 if 307 if(($value_buff != 'null') and ($value_buff != 'NULL')) 304 308 { 305 309 $str = ''; … … 322 326 // echo ($column.'-"'.$Value[$column].'"<br>'); 323 327 } 324 $Value[$this->Group['PrimaryKeyItem']] = $Value[$this->Group['MangosTableIndex']]; 328 foreach($this->Group['Items'] as $GroupItem) 329 { 330 if($GroupItem['MangosColumn'] != '') 331 $Value[$GroupItem['Column']] = $Value[$GroupItem['MangosColumn']]; 332 } 333 334 // Get multicolumn value 335 $Columns = explode(',', $this->Group['MangosTableIndex']); 336 $ColumnValue = ''; 337 foreach($Columns as $Column) 338 $ColumnValue .= '_'.$Value[$Column]; 339 $ColumnValue = substr($ColumnValue, 1); 340 $Value[$this->Group['PrimaryKeyItem']] = $ColumnValue; 325 341 $this->InsertItem($Value); 326 342 $Count++; … … 328 344 } 329 345 } 330 echo('<br />Celkem: '.$Count.' Nových: '.$ NewCount.'<br />');346 echo('<br />Celkem: '.$Count.' Nových: '.$this->NewItemCount.'<br />'); 331 347 $Database->SQLCommand('UPDATE `Group` SET `LastVersion` = "'.$this->Version['BuildNumber'].'", `LastImport` = NOW() WHERE `Id`='.$this->Group['Id']); 332 348 }
Note:
See TracChangeset
for help on using the changeset viewer.