Ignore:
Timestamp:
Dec 8, 2013, 6:43:40 PM (11 years ago)
Author:
maron
Message:
  • Fixed: Load data from arrays only if array exists
  • Fixed: Import/cmd.php
  • Fixed: patch in Import/Import.php
  • Fixed: Can compare text with not complete
File:
1 edited

Legend:

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

    r578 r630  
    1515                $this->License = 'GNU/GPL';
    1616                $this->Description = 'Support for import of data.';
    17                 $this->Dependencies = array();
     17                $this->Dependencies = array(); 
    1818        }
    1919
     
    6161      // Update existed text
    6262      $DbRow2 = $DbResult2->fetch_assoc();
    63       if($this->HaveSameText($this->Group, $DbRow2, $Value))
     63      if($this->HaveSameText($this->Group, $DbRow2, $Value) )
    6464      {
    6565        if($DbRow2['VersionEnd'] <> $this->Version['BuildNumber'])
     
    6969        } else echo('. ');
    7070      } else
    71       {       
    72         $Columns = '`Entry`, `Language`, `VersionStart`, `VersionEnd`';
    73         $Values = $DbRow2['Entry'].', 0, '.$this->Version['BuildNumber'].', '.$this->Version['BuildNumber'];
    74         foreach($this->Group['Items'] as $GroupItem)
    75         {
    76           $Columns .= ', `'.$GroupItem['Column'].'`';
    77           $Values .= ', "'.$Value[$GroupItem['Column']].'"';
    78         }
    79         $this->System->Database->query('INSERT `'.$this->Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')');
    80         echo('# ');
    81         $InsertId = $this->System->Database->insert_id;
    82         $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);
     71      {
     72        if($DbRow2['VersionEnd'] <> $this->Version['BuildNumber']) {     
     73          $Columns = '`Entry`, `Language`, `VersionStart`, `VersionEnd`';
     74          $Values = $DbRow2['Entry'].', 0, '.$this->Version['BuildNumber'].', '.$this->Version['BuildNumber'];
     75          foreach($this->Group['Items'] as $GroupItem)
     76          {
     77            $Columns .= ', `'.$GroupItem['Column'].'`';
     78            $Values .= ', "'.$Value[$GroupItem['Column']].'"';
     79          }
     80          $this->System->Database->query('INSERT `'.$this->Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')');
     81          echo('# ');
     82          $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'].' ');
    8385      }       
    8486    } else
     
    115117  {
    116118    global $TranslationTree, $PatchVersion;
    117        
    118119    $Output = 'Načítání textů z LUA souboru...';
     120                               
    119121    if(($this->Group['LuaFileName'] != '') and ($this->Group['TablePrefix'] != ''))
    120122    {
     123
    121124        $Output .= '<br />'.$this->Group['Name'].'<br />';
    122125        if($this->Group['LastVersion'] < $this->Version['BuildNumber'] + 1)
    123126        {
    124127          $File = new FileStream();
    125           $File->OpenFile('../source/'.$this->Version['Version'].'/lua/'.$this->Group['LuaFileName'].'.lua');
     128                                             
     129          $File->OpenFile(dirname(__FILE__).'/../../source/'.$this->Version['Version'].'/lua/'.$this->Group['LuaFileName'].'.lua');
    126130          $this->NewItemCount = 0;
    127131          $Count = 0;
     
    161165      } else $Output .= ShowMessage('Není definováno jméno zdrojového souboru', MESSAGE_CRITICAL);
    162166    $Output .= ShowMessage('Dokončeno.');
     167    return ($Output);
    163168  }
    164169 
     
    170175    foreach($TranslationTree as $Group) 
    171176    {
    172       $Output .= '<br />'.$Group['Name'].' ';     
     177      $Output .= '<br />'.$Group['Name'].' '; 
     178      $do = true;   
     179      while($do)
     180      {
    173181      $DbResult = $this->System->Database->query('SELECT `gs_tran`.`ID`, '.
    174182        '`gs_tran`.`VersionEnd` AS `VersionEnd_tran`, '.
     
    177185        '` AS `gs_orig` ON `gs_orig`.`ID` = `gs_tran`.`Take` WHERE '.
    178186        '`gs_tran`.`VersionEnd` <> `gs_orig`.`VersionEnd`');
    179       while($DbRow = $DbResult->fetch_assoc())
    180       {
    181         $this->System->Database->query('UPDATE `'.$Group['TablePrefix'].'` SET `VersionEnd` = '.$DbRow['VersionEnd_orig'].' WHERE `ID` = '.$DbRow['ID']);
    182         $Output .= '. ';
    183       } 
     187        $do = ($DbResult->num_rows > 0);
     188        while($DbRow = $DbResult->fetch_assoc())
     189        {
     190          $this->System->Database->query('UPDATE `'.$Group['TablePrefix'].'` SET `VersionEnd` = '.$DbRow['VersionEnd_orig'].' WHERE `ID` = '.$DbRow['ID']);
     191          $Output .= '. ';
     192        }
     193      }
    184194      $Output .= '<strong>Dokončeno.</strong>';
    185195    }
     
    255265     
    256266      $DBCFile = new DBCFile();
    257       $DBCFile->OpenFile('../source/'.$this->Version['Version'].'/dbc/'.$this->Group['DBCFileName'].'.dbc', $ColumnFormat);
     267      $DBCFile->OpenFile(dirname(__FILE__).'/../../source/'.$this->Version['Version'].'/dbc/'.$this->Group['DBCFileName'].'.dbc', $ColumnFormat);
    258268      $ItemCount = $DBCFile->GetRecordCount();
    259269      $this->NewItemCount = 0;
     
    305315    $Output= '';
    306316    $File = new FileStream();
    307     $File->OpenFile('../source/'.$this->Version['Version'].'/sql/'.$this->Group['MangosTable'].'.sql');
     317    $File->OpenFile(dirname(__FILE__).'/../../source/'.$this->Version['Version'].'/sql/'.$this->Group['MangosTable'].'.sql');
    308318    $this->NewItemCount = 0;
    309319    $Count = 0;
Note: See TracChangeset for help on using the changeset viewer.