Changeset 681 for trunk/Modules/Import
- Timestamp:
- Jan 1, 2014, 2:40:05 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Import/Import.php
r680 r681 46 46 function InsertItem($Value) 47 47 { 48 48 $insert = true; 49 49 $Columns = ''; 50 50 //$Values = ''; … … 59 59 //print_r($Value); 60 60 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'); 61 $DbResultMiddle = $this->System->Database->query('SELECT `VersionEnd`,`VersionStart`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND `VersionStart` <= '.$this->Version['BuildNumber'].' AND `VersionEnd` >= '.$this->Version['BuildNumber'].' ORDER BY `VersionEnd` DESC LIMIT 1'); 62 $DbResultBefore = $this->System->Database->query('SELECT `VersionEnd`,`VersionStart`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND `VersionEnd` <= '.$this->Version['BuildNumber'].' ORDER BY `VersionEnd` DESC LIMIT 1'); 63 $DbResultAfter = $this->System->Database->query('SELECT `VersionEnd`,`VersionStart`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND `VersionStart` >= '.$this->Version['BuildNumber'].' ORDER BY `VersionStart` LIMIT 1'); 63 64 //echo('SELECT `VersionEnd`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND (`Language`=0) ORDER BY `VersionStart` DESC LIMIT 1'); 64 if(($DbResult Before->num_rows > 0) or ($DbResultAfter->num_rows > 0))65 if(($DbResultMiddle->num_rows > 0) or ($DbResultBefore->num_rows > 0) or ($DbResultAfter->num_rows > 0)) 65 66 { 66 67 // Update existed text 68 $DbRowMiddle = $DbResultMiddle->fetch_assoc(); 67 69 $DbRowAfter = $DbResultAfter->fetch_assoc(); 68 70 $DbRowBefore = $DbResultBefore->fetch_assoc(); 69 if ($DbRowAfter['ID'] == $DbRowBefore['ID']) echo('` '); 70 else 71 71 72 if($this->HaveSameText($this->Group, $DbRowBefore, $Value) and ($DbResultBefore->num_rows > 0) ) 72 73 { 73 if($DbRowBefore['VersionEnd'] <> $this->Version['BuildNumber'])74 {74 $insert = false; 75 //echo (); 75 76 $this->System->Database->query('UPDATE `'.$this->Group['TablePrefix'].'` SET `VersionEnd` = "'.$this->Version['BuildNumber'].'" WHERE `ID`='.$DbRowBefore['ID']); 76 echo(' ,');77 } else echo('. ');77 echo('b '); 78 78 79 } else 79 80 if($this->HaveSameText($this->Group, $DbRowAfter, $Value) and ($DbResultAfter->num_rows > 0)) 80 81 { 81 if($DbRowAfter['VersionEnd'] <> $this->Version['BuildNumber']) 82 { 82 $insert = false; 83 83 $this->System->Database->query('UPDATE `'.$this->Group['TablePrefix'].'` SET `VersionStart` = "'.$this->Version['BuildNumber'].'" WHERE `ID`='.$DbRowAfter['ID']); 84 echo(' ,');85 } else echo('. ');84 echo('a '); 85 86 86 } else 87 87 { 88 $inserted = false;89 if (isset($DbRowAfter['VersionStart'])) 90 if ($DbRowAfter['VersionStart'] == $this->Version['BuildNumber']) {88 89 if (isset($DbRowAfter['VersionStart'])) { 90 if ($DbRowAfter['VersionStart'] <= $this->Version['BuildNumber']) { 91 91 echo('Allready imported '.$DbRowBefore['Entry'].' '); 92 $insert ed = true;93 } 94 95 if (isset($DbRowBefore['VersionEnd'])) 96 if ($DbRowBefore['VersionEnd'] == $this->Version['BuildNumber']) {92 $insert = false; 93 } 94 } 95 if (isset($DbRowBefore['VersionEnd'])) { 96 if ($DbRowBefore['VersionEnd'] >= $this->Version['BuildNumber']) { 97 97 echo('Allready imported '.$DbRowBefore['Entry'].' '); 98 $inserted = true; 99 } 100 101 if (!$inserted) 98 $inserted = false; 99 } 100 } 101 102 //if [DEPRECATED] do not import 103 foreach($this->Group['Items'] as $GroupItem) { 104 if (false !== strpos($Value[$GroupItem['Column']],'[DEPRECATED')) 105 $insert = false; 106 } 107 108 109 if (isset($DbRowMiddle['Entry'])) $insert = false; 110 if (isset($DbRowAfter['Entry'])) $Value['Entry'] = $DbRowAfter['Entry']; 111 if (isset($DbRowBefore['Entry'])) $Value['Entry'] = $DbRowBefore['Entry']; 112 113 if ($insert) 102 114 { 115 103 116 $Columns = '`Entry`, `Language`, `VersionStart`, `VersionEnd`'; 104 117 $Values = $Value['Entry'].', 0, '.$this->Version['BuildNumber'].', '.$this->Version['BuildNumber']; … … 109 122 } 110 123 $this->System->Database->query('INSERT `'.$this->Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 124 125 echo ' 126 '.$Value['Entry'].' = '.$DbRowBefore['VersionStart'].'.'.$DbRowBefore['VersionEnd'].'< '.$this->Version['BuildNumber'].' <'.$DbRowAfter['VersionStart'].'.'.$DbRowAfter['VersionEnd'].'... '.$DbRowMiddle['VersionStart'].' '.$DbRowMiddle['VersionEnd'].' 127 '; 128 129 if (false !== strpos($Values,'[DEPRECATED')) 130 echo $Values; 131 111 132 echo('# '); 112 133 $InsertId = $this->System->Database->insert_id; … … 153 174 154 175 $Output .= '<br />'.$this->Group['Name'].'<br />'; 155 if($this->Group['LastVersion'] < $this->Version['BuildNumber'] + 1)176 // if($this->Group['LastVersion'] < $this->Version['BuildNumber'] + 1) 156 177 { 157 178 $File = new FileStream(); … … 192 213 $Output .= '<br />Celkem: '.$Count.' Nových: '.$this->NewItemCount.'<br />'; 193 214 $this->System->Database->query('UPDATE `Group` SET `LastVersion` = "'.$this->Version['BuildNumber'].'", `LastImport` = NOW() WHERE `Id`='.$this->Group['Id']); 194 } else $Output .= ShowMessage('Již importován pro verzi '.$this->Version['Version'], MESSAGE_CRITICAL); 215 } 216 // else $Output .= ShowMessage('Již importován pro verzi '.$this->Version['Version'], MESSAGE_CRITICAL); 195 217 } else $Output .= ShowMessage('Není definováno jméno zdrojového souboru', MESSAGE_CRITICAL); 196 218 $Output .= ShowMessage('Dokončeno.'); … … 247 269 $old = str_replace("Â", "", $old); 248 270 $old = str_replace("�", "", $old); 249 $old = str_replace(" ", "", $old); 271 $old = str_replace('-', '', $old); 272 $old = str_replace(' ', '', $old); 250 273 $old = strtolower($old); 274 $old = str_replace('$b', '', $old); 251 275 252 276 … … 266 290 $new = str_replace("Â", "", $new); 267 291 $new = str_replace("�", "", $new); 268 $new = str_replace(" ", "", $new); 292 $new = str_replace('-', '', $new); 293 $new = str_replace(' ', '', $new); 269 294 $new = strtolower($new); 295 $new = str_replace('$b', '', $new); 270 296 271 297 if(($old == 'null') or ($old == 'NULL')) $old = ''; 272 298 if(($new == 'null') or ($new == 'NULL')) $new = ''; 273 299 274 if(($ old <> $new) and ($GroupItem['Column'] <> 'Comment'))300 if(($new <> '') and ($old <> $new) and ($GroupItem['Column'] <> 'Comment')) 275 301 { 276 302 // echo $old.'X'.$new; … … 278 304 } 279 305 } 306 280 307 return($result); 281 308 }
Note:
See TracChangeset
for help on using the changeset viewer.