Ignore:
Timestamp:
Dec 30, 2013, 12:27:16 PM (11 years ago)
Author:
maron
Message:
  • Added: import lower versions
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Import/Import.php

    r630 r680  
    4646  function InsertItem($Value)
    4747  {   
     48 
    4849    $Columns = '';
     50    //$Values = '';
    4951    foreach($this->Group['Items'] as $GroupItem)
    5052    {
    5153      $Columns .= ', `'.$GroupItem['Column'].'` ';
    52     }
     54     // $Values .= ', "'.$Value[$GroupItem['Column']].'"';
     55    }
     56   // echo $Values;
    5357    $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) ' ;
    5559    //print_r($Value);
    5660   
    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');
    5863    //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))
    6065    {
    6166      // 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']);
    6884          echo(', ');
    6985        } else echo('. ');
    7086      } else
    7187      {
    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        {     
    73103          $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'];
    75105          foreach($this->Group['Items'] as $GroupItem)
    76106          {
     
    81111          echo('# ');
    82112          $InsertId = $this->System->Database->insert_id;
    83           $this->System->ModuleManager->Modules['Log']->WriteLog('Text <a href="form.php?group='.$this->Group['Id'].'&amp;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'].'&amp;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        }
    85115      }       
    86116    } else
     
    178208      $do = true;   
    179209      while($do)
    180       { 
     210      {
    181211      $DbResult = $this->System->Database->query('SELECT `gs_tran`.`ID`, '.
    182212        '`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 `'.
    184216        $Group['TablePrefix'].'` AS `gs_tran` JOIN `'.$Group['TablePrefix'].
    185217        '` 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`');
    187219        $do = ($DbResult->num_rows > 0);
    188220        while($DbRow = $DbResult->fetch_assoc())
    189221        {
    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']);
    191224          $Output .= '. ';
    192225        }
     
    214247      $old = str_replace("Â", "", $old);
    215248      $old = str_replace("�", "", $old);
     249      $old = str_replace(" ", "", $old);
     250      $old = strtolower($old);
    216251 
    217252 
     
    231266      $new = str_replace("Â", "", $new);
    232267      $new = str_replace("�", "", $new);
    233 
     268      $new = str_replace(" ", "", $new);
     269      $new = strtolower($new);
     270     
    234271      if(($old == 'null') or ($old == 'NULL')) $old = '';
    235272      if(($new == 'null') or ($new == 'NULL')) $new = '';
Note: See TracChangeset for help on using the changeset viewer.