Changeset 407 for trunk/export


Ignore:
Timestamp:
Mar 28, 2010, 6:09:33 PM (15 years ago)
Author:
george
Message:
  • Opraveno: Exportování addonu. Funkce BuildQuery rozšířena pro načítání anglických originálů. Názvy sloupců s anglickými texty jsou prefixovýny pomocí En.
Location:
trunk/export
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/export/create_addon.php

    r400 r407  
    123123        $Buffer = 'CZWOW_'.$Column['AddonFileName'].'_count='.$FileIndex.';CZWOW_'.$Column['AddonFileName'].'_'.$FileIndex.'={';
    124124   
    125         $Query = 'SELECT `T2`.`'.$Column['Column'].'` AS `Translation`, `T3`.`'.$Column['Column'].'` AS `Original` FROM (SELECT `T1`.`Entry`, `T1`.`'.$Column['Column'].'` FROM (SELECT `Entry`,`'.$Column['Column'].'` FROM `'.$Group['TablePrefix'].'` WHERE (`Complete` = 1) AND (`VersionStart` <= '.$this->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$this->ClientVersion['BuildNumber'].') AND '.$this->WhereLang.' AND '.$this->WhereUsers.$this->OrderByUserList.') AS `T1` GROUP BY `T1`.`Entry`) AS `T2` JOIN `'.$Group['TablePrefix'].'` AS `T3` ON (`T2`.`Entry` = `T3`.`Entry`) AND (`T3`.`Language` = 0)';
    126         $DbResult2 = $this->Database->query($Query);
    127        
    128        
    129         if ($this->Database->affected_rows == 0) {
    130       $ID = $this->Database->query('SELECT MAX(`VersionEnd`) FROM `'.$Group['TablePrefix'].'`');
    131       $BuildNumber_max = $ID->fetch_assoc();
    132       $BuildNumber_max = $BuildNumber_max['MAX(`VersionEnd`)'];
    133      
    134       $Query = 'SELECT `T2`.`'.$Column['Column'].'` AS `Translation`, `T3`.`'.$Column['Column'].'` AS `Original` FROM (SELECT `T1`.`Entry`, `T1`.`'.$Column['Column'].'` FROM (SELECT `Entry`,`'.$Column['Column'].'` FROM `'.$Group['TablePrefix'].'` WHERE (`Complete` = 1) AND (`VersionStart` <= '.$BuildNumber_max.') AND (`VersionEnd` >= '.$BuildNumber_max.') AND '.$this->WhereLang.' AND '.$this->WhereUsers.$this->OrderByUserList.') AS `T1` GROUP BY `T1`.`Entry`) AS `T2` JOIN `'.$Group['TablePrefix'].'` AS `T3` ON (`T2`.`Entry` = `T3`.`Entry`) AND (`T3`.`Language` = 0)';
    135             $DbResult2 = $this->Database->query($Query);
    136      
    137     }
     125        $DbResult2 = $this->Database->query($this->BuildQuery($Group));
    138126       
    139127        while($Line = $DbResult2->fetch_assoc())
    140128        {
    141           $en = trim($this->ReplaceEnText($Line['Original'])); 
    142           $cz = $this->ReplaceCzText($Line['Translation']);
     129          $en = trim($this->ReplaceEnText($Line['En'.$Column['Column']])); 
     130          $cz = $this->ReplaceCzText($Line[$Column['Column']]);
    143131          if(($en <> '') and ($cz <> '') and ($this->NotCancel($en)))
    144132          {
     
    174162    $Group = $TranslationTree[14]; // client table
    175163    $Column['Column'] = 'Text';
    176     $Query = 'SELECT `T2`.`'.$Column['Column'].'` AS `Translation`, `T3`.`'.$Column['Column'].'` AS `Original`, `T3`.`ShortCut` FROM (SELECT `T1`.`Entry`, `T1`.`'.$Column['Column'].'` FROM (SELECT `Entry`,`'.$Column['Column'].'` FROM '.$Group['TablePrefix'].' WHERE (`Complete` = 1) AND (`VersionStart` <= '.$this->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$this->ClientVersion['BuildNumber'].') AND '.$this->WhereLang.' AND '.$this->WhereUsers.$this->OrderByUserList.') AS `T1` GROUP BY `T1`.`Entry`) AS `T2` JOIN `'.$Group['TablePrefix'].'` AS `T3` ON (`T2`.`Entry` = `T3`.`Entry`) AND (`T3`.`Language` = 0)';
    177     $DbResult = $this->Database->query($Query);
     164   
     165    $DbResult = $this->Database->query($this->BuildQuery($Group));
    178166    while($Line = $DbResult->fetch_array())
    179167    {
    180       $Original = $this->my_trim($Line['Original']);
    181       $Translated = $this->my_trim($Line['Translation']);
    182       if ($this->ClientVersion['Version'] == '2.4.3')
     168      $Original = $this->my_trim($Line['En'.$Column['Column']]);
     169      $Translated = $this->my_trim($Line[$Column['Column']]);
     170      if($this->ClientVersion['Version'] == '2.4.3')
    183171      {
    184172        $Original = str_replace("|Hchannel:%d|h[%s]|h", '[%s]', $Original);
  • trunk/export/export.php

    r403 r407  
    4141  function BuildQuery($Group, $Columns = '')
    4242  {
     43    global $TranslationTree;
     44   
    4345    $Query = 'SELECT * FROM (SELECT `T`.*, '.$Columns.'`User`.`Name` AS `UserName` FROM `'.$Group['TablePrefix'].'` AS `T`'.
    4446    ' JOIN `ExportUser` ON (`ExportUser`.`User`=`T`.`User`) AND (`ExportUser`.`Export`='.$this->Id.') '.
     
    4648    ' JOIN `ExportLanguage` ON (`ExportLanguage`.`Export`='.$this->Id.')'.
    4749    ' WHERE (`Complete` = 1) AND (`VersionStart` <= '.$this->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$this->ClientVersion['BuildNumber'].')'.
    48     ' ORDER BY `ExportLanguage`.`Sequence`, `ExportUser`.`Sequence`) AS `TT` GROUP BY `TT`.`Entry`'; 
     50    ' ORDER BY `ExportLanguage`.`Sequence`, `ExportUser`.`Sequence`) AS `TT` GROUP BY `TT`.`Entry`';
     51   
     52    $OriginalColumns = '';
     53    foreach($TranslationTree[$Group['Id']]['Items'] as $Column)
     54      $OriginalColumns .= ' `T3`.`'.$Column['Column'].'` AS `En'.$Column['Column'].'`, ';
     55    $OriginalColumns = substr($OriginalColumns, 0, -2);
     56   
     57    $Query = 'SELECT `T4`.*, '.$OriginalColumns.' FROM ('.$Query.') AS `T4` '.
     58    ' LEFT JOIN `'.$Group['TablePrefix'].'` AS `T3` ON (`T3`.`Entry` = `T4`.`Entry`) AND (`T3`.`Language` = 0) AND (`T3`.`VersionStart` = `T4`.`VersionStart`) AND (`T3`.`VersionEnd` = `T4`.`VersionEnd`)'; 
     59    echo($Query);
    4960    return($Query);
    5061  }
    51 
     62 
    5263  function ExportToMangosSQL()
    5364  {
     
    8293        $Buffer .= "\n\n-- ".$Group['Name']."\n\n";
    8394        $DbResult2 = $this->Database->query($this->BuildQuery($Group));
     95        if($DbResult2->num_rows > 0)
    8496        while($Line = $DbResult2->fetch_array())
    8597        {
     
    269281      if(!file_exists($this->TempDir.'lua/')) mkdir($this->TempDir.'lua/', 0777, true);
    270282      $File2->CreateFile($this->TempDir.'lua/'.$Group['LuaFileName'].'.lua');
    271  
     283     
     284      $DbResult2 = $this->Database->query($this->BuildQuery($Group));
     285       
    272286      while(!$File->EOF())
    273287      {
     
    281295          $Value['Comment'] = substr(trim($LineParts[1]), 3);
    282296
    283           $DbResult2 = $this->Database->query($this->BuildQuery($Group));
    284297          if($DbResult2->num_rows > 0)
    285298          {
Note: See TracChangeset for help on using the changeset viewer.