Changeset 680 for trunk/Modules/Import
- Timestamp:
- Dec 30, 2013, 12:27:16 PM (11 years ago)
- Location:
- trunk/Modules/Import
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Import/Import.php
r630 r680 46 46 function InsertItem($Value) 47 47 { 48 48 49 $Columns = ''; 50 //$Values = ''; 49 51 foreach($this->Group['Items'] as $GroupItem) 50 52 { 51 53 $Columns .= ', `'.$GroupItem['Column'].'` '; 52 } 54 // $Values .= ', "'.$Value[$GroupItem['Column']].'"'; 55 } 56 // echo $Values; 53 57 $Columns = substr($Columns, 1); 54 $Where = ' (`'.$this->Group['PrimaryKeyItem'].'` = "'.$Value[$this->Group['PrimaryKeyItem']].'") ';58 $Where = ' (`'.$this->Group['PrimaryKeyItem'].'` = "'.$Value[$this->Group['PrimaryKeyItem']].'") AND (`Language`=0) ' ; 55 59 //print_r($Value); 56 60 57 $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'); 61 $DbResultBefore = $this->System->Database->query('SELECT `VersionEnd`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND `VersionEnd` >'. $this->Version['BuildNumber'].' ORDER BY `VersionEnd` DESC LIMIT 1'); 62 $DbResultAfter = $this->System->Database->query('SELECT `VersionEnd`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND `VersionStart` <'. $this->Version['BuildNumber'].' ORDER BY `VersionStart` LIMIT 1'); 58 63 //echo('SELECT `VersionEnd`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND (`Language`=0) ORDER BY `VersionStart` DESC LIMIT 1'); 59 if( isset($DbResult2) and ($DbResult2->num_rows > 0))64 if(($DbResultBefore->num_rows > 0) or ($DbResultAfter->num_rows > 0)) 60 65 { 61 66 // Update existed text 62 $DbRow2 = $DbResult2->fetch_assoc(); 63 if($this->HaveSameText($this->Group, $DbRow2, $Value) ) 64 { 65 if($DbRow2['VersionEnd'] <> $this->Version['BuildNumber']) 66 { 67 $this->System->Database->query('UPDATE `'.$this->Group['TablePrefix'].'` SET `VersionEnd` = "'.$this->Version['BuildNumber'].'" WHERE `ID`='.$DbRow2['ID']); 67 $DbRowAfter = $DbResultAfter->fetch_assoc(); 68 $DbRowBefore = $DbResultBefore->fetch_assoc(); 69 if ($DbRowAfter['ID'] == $DbRowBefore['ID']) echo('` '); 70 else 71 if($this->HaveSameText($this->Group, $DbRowBefore, $Value) and ($DbResultBefore->num_rows > 0) ) 72 { 73 if($DbRowBefore['VersionEnd'] <> $this->Version['BuildNumber']) 74 { 75 $this->System->Database->query('UPDATE `'.$this->Group['TablePrefix'].'` SET `VersionEnd` = "'.$this->Version['BuildNumber'].'" WHERE `ID`='.$DbRowBefore['ID']); 76 echo(', '); 77 } else echo('. '); 78 } else 79 if($this->HaveSameText($this->Group, $DbRowAfter, $Value) and ($DbResultAfter->num_rows > 0)) 80 { 81 if($DbRowAfter['VersionEnd'] <> $this->Version['BuildNumber']) 82 { 83 $this->System->Database->query('UPDATE `'.$this->Group['TablePrefix'].'` SET `VersionStart` = "'.$this->Version['BuildNumber'].'" WHERE `ID`='.$DbRowAfter['ID']); 68 84 echo(', '); 69 85 } else echo('. '); 70 86 } else 71 87 { 72 if($DbRow2['VersionEnd'] <> $this->Version['BuildNumber']) { 88 $inserted = false; 89 if (isset($DbRowAfter['VersionStart'])) 90 if ($DbRowAfter['VersionStart'] == $this->Version['BuildNumber']) { 91 echo('Allready imported '.$DbRowBefore['Entry'].' '); 92 $inserted = true; 93 } 94 95 if (isset($DbRowBefore['VersionEnd'])) 96 if ($DbRowBefore['VersionEnd'] == $this->Version['BuildNumber']) { 97 echo('Allready imported '.$DbRowBefore['Entry'].' '); 98 $inserted = true; 99 } 100 101 if (!$inserted) 102 { 73 103 $Columns = '`Entry`, `Language`, `VersionStart`, `VersionEnd`'; 74 $Values = $ DbRow2['Entry'].', 0, '.$this->Version['BuildNumber'].', '.$this->Version['BuildNumber'];104 $Values = $Value['Entry'].', 0, '.$this->Version['BuildNumber'].', '.$this->Version['BuildNumber']; 75 105 foreach($this->Group['Items'] as $GroupItem) 76 106 { … … 81 111 echo('# '); 82 112 $InsertId = $this->System->Database->insert_id; 83 $this->System->ModuleManager->Modules['Log']->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);84 } else echo('Allready imported '.$DbRow2['Entry'].' ');113 $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); 114 } 85 115 } 86 116 } else … … 178 208 $do = true; 179 209 while($do) 180 { 210 { 181 211 $DbResult = $this->System->Database->query('SELECT `gs_tran`.`ID`, '. 182 212 '`gs_tran`.`VersionEnd` AS `VersionEnd_tran`, '. 183 '`gs_orig`.`VersionEnd` AS `VersionEnd_orig` FROM `'. 213 '`gs_tran`.`VersionStart` AS `VersionStart_tran`, '. 214 '`gs_orig`.`VersionEnd` AS `VersionEnd_orig`, '. 215 '`gs_orig`.`VersionStart` AS `VersionStart_orig` FROM `'. 184 216 $Group['TablePrefix'].'` AS `gs_tran` JOIN `'.$Group['TablePrefix']. 185 217 '` AS `gs_orig` ON `gs_orig`.`ID` = `gs_tran`.`Take` WHERE '. 186 '`gs_tran`.`VersionEnd` <> `gs_orig`.`VersionEnd` ');218 '`gs_tran`.`VersionEnd` <> `gs_orig`.`VersionEnd` OR `gs_tran`.`VersionStart` <> `gs_orig`.`VersionStart`'); 187 219 $do = ($DbResult->num_rows > 0); 188 220 while($DbRow = $DbResult->fetch_assoc()) 189 221 { 190 $this->System->Database->query('UPDATE `'.$Group['TablePrefix'].'` SET `VersionEnd` = '.$DbRow['VersionEnd_orig'].' WHERE `ID` = '.$DbRow['ID']); 222 echo '`'; 223 $this->System->Database->query('UPDATE `'.$Group['TablePrefix'].'` SET `VersionEnd` = '.$DbRow['VersionEnd_orig'].', `VersionStart` = '.$DbRow['VersionStart_orig'].' WHERE `ID` = '.$DbRow['ID']); 191 224 $Output .= '. '; 192 225 } … … 214 247 $old = str_replace("Â", "", $old); 215 248 $old = str_replace("�", "", $old); 249 $old = str_replace(" ", "", $old); 250 $old = strtolower($old); 216 251 217 252 … … 231 266 $new = str_replace("Â", "", $new); 232 267 $new = str_replace("�", "", $new); 233 268 $new = str_replace(" ", "", $new); 269 $new = strtolower($new); 270 234 271 if(($old == 'null') or ($old == 'NULL')) $old = ''; 235 272 if(($new == 'null') or ($new == 'NULL')) $new = ''; -
trunk/Modules/Import/cmd.php
r630 r680 47 47 '; 48 48 $Output .= 'id=<id_import_group> - importuje skupinu <id_import_group><br /><br />'; 49 $Output .= 'version=<version> - nastaví verzi importu default: '.$System->Config['Web']['GameVersion'].'<br /><br />'; 49 50 $Output .= ' <id_import_group>:'; 50 51 foreach($TranslationTree as $Group) … … 59 60 { 60 61 // $Output .= '<div style="font-size: xx-small;">'; 62 if (array_key_exists('version', $_GET)) 63 $Import->SetVersion($_GET['version']); 64 else 61 65 $Import->SetVersion($System->Config['Web']['GameVersion']); 62 66 $Output .= $Import->ImportGroup($_GET['id']); //$Config['Web']['GameVersion']
Note:
See TracChangeset
for help on using the changeset viewer.