Changeset 291


Ignore:
Timestamp:
Dec 27, 2009, 7:12:44 PM (15 years ago)
Author:
george
Message:
  • Přidáno: Metoda Init u třídy Export, která inicializuje základní nastavení jako je cesta k dočasné složce.
  • Opraveno: Načtení informací o verzi klienta pro generování exportu.
  • Přidáno: Možnost předvolby směru řazení tabulek.
  • Opraveno: Ukládání obecných nastavení exportů.
  • Upraveno: Knihovna pro generování addonu přepsána z procedurálního na objektový zápis. Třída rozšiřuje třídu Export o další metody.
  • Upraveno: Přepsáno zařazování úloh pro generování DBC exportů.
Location:
trunk
Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/export/create_addon.php

    r267 r291  
    11<?php
    22
    3 /*
    4 if(Licence(LICENCE_ADMIN))
    5 
    6         // echo 'Přístup povolen';
    7 } else die('Přístup zamítnut!');
    8 */
    9 
    10 // Replace special codes by lua functions
    11 function ReplaceVarInText($string)
     3include_once('export.php');
     4
     5class ExportAddon extends Export
    126{
    13   $string = str_replace('$N', '"..strlower(UnitName("player")).."', $string);
    14   $string = str_replace('$n', '"..strlower(UnitName("player")).."', $string);
    15   $string = str_replace('$C', '"..strlower(UnitClass("player")).."', $string);
    16   $string = str_replace('$c', '"..strlower(UnitClass("player")).."', $string);
    17   $string = str_replace('$R', '"..strlower(UnitRace("player")).."', $string);
    18   $string = str_replace('$r', '"..strlower(UnitRace("player")).."', $string);
    19   $Gender = '$G';
    20   while(strpos($string, $Gender) !== false)
    21   {
    22         $Before = substr($string, 0, strpos($string, $Gender));
    23         $Man = substr($string, strpos($string, $Gender) + 2);
    24         $Woman = substr($Man, strpos($Man, ':') + 1);
    25         $After = substr($Woman, strpos($Woman, ';') + 1);
    26         $Man = substr($Man, 0, strpos($Man, ':'));
    27         $Woman = substr($Woman, 0, strpos($Woman, ';'));
    28         $string = $Before.'"..gsub(gsub(UnitSex("player"), "^2$", "'.
    29           $Man.'"), "^3$", "'.$Woman.'").."'.$After;
    30   }
    31   $Gender = '$g';
    32   while(strpos($string, $Gender) !== false)
    33   {
    34         $Before = substr($string, 0, strpos($string, $Gender));
    35         $Man = substr($string, strpos($string, $Gender) + 2);
    36         $Woman = substr($Man, strpos($Man, ':') + 1);
    37         $After = substr($Woman, strpos($Woman, ';') + 1);
    38         $Man = substr($Man, 0, strpos($Man, ':'));
    39         $Woman = substr($Woman, 0, strpos($Woman, ';'));
    40         $string = $Before.'"..gsub(gsub(UnitSex("player"), "^2$", "'.$Man.'"), "^3$", "'.$Woman.'").."'.$After;
    41   }
    42 
    43   $string = str_replace('$', '', $string);
    44   $string = str_replace("\r", '', $string);
    45   $string = str_replace("\n", '\r\n', $string);
    46   return($string);     
    47 }
    48 
    49 function ReplaceEnText($string)
    50 {
    51   //    $string = mysql_escape_string($string);
    52   $string = strtolower($string);
    53  
    54   $string = str_replace('"', '\"', $string);
    55   $string = str_replace('$b$b', ' ', $string); 
    56   $string = str_replace('$b $b', ' ', $string);         
    57   $string = str_replace('$b', ' ', $string);   
    58   while(strpos($string, '  '))
    59     $string = str_replace('  ', ' ', $string);
    60   $string = ReplaceVarInText($string); 
    61   return($string);
    62 }
    63 
    64 function ReplaceCzText($string)
    65 {
    66   $string = mysql_escape_string($string);
    67   $string = str_replace('$B', '\r\n', $string);
    68   $string = str_replace('$b', '\r\n', $string);
    69   $string = ReplaceVarInText($string);
    70   return($string);
    71 }
    72 
    73 function NotCancel($string)
    74 {
    75         //echo (strpos($string,'<html>'));
    76   if (strpos($string,'<html>') > -1) {
    77         return(false);
    78   } else {
    79     return(true);
    80   }
    81 }
    82 
    83 function MakeLanguageFiles($Setting)
    84 {
    85   global $Database, $TempDir, $TranslationTree, $CreatedFileList, $LanguageList;
    86  
    87   $CreatedFileList = array();
    88   $CreatedFileListCount = array();
    89  
    90   $WhereLang = '';
    91   foreach($LanguageList as $Language)
    92     if($Language['Enabled'] == 1)
    93       if(isset($Setting['language'.$Language['Id']]))  $WhereLang .= ' OR (Language = '.$Language['Id'].')';
    94   if($WhereLang == '') $WhereLang = 1;
    95     else $WhereLang = '('.substr($WhereLang, 4).')';
    96 
    97   $SelectedUsers = ''; 
    98   foreach($Setting['users-selection'] as $Item)
    99     $SelectedUsers .= ','.$Item;
    100   $SelectedUsers = substr($SelectedUsers, 1);
    101 
    102   if($SelectedUsers == '')
    103   {
    104         $WhereUsers = 1;
    105         $OrderByUserList = '';
    106   } else
    107   {
    108         $WhereUsers = '(User IN ('.$SelectedUsers.'))';
    109         $OrderByUserList = ' ORDER BY FIELD(User, '.$SelectedUsers.')';
    110   }
    111        
    112   foreach($TranslationTree as $Group)
    113   if(($Group['TablePrefix'] != '') and (in_array($Group['Id'], $Setting['groups'])))
    114   {     
    115         foreach($Group['Items'] as $Column)
    116         if($Column['AddonFileName'] != '')     
    117         {
    118       if(!isset($CreatedFileListCount[$Column['AddonFileName']]))
    119             $CreatedFileListCount[$Column['AddonFileName']] = 0;
    120           $CreatedFileListCount[$Column['AddonFileName']]++;
    121           $FileIndex = $CreatedFileListCount[$Column['AddonFileName']];
    122          
    123           $CreatedFileList[] = $Column['AddonFileName'].'_'.$FileIndex;
    124       $FileName = $TempDir.$Column['AddonFileName'].'_'.$FileIndex.'.lua';
    125       echo($Column['AddonFileName'].': ');
    126       $i = 0;
    127 
    128       $Buffer = 'CZWOW_'.$Column['AddonFileName'].
    129             '_count='.$FileIndex.'; CZWOW_'.$Column['AddonFileName'].'_'.$FileIndex.'={';
    130    
    131       $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 <= '.GetBuildNumber($Setting['Version']).' AND VersionEnd >= '.GetBuildNumber($Setting['Version']).' AND '.$WhereLang.' AND '.$WhereUsers.$OrderByUserList.') AS T1 GROUP BY T1.entry) as T2 JOIN '.$Group['TablePrefix'].' AS T3 ON (T2.entry = T3.entry) AND (T3.Language = 0)';
    132       $DbResult = $Database->SQLCommand($Query);
    133       while($Line = mysql_fetch_array($DbResult))
    134           {
    135         $en = trim(ReplaceEnText($Line['Original'])); 
    136         $cz = ReplaceCzText($Line['Translation']);
    137         if(($en <> '') and ($cz <> '') and (NotCancel($en)))
    138             {
    139           $Buffer .= "\n".'["'.$en.'"]="'.$cz.'",';
    140           $i++;
     7 
     8  // Replace special codes by lua functions
     9  function ReplaceVarInText($string)
     10  {
     11    $string = str_replace('$N', '"..strlower(UnitName("player")).."', $string);
     12    $string = str_replace('$n', '"..strlower(UnitName("player")).."', $string);
     13    $string = str_replace('$C', '"..strlower(UnitClass("player")).."', $string);
     14    $string = str_replace('$c', '"..strlower(UnitClass("player")).."', $string);
     15    $string = str_replace('$R', '"..strlower(UnitRace("player")).."', $string);
     16    $string = str_replace('$r', '"..strlower(UnitRace("player")).."', $string);
     17    $Gender = '$G';
     18    while(strpos($string, $Gender) !== false)
     19    {
     20      $Before = substr($string, 0, strpos($string, $Gender));
     21      $Man = substr($string, strpos($string, $Gender) + 2);
     22      $Woman = substr($Man, strpos($Man, ':') + 1);
     23      $After = substr($Woman, strpos($Woman, ';') + 1);
     24      $Man = substr($Man, 0, strpos($Man, ':'));
     25      $Woman = substr($Woman, 0, strpos($Woman, ';'));
     26      $string = $Before.'"..gsub(gsub(UnitSex("player"), "^2$", "'.
     27      $Man.'"), "^3$", "'.$Woman.'").."'.$After;
     28    }
     29    $Gender = '$g';
     30    while(strpos($string, $Gender) !== false)
     31    {
     32      $Before = substr($string, 0, strpos($string, $Gender));
     33      $Man = substr($string, strpos($string, $Gender) + 2);
     34      $Woman = substr($Man, strpos($Man, ':') + 1);
     35      $After = substr($Woman, strpos($Woman, ';') + 1);
     36      $Man = substr($Man, 0, strpos($Man, ':'));
     37      $Woman = substr($Woman, 0, strpos($Woman, ';'));
     38      $string = $Before.'"..gsub(gsub(UnitSex("player"), "^2$", "'.$Man.'"), "^3$", "'.$Woman.'").."'.$After;
     39    }
     40
     41    $string = str_replace('$', '', $string);
     42    $string = str_replace("\r", '', $string);
     43    $string = str_replace("\n", '\r\n', $string);
     44    return($string);   
     45  }
     46
     47  function ReplaceEnText($string)
     48  {
     49    //  $string = mysql_escape_string($string);
     50    $string = strtolower($string);
     51 
     52    $string = str_replace('"', '\"', $string);
     53    $string = str_replace('$b$b', ' ', $string); 
     54    $string = str_replace('$b $b', ' ', $string);   
     55    $string = str_replace('$b', ' ', $string); 
     56    while(strpos($string, '  '))
     57      $string = str_replace('  ', ' ', $string);
     58    $string = $this->ReplaceVarInText($string); 
     59    return($string);
     60  }
     61
     62  function ReplaceCzText($string)
     63  {
     64    $string = mysql_escape_string($string);
     65    $string = str_replace('$B', '\r\n', $string);
     66    $string = str_replace('$b', '\r\n', $string);
     67    $string = $this->ReplaceVarInText($string);
     68    return($string);
     69  }
     70
     71  function NotCancel($string)
     72  {
     73    //echo (strpos($string,'<html>'));
     74    if (strpos($string,'<html>') > -1) return(false);
     75      else return(true);
     76  }
     77
     78  function MakeLanguageFiles()
     79  {
     80    global $TranslationTree, $CreatedFileList, $LanguageList;
     81   
     82    $this->LoadFilters();
     83   
     84    $CreatedFileList = array();
     85    $CreatedFileListCount = array();
     86 
     87    $DbResult = $this->Database->query('SELECT `group`.* FROM `ExportGroup` JOIN `group` ON `group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id.' AND `group`.`TablePrefix` != ""');
     88    while($Group = $DbResult->fetch_assoc())
     89    {
     90      foreach($TranslationTree[$Group['Id']]['Items'] as $Column)
     91      if($Column['AddonFileName'] != '') 
     92      {
     93        if(!isset($CreatedFileListCount[$Column['AddonFileName']]))
     94        $CreatedFileListCount[$Column['AddonFileName']] = 0;
     95        $CreatedFileListCount[$Column['AddonFileName']]++;
     96        $FileIndex = $CreatedFileListCount[$Column['AddonFileName']];
     97   
     98        $CreatedFileList[] = $Column['AddonFileName'].'_'.$FileIndex;
     99        $FileName = $this->TempDir.$Column['AddonFileName'].'_'.$FileIndex.'.lua';
     100        echo($Column['AddonFileName'].': ');
     101        $i = 0;
     102
     103        $Buffer = 'CZWOW_'.$Column['AddonFileName'].
     104        '_count='.$FileIndex.'; CZWOW_'.$Column['AddonFileName'].'_'.$FileIndex.'={';
     105   
     106        $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)';
     107        $DbResult2 = $this->Database->query($Query);
     108        while($Line = $DbResult2->fetch_assoc())
     109        {
     110          $en = trim($this->ReplaceEnText($Line['Original'])); 
     111          $cz = $this->ReplaceCzText($Line['Translation']);
     112          if(($en <> '') and ($cz <> '') and ($this->NotCancel($en)))
     113          {
     114            $Buffer .= "\n".'["'.$en.'"]="'.$cz.'",';
     115            $i++;
     116          }
    141117        }
     118   
     119        $Buffer = $Buffer."\n};if not CZWOW_".$Column['AddonFileName']." then CZWOW_".$Column['AddonFileName']."=0; end; CZWOW_".$Column['AddonFileName']."=CZWOW_".$Column['AddonFileName']."+".$i.";\n";
     120
     121        file_put_contents($FileName, $Buffer);
     122        echo('<b>Hotovo</b><br />');
    142123      }
    143    
    144       $Buffer = $Buffer."\n};if not CZWOW_".$Column['AddonFileName']." then CZWOW_".$Column['AddonFileName']."=0; end; CZWOW_".$Column['AddonFileName']."=CZWOW_".$Column['AddonFileName']."+".$i.";\n";
    145 
    146           file_put_contents($FileName, $Buffer);
    147       echo('<b>Hotovo</b><br />');
    148         }
    149   }
    150  
    151   // Generate file Translates.xml
    152   $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"><script file="BookPage_1.lua"/>'."\n";
    153   foreach($CreatedFileList as $CreatedFile)
    154     $Buffer .= '<script file="'.$CreatedFile.'.lua"/>'."\n";
    155   $Buffer .= '</Ui>';
    156   file_put_contents($TempDir.'Translates.xml', $Buffer);
    157 }
    158 
    159 function MakeClientStrings($Setting)
    160 {
    161   global $Database, $TempDir, $TranslationTree, $LanguageList;
    162  
    163   $WhereLang = '';
    164   foreach($LanguageList as $Language)
    165     if($Language['Enabled'] == 1)
    166       if(isset($Setting['language'.$Language['Id']]))  $WhereLang .= ' OR (Language = '.$Language['Id'].')';
    167   if($WhereLang == '') $WhereLang = 1;
    168     else $WhereLang = '('.substr($WhereLang, 4).')';
    169 
    170   $SelectedUsers = ''; 
    171   foreach($Setting['users-selection'] as $Item)
    172     $SelectedUsers .= ','.$Item;
    173   $SelectedUsers = substr($SelectedUsers, 1);
    174 
    175   if($SelectedUsers == '')
    176   {
    177         $WhereUsers = 1;
    178         $OrderByUserList = '';
    179   } else
    180   {
    181         $WhereUsers = '(User IN ('.$SelectedUsers.'))';
    182         $OrderByUserList = ' ORDER BY FIELD(User, '.$SelectedUsers.')';
    183   }
    184        
    185   $Buffer = "local f=function(name, en, cz) CzWoW_interface[name]=cz; CzWoW_interface_entoname[en]=name; end; CzWoW_interface={ };CzWoW_interface_entoname={ };\n";
    186   $Group = $TranslationTree[14]; // client table
    187   $Column['Column'] = 'Text';
    188   $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 <= '.GetBuildNumber($Setting['Version']).' AND VersionEnd >= '.GetBuildNumber($Setting['Version']).' AND '.$WhereLang.' AND '.$WhereUsers.$OrderByUserList.') AS T1 GROUP BY T1.entry) as T2 JOIN '.$Group['TablePrefix'].' AS T3 ON (T2.entry = T3.entry) AND (T3.Language = 0)';
    189   $DbResult = $Database->SQLCommand($Query);
    190   while($Line = mysql_fetch_array($DbResult))
    191   {
    192                 $Original = str_replace("\r", '', str_replace("\n", '\r\\'."\n", addslashes($Line['Original'])));
    193                 $Translated = str_replace("\r", '', str_replace("\n", '\r\\'."\n", addslashes($Line['Translation'])));
    194         if ($Setting['Version'] == '2.4.3') {
    195                 $Original = str_replace("|Hchannel:%d|h[%s]|h", '[%s]', $Original);
    196                 $Translated = str_replace("|Hchannel:%d|h[%s]|h", '[%s]', $Translated);
    197         }
    198     $Buffer .= 'f("'.addslashes($Line['ShortCut']).'", "'.$Original.'", "'.$Translated.'");'."\n";
    199   }
    200   //nepřeložené texty
    201   $Query = 'SELECT '.$Column['Column'].' as Original, ShortCut FROM '.$Group['TablePrefix'].' WHERE Language = 0  AND VersionStart <= '.GetBuildNumber($Setting['Version']).' AND VersionEnd >= '.GetBuildNumber($Setting['Version']).' AND entry NOT IN (SELECT entry FROM '.$Group['TablePrefix'].' WHERE (Complete = 1)  AND VersionStart <= '.GetBuildNumber($Setting['Version']).' AND VersionEnd >= '.GetBuildNumber($Setting['Version']).' AND '.$WhereLang.' AND '.$WhereUsers.')';
    202   $DbResult = $Database->SQLCommand($Query);
    203   while($Line = mysql_fetch_array($DbResult))
    204   {
    205                 $Original = str_replace("\r", '', str_replace("\n", '\r\\'."\n", addslashes($Line['Original'])));
    206                 $Translated = str_replace("\r", '', str_replace("\n", '\r\\'."\n", $Line['Original']));
    207         if ($Setting['Export'] == 'Addon-2.x.x') {
    208                 $Original = str_replace("|Hchannel:%d|h[%s]|h", '[%s]', $Original);
    209                 $Translated = str_replace("|Hchannel:%d|h[%s]|h", '[%s]', $Translated);
    210         }
    211     $Buffer .= 'f("'.addslashes($Line['ShortCut']).'", "'.$Original.'", "'.$Translated.'");'."\n";
    212   }
    213   file_put_contents($TempDir.'LocalizationStrings.lua', $Buffer);
    214 }
    215 
    216 function MakeAddon($Setting)
    217 {
    218   global $TempDir;
    219  
    220   if(!file_exists($TempDir)) mkdir($TempDir, 0777, true);
    221   MakeLanguageFiles($Setting);
    222   MakeClientStrings($Setting);
    223  // MakeMainScript($Setting);
    224 }
    225 
    226 function MakeReadme($Setting)
    227 {
    228   global $TempDir,$Database;
    229        
    230   $ID = $Database->SQLCommand('SELECT * FROM verseclient ORDER BY DATE DESC');
    231   $Line = mysql_fetch_assoc($ID);
    232 
    233   $Buffer = '
     124    }
     125 
     126    // Generate file Translates.xml
     127    $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"><script file="BookPage_1.lua"/>'."\n";
     128    foreach($CreatedFileList as $CreatedFile)
     129      $Buffer .= '<script file="'.$CreatedFile.'.lua"/>'."\n";
     130    $Buffer .= '</Ui>';
     131    file_put_contents($this->TempDir.'Translates.xml', $Buffer);
     132  }
     133
     134  function MakeClientStrings()
     135  {
     136    global $TranslationTree, $LanguageList;
     137 
     138    $this->LoadFilters();
     139 
     140    $Buffer = "local f=function(name, en, cz) CzWoW_interface[name]=cz; CzWoW_interface_entoname[en]=name; end; CzWoW_interface={ };CzWoW_interface_entoname={ };\n";
     141    $Group = $TranslationTree[14]; // client table
     142    $Column['Column'] = 'Text';
     143    $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)';
     144    $DbResult = $this->Database->query($Query);
     145    while($Line = $DbResult->fetch_array())
     146    {
     147      $Original = str_replace("\r", '', str_replace("\n", '\r\\'."\n", addslashes($Line['Original'])));
     148      $Translated = str_replace("\r", '', str_replace("\n", '\r\\'."\n", addslashes($Line['Translation'])));
     149      if ($this->ClientVersion['Version'] == '2.4.3')
     150      {
     151        $Original = str_replace("|Hchannel:%d|h[%s]|h", '[%s]', $Original);
     152        $Translated = str_replace("|Hchannel:%d|h[%s]|h", '[%s]', $Translated);
     153      }
     154      $Buffer .= 'f("'.addslashes($Line['ShortCut']).'", "'.$Original.'", "'.$Translated.'");'."\n";
     155    }
     156    //nepřeložené texty
     157    $Query = 'SELECT '.$Column['Column'].' as Original, ShortCut FROM '.$Group['TablePrefix'].' WHERE Language = 0  AND VersionStart <= '.$this->ClientVersion['BuildNumber'].' AND VersionEnd >= '.$this->ClientVersion['BuildNumber'].' AND entry NOT IN (SELECT entry FROM '.$Group['TablePrefix'].' WHERE (Complete = 1)  AND VersionStart <= '.$this->ClientVersion['BuildNumber'].' AND VersionEnd >= '.$this->ClientVersion['BuildNumber'].' AND '.$this->WhereLang.' AND '.$this->WhereUsers.')';
     158    $DbResult = $this->Database->query($Query);
     159    while($Line = $DbResult->fetch_array())
     160    {
     161      $Original = str_replace("\r", '', str_replace("\n", '\r\\'."\n", addslashes($Line['Original'])));
     162      $Translated = str_replace("\r", '', str_replace("\n", '\r\\'."\n", $Line['Original']));
     163      if(substr($this->ClientVersion['Version'], 0, 2) == '2.')
     164      {
     165        $Original = str_replace("|Hchannel:%d|h[%s]|h", '[%s]', $Original);
     166        $Translated = str_replace("|Hchannel:%d|h[%s]|h", '[%s]', $Translated);
     167      }
     168      $Buffer .= 'f("'.addslashes($Line['ShortCut']).'", "'.$Original.'", "'.$Translated.'");'."\n";
     169    }
     170    file_put_contents($this->TempDir.'LocalizationStrings.lua', $Buffer);
     171  }
     172
     173  function MakeAddon()
     174  {
     175    if(!file_exists($this->TempDir)) mkdir($this->TempDir, 0777, true);
     176    $this->MakeLanguageFiles();
     177    $this->MakeClientStrings();
     178   // MakeMainScript($Setting);
     179  }
     180
     181  function MakeReadme()
     182  {
     183    $DbResult = $this->Database->query('SELECT * FROM verseclient ORDER BY DATE DESC');
     184    $Line = $DbResult->fetch_assoc();
     185
     186    $Buffer = '
    234187 Čeština pro klienty:
    235188  Vytvořeno v projektu http://wowpreklad.zdechov.net/
     
    241194 Verze:
    242195  Verze Addonu: '.$Line['verse'].'
    243   Tato verze je pro verzi hry '.$Setting['Version'].'
     196  Tato verze je pro verzi hry '.$this->ClientVersion['Version'].'
    244197 
    245198 Změny ve verzích:
    246199 
    247   ';
    248   $ID = $Database->SQLCommand('SELECT * FROM verseclient ORDER BY DATE DESC');
    249   while($Line = mysql_fetch_assoc($ID))
    250   {
    251     $Buffer .='
     200    ';
     201    $DbResult = $Database->query('SELECT * FROM verseclient ORDER BY DATE DESC');
     202    while($Line = $DbResult->fetch_assoc())
     203    {
     204      $Buffer .='
    252205  Verze: '.$Line['verse'].'
    253206  =============
     
    255208 
    256209  ';
    257   }
    258   file_put_contents($TempDir.'CZWOW-Readme.txt', $Buffer);
     210    }
     211    file_put_contents($this->TempDir.'CZWOW-Readme.txt', $Buffer);
     212  }
    259213}
    260 
     214 
    261215?>
  • trunk/export/export.php

    r290 r291  
    1313  var $User;
    1414  var $ClientVersion;
     15  var $OrderByUserList;
     16 
     17  function Init()
     18  {
     19    $this->TempDir = $this->Config['Web']['TempFolder'].'Export/'.$this->Id.'/';
     20    if(!file_exists($this->TempDir)) mkdir($this->TempDir, 0777, true);
     21  }
    1522 
    1623  function LoadFilters()
     
    3340      $this->SelectedUsers .= ','.$User['User'];
    3441    $this->SelectedUsers = substr($this->SelectedUsers, 1);
    35 
     42   
    3643    if($this->SelectedUsers == '') $Where = 0;
    3744      else $Where = 'ID IN ('.$this->SelectedUsers.')';
     
    4350    $this->UserNames = substr($this->UserNames, 1);   
    4451   
    45     if($this->SelectedUsers == '') $WhereUsers = 1;
    46       else $this->WhereUsers = '(User IN ('.$this->SelectedUsers.'))';
    47 
     52    if($this->SelectedUsers == '')
     53    {
     54      $this->WhereUsers = 1;
     55      $this->OrderByUserList = '';
     56    } else
     57    {
     58      $this->WhereUsers = '(User IN ('.$this->SelectedUsers.'))';
     59      $this->OrderByUserList = ' ORDER BY FIELD(User, '.$this->SelectedUsers.')';
     60    }
     61   
    4862    if($_SESSION['UserID'] != '')
    4963    {
     
    5266    } else $this->User = array('user' => 'Neznámý');
    5367
    54     $DbResult = $this->Database->query('SELECT `BuildNumber` FROM `wow_client_version` WHERE `Id`='.$this->Export['ClientVersion']);
    55     $DbRow = $DbResult->fetch_assoc();
    56     $this->ClientVersion = $DbRow['BuildNumber'];
     68    $DbResult = $this->Database->query('SELECT * FROM `wow_client_version` WHERE `Id`='.$this->Export['ClientVersion']);
     69    $this->ClientVersion = $DbResult->fetch_assoc();   
    5770  }
    5871
     
    87100      if($Group['MangosTable'] != '')
    88101      {
    89         $Query = 'SELECT * FROM (SELECT * FROM '.$Group['TablePrefix'].' WHERE (Complete = 1) AND VersionStart <= '.$this->ClientVersion.' AND VersionEnd >= '.$this->ClientVersion.' AND '.$this->WhereLang.' AND '.$this->WhereUsers.' ORDER BY FIELD(User, '.$this->SelectedUsers.')) AS T GROUP BY T.entry'; 
     102        $Query = 'SELECT * FROM (SELECT * FROM '.$Group['TablePrefix'].' WHERE (Complete = 1) AND VersionStart <= '.$this->ClientVersion['BuildNumber'].' AND VersionEnd >= '.$this->ClientVersion['BuildNumber'].' AND '.$this->WhereLang.' AND '.$this->WhereUsers.' ORDER BY FIELD(User, '.$this->SelectedUsers.')) AS T GROUP BY T.entry'; 
    90103        //echo($Query);
    91104        $Buffer .= "\n\n-- ".$Group['Name']."\n\n";
     
    191204        $Group['MangosTableIndex'] = 'entry';
    192205      }
    193       $Query = 'SELECT *,(SELECT user FROM user WHERE user.ID=T.User) as UserName FROM (SELECT * FROM '.$Group['TablePrefix'].' WHERE (Complete = 1) AND VersionStart <= '.$this->ClientVersion.' AND VersionEnd >= '.$this->ClientVersion.' AND '.$this->WhereLang.' AND '.$this->WhereUsers.' ORDER BY FIELD(User, '.$this->SelectedUsers.')) AS T GROUP BY T.entry';
     206      $Query = 'SELECT *,(SELECT user FROM user WHERE user.ID=T.User) as UserName FROM (SELECT * FROM '.$Group['TablePrefix'].' WHERE (Complete = 1) AND VersionStart <= '.$this->ClientVersion['BuildNumber'].' AND VersionEnd >= '.$this->ClientVersion['BuildNumber'].' AND '.$this->WhereLang.' AND '.$this->WhereUsers.' ORDER BY FIELD(User, '.$this->SelectedUsers.')) AS T GROUP BY T.entry';
    194207      //echo($Query);
    195208      $Buffer .= '    <group id="'.$Group['Id'].'" name="'.$Group['TablePrefix'].'">'."\n";
     
    248261
    249262          foreach($Group['Items'] as $GroupItem)
    250             if(GetDBCColumnIndex($Setting['Version'],$Group['DBCFileName'],$GroupItem['Column']) != '')
    251           $Line[GetDBCColumnIndex($this->Export['ClientVersion'],$Group['DBCFileName'],$GroupItem['Column'])] = $DbRow[$GroupItem['Column']];
     263            if(GetDBCColumnIndex($Setting['Version'], $Group['DBCFileName'], $GroupItem['Column']) != '')
     264          $Line[GetDBCColumnIndex($this->Export['ClientVersion'], $Group['DBCFileName'],$GroupItem['Column'])] = $DbRow[$GroupItem['Column']];
    252265          //print_r($Line);
    253266        }
     
    274287      echo($Group['Name'].'... ');
    275288      $File = new FileStream();
    276       $File->OpenFile('../source/'.$this->ClientVersion.'/lua/'.$Group['LuaFileName'].'.lua');
     289      $File->OpenFile('../source/'.$this->ClientVersion['Version'].'/lua/'.$Group['LuaFileName'].'.lua');
    277290      $File2 = new FileStream();
    278291      $File2->CreateFile($TempDir.''.$Group['LuaFileName'].'.lua');
     
    289302          $Value['Comment'] = addslashes(substr(trim($LineParts[1]), 3));
    290303
    291           $Query = 'SELECT * FROM (SELECT * FROM '.$Group['TablePrefix'].' WHERE (Complete = 1) AND '.$this->WhereLang.' AND '.$this->WhereUsers.' AND (ShortCut="'.$Value['ShortCut'].'") AND VersionStart <= '.$this->ClientVersion.' AND VersionEnd >= '.$this->ClientVersion.' ORDER BY FIELD(User, '.$this->SelectedUsers.')) AS T GROUP BY T.entry';
     304          $Query = 'SELECT * FROM (SELECT * FROM '.$Group['TablePrefix'].' WHERE (Complete = 1) AND '.$this->WhereLang.' AND '.$this->WhereUsers.' AND (ShortCut="'.$Value['ShortCut'].'") AND VersionStart <= '.$this->ClientVersion['BuildNumber'].' AND VersionEnd >= '.$this->ClientVersion['BuildNumber'].' ORDER BY FIELD(User, '.$this->SelectedUsers.')) AS T GROUP BY T.entry';
    292305          //echo($Query);
    293306          $DbResult2 = $this->Database->query($Query);
  • trunk/export/index.php

    r290 r291  
    4040    array('Name' => '', 'Title' => 'Akce'),
    4141  ); 
    42   $Order = GetOrderTableHeader($TableColumns, 'TimeCreate');
     42  $Order = GetOrderTableHeader($TableColumns, 'TimeCreate', 1);
    4343  echo('<table class="BaseTable">');
    4444  echo($Order['Output']);
     
    172172    array('Name' => 'Sequence2', 'Title' => 'Pořadí'),
    173173  ); 
    174   $Order = GetOrderTableHeader($TableColumns, 'TranslatedCount');
     174  $Order = GetOrderTableHeader($TableColumns, 'TranslatedCount', 1);
    175175  echo('<form action="?Action=View&amp;ExportId='.$_GET['ExportId'].'&amp;Operation=Save" method="post">');
    176176  echo('<h3>Překladatelé</h3>');
    177   echo('<input type="submit" value="Uložit výběr" '.$DisabledInput[$Editable].'/><br />'.
     177  echo('<input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/><br />'.
    178178   'Zvolte ze seznamu uživatele, od kterých chcete načítat překlady a upravte jejich pořadí.<br />'.
    179179    'Pořadí řádků je dáno číselnou hodnotou, kterou lze změnit na požadované pořadí. Řádky se stejným pořadovým číslem budou přečíslovány vzestupně.');
     
    213213  if(array_key_exists('ExportId', $_GET))
    214214  {
    215     $DbRows = $Database->SQLCommand('SELECT * FROM Export WHERE Id='.$_GET['ExportId']);
     215    $DbRows = $Database->SQLCommand('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    216216    if(mysql_num_rows($DbRows) > 0)
    217217    {   
     
    219219      if(Licence(LICENCE_USER) and ($_SESSION['UserID'] == $Export['User'])) $Editable = true;
    220220        else $Editable = false;
     221      if($Editable and array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
     222      {
     223        if(array_key_exists('WithDiacritic', $_POST)) $WithDiacritic = 1;
     224          else $WithDiacritic = 0;
     225        $Database->SQLCommand('UPDATE `Export` SET `Title`="'.$_POST['Title'].'", `Description`="'.$_POST['Description'].'", `WithDiacritic`='.$WithDiacritic.' WHERE Id='.$Export['Id']);
     226        $Export['Title'] = $_POST['Title'];
     227        $Export['Description'] = $_POST['Description'];
     228        $Export['WithDiacritic'] = $WithDiacritic;
     229      }
     230     
    221231      if($Export['WithDiacritic'] == 1) $WithDiacritic = ' checked="checked"'; else $WithDiacritic = '';
    222       echo('<form action="?Action=ModifyFinish&amp;ExportId='.$Export['Id'].'" method="post">'.
     232      echo('<form action="?Action=View&amp;Tab=0&amp;ExportId='.$Export['Id'].'" method="post">'.
    223233        '<table>'.
    224234        '<tr><td colspan="2"><input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/></td></tr>'.
    225235'<tr><td>Označení:</td><td><input type="text" style="width: 400px" name="Title" value="'.$Export['Title'].'"'.$DisabledInput[$Editable].'/></td></tr>'.
    226         '<tr><td>Popis:</td><td><textarea name="Description" cols="54" rows="10"'.$DisabledTextArea[$Editable].'></textarea></td></tr>'.
     236        '<tr><td>Popis:</td><td><textarea name="Description" cols="54" rows="10"'.$DisabledTextArea[$Editable].'>'.$Export['Description'].'</textarea></td></tr>'.
    227237        '<tr><td>Včetně háčků a čárek</td><td><input type="checkbox" name="WithDiacritic" '.$WithDiacritic.''.$DisabledInput[$Editable].'/></td></tr>'.
    228238      '</table></fieldset></form>');
     
    293303  echo('<form action="?Action=View&amp;ExportId='.$_GET['ExportId'].'&amp;Operation=Save" method="post">');
    294304  echo('<h3>Jazyky</h3>');
    295   echo('<input type="submit" value="Uložit výběr" '.$DisabledInput[$Editable].'/><br />'.
     305  echo('<input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/><br />'.
    296306   'Zvolte ze seznamu dostupných jazyků, ze kterých chcete sestavit překlady a upravte jejich pořadí.<br />'.
    297307    'Pořadí řádků je dáno číselnou hodnotou, kterou lze změnit na požadované pořadí. Řádky se stejným pořadovým číslem budou přečíslovány vzestupně.');
     
    377387  echo('<form action="?Action=View&amp;ExportId='.$_GET['ExportId'].'&amp;Operation=Save" method="post">');
    378388  echo('<h3>Překladové skupiny</h3>');
    379   echo('<input type="submit" value="Uložit výběr" '.$DisabledInput[$Editable].'/><br />'.
     389  echo('<input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/><br />'.
    380390   'Zvolte ze překladových skupin, ze kterých chcete načítat překlady.<br />');
    381391
     
    474484    array('Name' => '', 'Title' => 'Výběr'),
    475485  );
    476   $Order = GetOrderTableHeader($TableColumns, 'BuildNumber');
     486  $Order = GetOrderTableHeader($TableColumns, 'BuildNumber', 1);
    477487  echo('<form action="?Action=View&amp;ExportId='.$_GET['ExportId'].'" method="post">');
    478488  echo('<h3>Verze klienta</h3>');
    479489
    480   echo('<input type="submit" value="Uložit výběr" '.$DisabledInput[$Editable].'/><br />
     490  echo('<input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/><br />
    481491   Vyberte pro jakou verzi herního klienta se budou texty exportovat.<br />');
    482492  echo($PageList['Output']);
  • trunk/includes/global_function.php

    r290 r291  
    9292$OrderArrowImage = array('sort_asc.png', 'sort_desc.png');
    9393
    94 function GetOrderTableHeader($Columns, $DefaultColumn)
     94function GetOrderTableHeader($Columns, $DefaultColumn, $DefaultOrder = 0)
    9595{
    9696  global $OrderDirSQL, $OrderArrowImage, $Config;
     
    9999  if(array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir'];
    100100  if(!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn;
    101   if(!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = 0;
     101  if(!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder;
    102102 
    103103  // Check OrderCol
  • trunk/log.php

    r288 r291  
    7676    array('Name' => 'IP', 'Title' => 'Adresa'),
    7777  );
    78   $Order = GetOrderTableHeader($TableColumns, 'date');
     78  $Order = GetOrderTableHeader($TableColumns, 'date', 1);
    7979  echo('<table width="98%" class="BaseTable">');
    8080  echo($Order['Output']);
  • trunk/statistic.php

    r286 r291  
    88if($LanguageId > 0) $language = '&amp;language='.$LanguageId;
    99  else $language = '';
    10 if(array_key_exists('user', $_GET))  $user_stat = '&amp;user='.$_SESSION['UserID'];
    11   else $user_stat = '';
    1210
    1311echo('<strong>Statistika:</strong> <a href="statistic.php">Všechny</a>');
    1412foreach($LanguageList as $Language)
    1513if($Language['Enabled'] == 1) echo(' <a href="?language='.$Language['Id'].'">'.$Language['Name'].'</a>');
    16 if(Licence(LICENCE_USER))
    17 {
    18   $DbResult = mysql_fetch_assoc($Database->SQLCommand('SELECT ExportSetting FROM `user` WHERE ID='.$_SESSION['UserID']));
    19   if ($DbResult['ExportSetting'] != '')
    20     echo(' <a href="?user">Statistika výběru uživatele</a>');
    21 }
    2214
    2315foreach($TranslationTree as $Group)
    2416  if($Group['TablePrefix'] != '')
    2517  echo('<div class="state-image">
    26   <img alt="'.$Group['TablePrefix'].'" src="img_statistic.php?group='.$Group['Id'].$language.$user_stat.'" title="statistika překladů '.$Group['Name'].'"/></div>');
     18  <img alt="'.$Group['TablePrefix'].'" src="img_statistic.php?group='.$Group['Id'].$language.'" title="statistika překladů '.$Group['Name'].'"/></div>');
    2719
    2820echo('<p><strong>Celková statistika v závislosti na čase: </strong><a href="http://stat.zdechov.net/game/?Measure=18">Počet přeložených textů</a></p>
  • trunk/team.php

    r288 r291  
    2424  if(Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => 'Uživatelské akce');
    2525
    26   $Order = GetOrderTableHeader($TableColumns, 'numberuser');
     26  $Order = GetOrderTableHeader($TableColumns, 'numberuser', 1);
    2727  echo($Order['Output']);
    2828
  • trunk/userlist.php

    r288 r291  
    4040  array('Name' => 'LastLogin', 'Title' => 'Poslední připojení'),
    4141);
    42 $Order = GetOrderTableHeader($TableColumns, 'NumberTranslate');
     42$Order = GetOrderTableHeader($TableColumns, 'NumberTranslate', 1);
    4343echo($Order['Output']);
    4444
Note: See TracChangeset for help on using the changeset viewer.