Ignore:
Timestamp:
Feb 22, 2015, 11:20:50 PM (10 years ago)
Author:
chronos
Message:
  • Modified: Tabs converted to spaces.
  • Modified: Remove spaces from end of lines.
  • Added: Code format script.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Export/CreateAddon.php

    r788 r816  
    55class ExportAddon extends Export
    66{
    7  
     7
    88  // Replace special codes by lua functions
    99  function ReplaceVarInText($string, $strlower = 'strlower')
    1010  {
    11    
     11
    1212    $string = str_replace('$N', '"..'.$strlower.'(UnitName("player")).."', $string);
    1313    $string = str_replace('$n', '"..'.$strlower.'(UnitName("player")).."', $string);
     
    1717    $string = str_replace('$r', '"..'.$strlower.'(UnitRace("player")).."', $string);
    1818    $Gender = '$G';
    19     while(strpos($string, $Gender) !== false) 
     19    while(strpos($string, $Gender) !== false)
    2020    {
    2121      $Before = substr($string, 0, strpos($string, $Gender));
     
    2828      $Woman = str_replace(' ', '', $Woman);
    2929      $string = $Before.'"..gsub(gsub(UnitSex("player"), "^2$", "'.$Man.'"), "^3$", "'.$Woman.'").."'.$After;
    30     } 
     30    }
    3131    $Gender = '$g';
    32     while(strpos($string, $Gender) !== false) 
     32    while(strpos($string, $Gender) !== false)
    3333    {
    3434      $Before = substr($string, 0, strpos($string, $Gender));
     
    4141      $Woman = str_replace(' ', '', $Woman);
    4242      $string = $Before.'"..gsub(gsub(UnitSex("player"), "^2$", "'.$Man.'"),"^3$", "'.$Woman.'").."'.$After;
    43     } 
     43    }
    4444
    4545    $string = str_replace('$', '', $string);
    4646    $string = str_replace("\r", '', $string);
    4747    $string = str_replace("\n", '\r\n', $string);
    48     return($string);   
     48    return($string);
    4949  }
    5050
     
    5353    //  $string = mysql_escape_string($string);
    5454    $string = strtolower($string);
    55  
     55
    5656    $string = str_replace('"', '\"', $string);
    57     $string = str_replace('$b$b', ' ', $string); 
    58     $string = str_replace('$b $b', ' ', $string);   
    59     $string = str_replace('$b', ' ', $string); 
    60     $string = $this->ReplaceVarInText($string); 
     57    $string = str_replace('$b$b', ' ', $string);
     58    $string = str_replace('$b $b', ' ', $string);
     59    $string = str_replace('$b', ' ', $string);
     60    $string = $this->ReplaceVarInText($string);
    6161    $string = str_replace("\r", ' ', $string);
    6262    $string = str_replace("\n", ' ', $string);
     
    6464    $string = str_replace('\\n', ' ', $string);
    6565    $string = str_replace(' ', '', $string);
    66 //    while(strpos($string, '  ')) 
     66//    while(strpos($string, '  '))
    6767//      $string = str_replace('  ', ' ', $string);
    6868    return($string);
     
    7373    $string = $this->Database->real_escape_string($string);
    7474    $string = str_replace('$B', '\r\n', $string);
    75     $string = str_replace('$b', '\r\n', $string); 
     75    $string = str_replace('$b', '\r\n', $string);
    7676    $string = $this->ReplaceVarInText($string,'');
    7777    return($string);
     
    104104  {
    105105    global $TranslationTree, $CreatedFileList;
    106    
     106
    107107    $Output = '';
    108108    $this->LoadFilters();
    109    
     109
    110110    $CreatedFileList = array();
    111111    $CreatedFileListCount = array();
    112    
     112
    113113    if(!file_exists($this->TempDir.'CzWoW/')) mkdir($this->TempDir.'CzWoW/', 0777, true);
    114  
     114
    115115    $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id.' AND `Group`.`TablePrefix` != ""');
    116116    while($Group = $DbResult->fetch_assoc())
    117117    {
    118118    //získání čísla verze pro export
    119       $ID = $this->Database->query('SELECT LastVersion FROM `Group` WHERE Id = '.$Group['Id']); 
     119      $ID = $this->Database->query('SELECT LastVersion FROM `Group` WHERE Id = '.$Group['Id']);
    120120      $LastVersion = $ID->fetch_assoc();
    121      
     121
    122122      if ($LastVersion['LastVersion'] < $this->ClientVersion['BuildNumber'])
    123123        $ExportVersion = $LastVersion['LastVersion'];
     
    125125
    126126      foreach($TranslationTree[$Group['Id']]['Items'] as $Column)
    127       if($Column['AddonFileName'] != '') 
     127      if($Column['AddonFileName'] != '')
    128128      {
    129129        $this->AddProgress(1);
    130         if(!isset($CreatedFileListCount[$Column['AddonFileName']])) 
     130        if(!isset($CreatedFileListCount[$Column['AddonFileName']]))
    131131        $CreatedFileListCount[$Column['AddonFileName']] = 0;
    132132        $CreatedFileListCount[$Column['AddonFileName']]++;
    133133        $FileIndex = $CreatedFileListCount[$Column['AddonFileName']];
    134    
     134
    135135        $CreatedFileList[] = $Column['AddonFileName'].'_'.$FileIndex;
    136         $FileName = $this->TempDir.'CzWoW/'.$Column['AddonFileName'].'_'.$FileIndex.'.lua';       
     136        $FileName = $this->TempDir.'CzWoW/'.$Column['AddonFileName'].'_'.$FileIndex.'.lua';
    137137        $Output .= $Column['AddonFileName'].': ';
    138138        $i = 0;
     
    140140        $Buffer = 'CZWOW_'.$Column['AddonFileName'].'_count='.$FileIndex.';CZWOW_'.$Column['AddonFileName'].'_'.$FileIndex.'={';
    141141        $TableTexts = array();
    142    
     142
    143143        //old version
    144144        //get version before
     
    146146        if ($ExportVersion == '') $BuildNumber = $this->ClientVersion['BuildNumber'];
    147147        $ID = $this->Database->query('SELECT `BuildNumber` FROM `ClientVersion` WHERE '.
    148         ' `Imported` = 1 AND `BuildNumber` < '.$BuildNumber.' ORDER BY  `BuildNumber` DESC LIMIT 1'); 
    149         if($ID->num_rows > 0) {       
     148        ' `Imported` = 1 AND `BuildNumber` < '.$BuildNumber.' ORDER BY  `BuildNumber` DESC LIMIT 1');
     149        if($ID->num_rows > 0) {
    150150          $ExportVersionOld = $ID->fetch_assoc();
    151151          $ExportVersionOld = $ExportVersionOld['BuildNumber'];
    152        
    153           $DbResult2 = $this->Database->query($this->BuildQuery($Group,$ExportVersionOld));       
    154           while($Line = $DbResult2->fetch_assoc()) 
     152
     153          $DbResult2 = $this->Database->query($this->BuildQuery($Group,$ExportVersionOld));
     154          while($Line = $DbResult2->fetch_assoc())
    155155          {
    156             $en = trim($this->ReplaceEnText($Line['En'.$Column['Column']])); 
     156            $en = trim($this->ReplaceEnText($Line['En'.$Column['Column']]));
    157157            $cz = $this->ReplaceCzText($Line[$Column['Column']]);
    158             if(($en <> '') and ($cz <> '') and ($this->NotCancel($en))) 
     158            if(($en <> '') and ($cz <> '') and ($this->NotCancel($en)))
    159159            {
    160                $TableTexts[$en] = $cz; 
     160               $TableTexts[$en] = $cz;
    161161            }
    162162          }
    163163        }
    164164                //last version
    165        
    166         $DbResult2 = $this->Database->query($this->BuildQuery($Group,$ExportVersion));       
    167         while($Line = $DbResult2->fetch_assoc()) 
     165
     166        $DbResult2 = $this->Database->query($this->BuildQuery($Group,$ExportVersion));
     167        while($Line = $DbResult2->fetch_assoc())
    168168        {
    169           $en = trim($this->ReplaceEnText($Line['En'.$Column['Column']])); 
     169          $en = trim($this->ReplaceEnText($Line['En'.$Column['Column']]));
    170170          $cz = $this->ReplaceCzText($Line[$Column['Column']]);
    171           if(($en <> '') and ($cz <> '') and ($this->NotCancel($en))) 
     171          if(($en <> '') and ($cz <> '') and ($this->NotCancel($en)))
    172172          {
    173              $TableTexts[$en] = $cz; 
     173             $TableTexts[$en] = $cz;
    174174          }
    175175        }
    176        
     176
    177177        foreach($TableTexts as $key => $value) {
    178178            $Buffer .= "\n".'["'.$key.'"]="'.$value.'",';
    179179            $i++;
    180180        }
    181        
    182    
     181
     182
    183183        $Buffer = $Buffer."\n};if not CZWOW_".$Column['AddonFileName']." then CZWOW_".$Column['AddonFileName']."=0; end; CZWOW_".$Column['AddonFileName']."=CZWOW_".$Column['AddonFileName']."+".$i.";\n";
    184184
     
    193193    $Buffer = '';
    194194    foreach($CreatedFileList as $CreatedFile)
    195       $Buffer .= 'CZWOW_'.str_replace('_','_count=',$CreatedFile).';'."\n"; 
     195      $Buffer .= 'CZWOW_'.str_replace('_','_count=',$CreatedFile).';'."\n";
    196196    foreach($TranslationTree as $Group)
    197197      foreach($TranslationTree[$Group['Id']]['Items'] as $Column)
    198       if (($Column['AddonFileName'] != '') and (!in_array($Column['AddonFileName'].'_1', $CreatedFileList))) 
     198      if (($Column['AddonFileName'] != '') and (!in_array($Column['AddonFileName'].'_1', $CreatedFileList)))
    199199      {
    200         $Buffer .= 'CZWOW_'.$Column['AddonFileName'].'_count=0;'."\n"; 
    201     }
    202    
     200        $Buffer .= 'CZWOW_'.$Column['AddonFileName'].'_count=0;'."\n";
     201    }
     202
    203203    file_put_contents($this->TempDir.'CzWoW/'.$CountFiles, $Buffer);
    204  
    205  
     204
     205
    206206    // Generate file Translates.xml
    207207    $Buffer = '<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/.\FrameXML\UI.xsd">'."\n";
     
    218218  {
    219219    global $TranslationTree;
    220  
     220
    221221    $this->LoadFilters();
    222  
     222
    223223    $Buffer = "local f=function(name, en, cz) CzWoW_interface[name]=cz;CzWoW_interface_entoname[en]=name; end; CzWoW_interface={};CzWoW_interface_entoname={ };\n";
    224224    $Group = $TranslationTree[14]; // client table
    225225    $Column['Column'] = 'Text';
    226    
     226
    227227    $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id.' AND `Group`.`TablePrefix` != "" AND `Group`.`Id` = 14');
    228228    //$Group = $DbResult->fetch_assoc();
     
    231231    else
    232232      $CanGenerated = '';
    233    
     233
    234234    $DbResult = $this->Database->query($this->BuildQuery($Group,$CanGenerated));
    235     while($Line = $DbResult->fetch_array()) 
     235    while($Line = $DbResult->fetch_array())
    236236    {
    237237      $Original = $this->my_trim($Line['En'.$Column['Column']]);
    238238      $Translated = $this->my_trim($Line[$Column['Column']]);
    239       if($this->ClientVersion['Version'] == '2.4.3') 
     239      if($this->ClientVersion['Version'] == '2.4.3')
    240240      {
    241241        $Original = str_replace("|Hchannel:%d|h[%s]|h", '[%s]', $Original);
     
    265265    $Buffer = '
    266266 Čeština pro klienty:
    267   Vytvořeno v projektu http://wowpreklad.zdechov.net/ 
     267  Vytvořeno v projektu http://wowpreklad.zdechov.net/
    268268  Obsahuje Fonty pro správné zobrazování českých znaků, WoW addon překládající
    269269texty
    270  
     270
    271271 Instalace:
    272272  Soubory rozbalte/zkopírujte do kořenové složky s hrou. Obvikle bývá
    273273"C:/Program Files/World of Warcraft/".
    274  
     274
    275275 Verze:
    276   Verze Addonu: '.$Line['Version'].' 
     276  Verze Addonu: '.$Line['Version'].'
    277277  Tato verze je pro verzi hry '.$this->ClientVersion['Version'].'
    278  
     278
    279279 Změny ve verzích:
    280  
     280
    281281    ';
    282282    $DbResult = $System->Database->query('SELECT * FROM `CzWoWPackageVersion` ORDER BY `Date` DESC');
    283     while($Line = $DbResult->fetch_assoc()) 
     283    while($Line = $DbResult->fetch_assoc())
    284284    {
    285285      $Buffer .='
    286   Verze: '.$Line['Version'].' 
     286  Verze: '.$Line['Version'].'
    287287  =============
    288288  '.$Line['text'].'
    289  
     289
    290290  ';
    291291    }
Note: See TracChangeset for help on using the changeset viewer.