Changeset 443


Ignore:
Timestamp:
Apr 11, 2010, 11:48:39 AM (14 years ago)
Author:
george
Message:
  • Upraveno: Přepracována a vylepšena třídy DBC. Nově je formát sloupců určen pomocí pole párů indexů a typů. Doplněny optimalizace předvytvoření prázdných polí se známou velikostí.
  • Upraveno: Přepracován systém určování textových sloupců DBC souborů dle verzí klienta. Vytvořena samostatná tabulka GroupItemDBC obsahující sloupce id verze klienta, id položky GroupItem a index v DBC souboru. Odstraněny podobné údaje z ClientVersion. Upraven DBC import a export.
  • Přidáno: Další překladové skupiny z DBC souborů.
  • Upraveno: Export přepracován pro jednoduchost zpět na PHP pomalou variantu. Bude později přepracován a zoptimalizován.
  • Přidáno: Zobrazení času úpravy překladu.
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • tools/dbc_export/DBCExport.pas

    r414 r443  
    1111
    1212type
     13
    1314  { TDBCExport }
    1415  TDBCExport = class(TCustomApplication)
     
    121122  WriteLn('  -f --file        Source DBC file name');
    122123  WriteLn('  -n --newfile     New created DBC file name');
    123   WriteLn('  -c --coltypedef  DBC column type definition string (u - uint32, s - string)');
     124  WriteLn('  -c --coltypedef  DBC column type definition string (usage index1:type1, index2:type2,...)');
     125  WriteLn('                   where 0 - uint32, 1 - sint32, 2 - float, 3 - string, 4 - byte)');
    124126  WriteLn('  -d --display     Display DBC data');
    125127  WriteLn('  -q --sql_query   SQL select when entry is ID first column in dbc file and text1,text2... is texts columns');
  • tools/dbc_export/UDBC.pas

    r415 r443  
    1313
    1414type
    15   TDBCColumnType = (ctInt32, ctString, ctFloat);
     15  TDBCColumnType = (ctUInt32, ctSInt32, ctSingle, ctString, ctByte);
    1616
    1717  { TDBC }
     
    2626  public
    2727    Cells: array of array of Variant;
     28    ColumnFormat: array of TColumnType;
    2829    function DetectColumnType(Column: Integer): TDBCColumnType;
    2930    procedure LoadFromFile(FileName: string);
  • trunk/TranslationList.php

    r437 r443  
    249249function ShowGroupTypeList()
    250250{
    251   global $Database;
     251  global $Database, $User;
    252252 
    253253  $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `Group`');
     
    260260  $TableColumns = array(
    261261    array('Name' => 'Name', 'Title' => 'Jméno'),
    262     array('Name' => 'MangosTable', 'Title' => 'Tabulka MaNGOSu'),
    263     array('Name' => 'DBCFileName', 'Title' => 'DBC soubor'),
    264     array('Name' => 'LuaFileName', 'Title' => 'Lua soubor'),
     262    array('Name' => 'SourceType', 'Title' => 'Typ zdroje'),
     263    array('Name' => '', 'Title' => 'Zdroje'),
    265264    array('Name' => 'LastImport', 'Title' => 'Datum posledního importu'),
    266265    array('Name' => 'LastVersion', 'Title' => 'Verze posledního importu'),
     
    273272  while($Group = mysql_fetch_assoc($ID))
    274273  {
    275     echo('<tr><td><a href="?group='.$Group['Id'].'&amp;action=filter">'.$Group['Name'].'</a></td><td>'.$Group['MangosTable'].'</td><td>'.$Group['DBCFileName'].'</td><td>'.$Group['LuaFileName'].'</td><td><a title="Změny po posledním importu u vybrané překladové skupiny" href="log.php?group='.$Group['Id'].'&amp;type=11">'.HumanDate($Group['LastImport']).'</a></td><td>'.GetVersionWOW($Group['LastVersion']).'</td></tr>');
     274    echo('<tr><td><a href="?group='.$Group['Id'].'&amp;action=filter">'.$Group['Name'].'</a></td><td>'.$Group['SourceType'].'</td><td>');
     275    if($Group['MangosTable'] != '') echo($Group['MangosTable'].'.sql ');
     276    if($Group['DBCFileName'] != '') echo($Group['DBCFileName'].'.dbc ');
     277    if($Group['LuaFileName'] != '') echo($Group['LuaFileName'].'.lua ');
     278    echo('</td><td><a title="Změny po posledním importu u vybrané překladové skupiny" href="log.php?group='.$Group['Id'].'&amp;type=11">'.HumanDate($Group['LastImport']).'</a></td><td>'.GetVersionWOW($Group['LastVersion']).'</td></tr>');
    276279  }
    277280  echo('</table>');
    278   echo('<br /><a title="Záznam změn po importu" href="log.php?type=11">Záznam změn v textech při importu</a>'); 
     281  echo('<br /><a title="Záznam změn po importu" href="log.php?type=11">Záznam změn v textech při importu</a><br/>');
     282  //if($User->Licence(LICENCE_ADMIN)) echo('<a href="?action=groupadd">Přidat překladovou skupinu</a>');
    279283}
    280284
     
    321325}
    322326
     327function ShowGroupAdd()
     328{
     329  global $User;
     330 
     331  if($User->Licence(LICENCE_ADMIN))
     332  {
     333    echo('<h3>Vložení nové skupiny</h3>');
     334    echo('<form action="?action=groupadd" method="post">'.
     335    'Jméno: <input type="text" name="Name"/><br/>'.
     336    'Název tabulky: <input type="text" name="TablePrefix"/><br/>'.
     337    '</form>');
     338  } else echo('Nemáte oprávnění');
     339}
     340
    323341ShowPage();
    324342
     
    326344if($Action == 'filter') ShowMenu();
    327345else if($Action == 'grouplist') ShowGroupTypeList();
     346else if($Action == 'groupadd') ShowGroupAdd();
    328347else
    329348{
  • trunk/export/export.php

    r417 r443  
    247247      if(file_exists('../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc'))
    248248      {
    249         $I = 1;
    250         $Columns = '';
    251         foreach($TranslationTree[$Group['Id']]['Items'] as $Column)
    252         {
    253           $Columns .= '`T`.`'.$Column['Column'].'` AS `Text'.$I.'`, ';
    254           $I = $I + 1;
     249        // Load string column index list
     250        $DbResult = $this->Database->query('SELECT * FROM `GroupItem` JOIN `GroupItemDBC` ON `GroupItem`.`Id` = `GroupItemDBC`.`GroupItem` AND `GroupItemDBC`.`ClientVersion` = '.$this->ClientVersion['Id'].'  WHERE `GroupItem`.`Group` = '.$Group['Id']);     
     251        $ColumnIndexes = array();
     252        $ColumnFormat = array();
     253        while($DbRow = $DbResult->fetch_assoc())
     254        {
     255          $ColumnFormat[$DbRow['ColumnIndex']] = FORMAT_STRING;
     256          $ColumnIndexes[$DbRow['GroupItem']] = $DbRow['ColumnIndex'];
    255257        }
    256258
    257         $Query = $this->BuildQuery($Group, $Columns);
    258         $Query = str_replace('`', '\`', $Query);
    259         $Query = '"'.str_replace(' ', '\ ', $Query).'"';
     259        // Load all data into lookup table
     260        $LookupTable = array();
     261        $DbResult2 = $this->Database->query($this->BuildQuery($Group));
     262        while($DbRow = $DbResult2->fetch_assoc())
     263          $LookupTable[$DbRow['Entry']] = $DbRow;
    260264     
    261         $Params = '-u '.$Config['Database']['User'].' -p '.$Config['Database']['Password'].' -f ../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc -n '.$this->TempDir.'dbc/'.$Group['DBCFileName'].'.dbc -c '.GetDBCColumns($this->ClientVersion['Version'], $Group['DBCFileName']).' -q '.$Query;
    262      
    263         exec('./DBCExport '.$Params);
    264        
     265        // Open original DBC file
     266        $SourceDBCFile = new DBCFile();
     267        $SourceDBCFile->OpenFile('../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc', $ColumnFormat);
     268       
     269        // Create new DBC file
     270        if(!file_exists($this->TempDir.'dbc/')) mkdir ($this->TempDir.'dbc/', 0777, true);
     271        $NewDBCFile = new DBCFile();
     272        $NewDBCFile->CreateFile($this->TempDir.'dbc/'.$Group['DBCFileName'].'.dbc', $ColumnFormat);
     273        $NewDBCFile->SetRecordCount($SourceDBCFile->GetRecordCount());
     274        $NewDBCFile->SetFieldCount($SourceDBCFile->GetFieldCount());
     275        $NewDBCFile->Commit();
     276
     277        // Replace translated strings
     278        $OldProgress = -1;
     279        echo("\n\r");
     280        $RowCount = $SourceDBCFile->GetRecordCount();
     281        $FieldCount = $SourceDBCFile->GetFieldCount();       
     282        for($Row = 0; $Row < $RowCount; $Row++)
     283        {
     284          $Line = $SourceDBCFile->GetLine($Row);
     285          /*foreach($TranslationTree[$Group['Id']]['Items'] as $GroupItem)
     286          {
     287            if(array_key_exists($GroupItem['Id'], $ColumnIndexes) and array_key_exists($Row, $LookupTable))
     288              $Line[$ColumnIndexes[$GroupItem['Id']]] = $LookupTable[$Row][$GroupItem['Column']];
     289          }
     290          */
     291          $NewDBCFile->SetLine($Row, $Line);
     292         
     293          // Show completion progress
     294          $Progress = round($Row / $RowCount * 100);
     295          if($Progress != $OldProgress)
     296          {
     297            echo($Progress."%\r");
     298            $OldProgress = $Progress;
     299          }
     300        }   
     301        $NewDBCFile->Commit();             
    265302      } else echo('Zdrojový soubor '.'../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc'.' nenalezen.'."\n");
    266303    }
  • trunk/form.php

    r437 r443  
    4444     
    4545  if(($Line['Language'] <> 0) and ($LineUser['Name'] <> ''))
    46     echo('Přeložil: <strong>'.$LineUser['Name'].'</strong> <br />');
     46    echo('Přeložil: <strong>'.$LineUser['Name'].'</strong> dne '.HumanDate($Line['ModifyTime']).'<br />');
    4747  if(($Line['Take'] <> 0) and ($Line['Take'] <> $Line['ID']))
    4848  {
  • trunk/import/import.php

    r392 r443  
    99  function SetVersion($Version)
    1010  {
    11     global $Database;
     11    global $System;
    1212   
    13     $DbResult = $Database->SQLCommand('SELECT * FROM `ClientVersion` WHERE `Version` = "'.$Version.'"');
    14     $this->Version = mysql_fetch_assoc($DbResult); 
     13    $DbResult = $System->Database->query('SELECT * FROM `ClientVersion` WHERE `Version` = "'.$Version.'"');
     14    $this->Version = $DbResult->fetch_assoc(); 
    1515  }
    1616 
     
    199199  function ImportDBC()
    200200  {
    201     global $Database, $TranslationTree, $Config;
     201    global $System, $TranslationTree, $Config;
    202202 
    203203    echo('Načítání textů z DBC souboru...');
     
    205205    {
    206206      echo('<br />'.$this->Group['Name'].'<br />');
     207
     208      // Load string column index list
     209      $DbResult = $System->Database->query('SELECT * FROM `GroupItem` JOIN `GroupItemDBC` ON `GroupItem`.`Id` = `GroupItemDBC`.`GroupItem` AND `GroupItemDBC`.`ClientVersion` = '.$this->Version['Id'].'  WHERE `GroupItem`.`Group` = '.$this->Group['Id']);     
     210      $ColumnIndexes = array();
     211      $ColumnFormat = array();
     212      while($DbRow = $DbResult->fetch_assoc())
     213      {
     214        $ColumnFormat[$DbRow['ColumnIndex']] = FORMAT_STRING;
     215        $ColumnIndexes[$DbRow['GroupItem']] = $DbRow['ColumnIndex'];
     216      }
     217     
    207218      $DBCFile = new DBCFile();
    208           $DBCFile->OpenFile('../source/'.$this->Version['Version'].'/dbc/'.$this->Group['DBCFileName'].'.dbc', GetDBCColumns($this->Version['Version'], $this->Group['DBCFileName']));
     219      $DBCFile->OpenFile('../source/'.$this->Version['Version'].'/dbc/'.$this->Group['DBCFileName'].'.dbc', $ColumnFormat);
    209220      $ItemCount = $DBCFile->GetRecordCount();
    210221      $this->NewItemCount = 0;
    211       $Count = 0;
    212       for($i = 0; $i < $ItemCount; $i++)
     222      $Count = 0;     
     223       
     224      for($I = 0; $I < $ItemCount; $I++)
    213225      {
    214226        foreach($this->Group['Items'] as $GroupItem)
    215227        {
    216           $Value[$GroupItem['Column']] = addslashes($DBCFile->GetString($i, GetDBCColumnIndex($this->Version['Version'], $this->Group['DBCFileName'], $GroupItem['Column'])));
     228          $Value[$GroupItem['Column']] = addslashes($DBCFile->GetString($I, $ColumnIndexes[$GroupItem['Id']]));
    217229        }
    218         $Value['Entry'] = $DBCFile->GetUint($i, 0); 
     230        $Value['Entry'] = $DBCFile->GetUint($I, 0); 
    219231        $this->InsertItem($Value);
    220232        $Count++;
    221233      }   
    222234      echo('<br />Celkem: '.$Count.'  Nových: '.$this->NewItemCount.'<br />');
    223       $Database->SQLCommand('UPDATE `Group` SET `LastVersion` = "'.$this->Version['BuildNumber'].'", `LastImport` = NOW() WHERE `Id`='.$this->Group['Id']);
     235      $System->Database->query('UPDATE `Group` SET `LastVersion` = "'.$this->Version['BuildNumber'].'", `LastImport` = NOW() WHERE `Id`='.$this->Group['Id']);
    224236    }
    225237    echo('<strong>Dokončeno.</strong>');
  • trunk/import/index.php

    r388 r443  
    7878  echo($Order['Output']);
    7979
    80   $ID = $Database->SQLCommand('SELECT *, CONCAT(`MangosDatabase`, ".", `MangosTable`, ", ", `DBCFileName`, ".dbc, ", `LuaMPQFolder`, "/", `LuaFileName`, ".lua" ) AS `SourceName` FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']);
     80  $ID = $Database->SQLCommand('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']);
    8181  while($Group = mysql_fetch_assoc($ID))
    8282  {
    83     echo('<tr><td>'.$Group['Name'].'</td><td>'.$Group['SourceType'].'</td><td>'.$Group['SourceName'].'</td><td><a title="Změny po posledním importu u vybrané překladové skupiny" href="log.php?group='.$Group['Id'].'&amp;type=11">'.HumanDate($Group['LastImport']).'</a></td><td>'.GetVersionWOW($Group['LastVersion']).'</td><td><a href="?action=importgroup&amp;id='.$Group['Id'].'">Importovat</a></td></tr>');
     83    echo('<tr><td>'.$Group['Name'].'</td><td>'.$Group['SourceType'].'</td><td>');
     84    if($Group['MangosTable'] != '') echo($Group['MangosTable'].'.sql ');
     85    if($Group['DBCFileName'] != '') echo($Group['DBCFileName'].'.dbc ');
     86    if($Group['LuaFileName'] != '') echo($Group['LuaFileName'].'.lua ');
     87    echo('</td><td><a title="Změny po posledním importu u vybrané překladové skupiny" href="log.php?group='.$Group['Id'].'&amp;type=11">'.HumanDate($Group['LastImport']).'</a></td><td>'.GetVersionWOW($Group['LastVersion']).'</td><td><a href="?action=importgroup&amp;id='.$Group['Id'].'">Importovat</a></td></tr>');
    8488  }
    8589  echo('</table>');
  • trunk/includes/dbc.php

    r297 r443  
    44
    55define('NOT_DBC_FILE', 'Není DBC soubor.');
    6 define('FIELD_COUNT_NOT_MATCH', 'Počet sloupců neodpovídá délce formátu.');
    76define('RECORD_SIZE_NOT_MATCH', 'Velikost řádku neodpovídá zadanému formátu.');
    8  
     7
     8define('DBC_SIGNATURE', 0x43424457);
     9
     10define('FORMAT_UINT32', 0);
     11define('FORMAT_SINT32', 1);
     12define('FORMAT_SINGLE', 2);
     13define('FORMAT_STRING', 3);
     14define('FORMAT_BYTE', 4);
     15
    916class DBCFile extends FileStream
    1017{
     
    1421  private $StringList = array();
    1522  private $StringListOffset = array();
    16   private $Format;
     23  private $ColumnFormat; // Array (Index => Type)
     24  private $EndOffset; // Calculated RecordSize according columns type
    1725   
    1826  private $RecordSize;
     
    2129  private $FieldCount;
    2230     
    23   public function OpenFile($FileName, $Format)
     31  public function OpenFile($FileName, $ColumnFormat = array())
    2432  {
    2533    parent::OpenFile($FileName);
    2634   
    27     $this->Format = $Format;
    28     if($this->ReadUint() != 0x43424457) die(NOT_DBC_FILE);
     35    $this->ColumnFormat = $ColumnFormat;
     36    if($this->ReadUint() != DBC_SIGNATURE) die(NOT_DBC_FILE);
    2937       
    3038    $this->RecordCount = $this->ReadUint();
     
    3341    $this->StringBlockSize = $this->ReadUint();
    3442     
    35     if(strlen($this->Format) != $this->FieldCount)
    36       die(FIELD_COUNT_NOT_MATCH.' Počet v souboru:'.$this->FieldCount.' Počet v struktuře: '.strlen($Format));
    37      
    38     $this->GenerateOffsetTable($Format);
    39     if($this->Offsets[count($this->Offsets) - 1] != $this->RecordSize)
    40     die(RECORD_SIZE_NOT_MATCH.$this->Offsets[count($this->Offsets) - 1].' <> '.$this->RecordSize);
    41   }
    42 
    43   public function CreateFile($FileName, $Format)
     43    $this->GenerateOffsetTable();
     44    if($this->EndOffset != $this->RecordSize)
     45    die(RECORD_SIZE_NOT_MATCH.$this->EndOffset.' <> '.$this->RecordSize);
     46  }
     47
     48  public function CreateFile($FileName, $ColumnFormat = array())
    4449  {
    4550    parent::CreateFile($FileName);
    4651   
    47     $this->WriteUint(0x43424457);
     52    $this->WriteUint(DBC_SIGNATURE);
    4853       
    4954    $this->StringList = array();
    5055    $this->StringOffset = 1;
    51     $this->Format = $Format;
    52     $this->GenerateOffsetTable($Format);
    53     $this->FieldCount = strlen($Format);
     56    $this->ColumnFormat = $ColumnFormat;
     57    $this->FieldCount = 0;
     58    $this->GenerateOffsetTable();
    5459    $this->RecordCount = 0;
    55     $this->RecordSize = $this->Offsets[count($this->Offsets) - 1];
     60    $this->RecordSize = $this->EndOffset;
    5661    $this->StringBlockSize = 0;
    5762
     
    6267  }
    6368   
    64   private function GenerateOffsetTable($Format)
    65   {
    66     $this->Offsets = array();
    67     $this->Offsets[0] = 0;
    68     for($I = 0; $I < strlen($Format); $I++)
    69     {
    70       $this->Offsets[$I + 1] = $this->Offsets[$I];
    71       switch($Format[$I])
     69  private function GenerateOffsetTable()
     70  {
     71    // Preallocate array
     72    if($this->FieldCount > 0) $this->Offsets = array_fill(0, $this->FieldCount, 0);
     73      else $this->Offsets = array();
     74   
     75    $Offset = 0;
     76    $I = 0;
     77    while($I < $this->FieldCount)
     78    {
     79      $this->Offsets[$I] = $Offset;
     80      if(array_key_exists($I, $this->ColumnFormat)) $Format = $this->ColumnFormat[$I];
     81        else $Format = FORMAT_UINT32;
     82      switch($Format)
    7283      {
    73         case "b":
    74         case "X":
    75           $this->Offsets[$I + 1] += 1; 
    76           break;
    77         case "x":
    78         case "u":
    79         case "i":
    80         case "f":
    81         case "s":
    82           $this->Offsets[$I + 1] += 4; 
     84        case FORMAT_BYTE:
     85          $Offset += 1; 
     86          break;
     87        case FORMAT_UINT32:
     88        case FORMAT_SINT32:
     89        case FORMAT_SINGLE:
     90        case FORMAT_STRING:
     91          $Offset += 4; 
    8392          break;
    8493      }
     94      $I++;
    8595    }   
     96    $this->EndOffset = $Offset;
    8697  }
    8798 
     
    98109  }   
    99110   
    100   public function GetUint($Row, $Column)
     111  public function GetUInt($Row, $Column)
    101112  {
    102113    $this->SeekPosi($Row, $Column); 
     
    142153  public function GetString($Row, $Column)
    143154  {
    144   $Offset = $this->GetUint($Row, $Column);
     155    $Offset = $this->GetUint($Row, $Column);
    145156   
    146157    $Position = $this->HeaderSize + $this->RecordCount * $this->RecordSize + $Offset;
     
    172183  public function Commit()
    173184  {
     185    $this->SetSize($this->HeaderSize + $this->RecordSize * $this->RecordCount); // Preallocate file
    174186    $this->Seek(0);
    175     $this->WriteUint(0x43424457);
     187    $this->WriteUint(DBC_SIGNATURE);
    176188    $this->WriteUint($this->RecordCount);
    177189    $this->WriteUint($this->FieldCount);
     
    188200  public function GetLine($Row)
    189201  {
    190     $Line = array();
     202    // Preallocate array
     203    if($this->FieldCount > 0) $Line = array_fill(0, $this->FieldCount, 0);
     204      else $Line = array();
    191205    for($I = 0; $I < $this->FieldCount; $I++)
    192206    {
    193       switch($this->Format[$I])
     207      if(array_key_exists($I, $this->ColumnFormat)) $Format = $this->ColumnFormat[$I];
     208        else $Format = FORMAT_UINT32;
     209      switch($Format)
    194210      {
    195         case 'b':
     211        case FORMAT_BYTE:
    196212          $Line[$I] = $this->GetByte($Row, $I);
    197213          break;
    198         case 'u':
    199           $Line[$I] = $this->GetUint($Row, $I);
    200           break;
    201         case 'i':
     214        case FORMAT_UINT32:
     215          $Line[$I] = $this->GetUInt($Row, $I);
     216          break;
     217        case FORMAT_SINT32:
    202218          $Line[$I] = $this->GetInt($Row, $I);
    203219          break;
    204         case 'f':
     220        case FORMAT_SINGLE:
    205221          $Line[$i] = $this->GetFloat($Row, $I);
    206222          break;
    207         case 's':
     223        case FORMAT_STRING:
    208224          $Line[$I] = $this->GetString($Row, $I);
    209225          break;
    210         case 'x':
    211         case 'X':
    212226        default:
    213227          break;
     
    221235    for($I = 0; $I < $this->FieldCount; $I++)
    222236    {
    223       switch($this->Format[$I])
     237      if(array_key_exists($I, $this->ColumnFormat)) $Format = $this->ColumnFormat[$I];
     238        else $Format = FORMAT_UINT32;
     239      switch($Format)
    224240      {
    225         case 'b':
     241        case FORMAT_BYTE:
    226242          $this->SetByte($Row, $I, $Line[$I]);
    227243          break;
    228         case 'u':
     244        case FORMAT_UINT32:
    229245          $this->SetUint($Row, $I, $Line[$I]);
    230246          break;
    231         case 'i':
     247        case FORMAT_SINT32:
    232248          $this->SetInt($Row, $I, $Line[$I]);
    233249          break;
    234         case 'f':
     250        case FORMAT_SINGLE:
    235251          $this->SetFloat($Row, $I, $Line[$i]);
    236252          break;
    237         case 's':
     253        case FORMAT_STRING:
    238254          $this->SetString($Row, $I, $Line[$I]);
    239255          break;
    240         case 'x':
    241         case 'X':
    242256        default:
    243257          break;
     
    249263  public function GetLineCols($Row, $Columns)
    250264  {
    251     $Line = array();
     265    // Preallocate array
     266    if(count($Columns) > 0) $Line = array_fill(0, count($Columns), 0);
     267      else $Line = array();
    252268    for($I = 0; $I < count($Columns); $I++)
    253269    {
    254       switch($this->Format[$Columns[$I]])
     270      if(array_key_exists($I, $this->ColumnFormat)) $Format = $this->ColumnFormat[$I];
     271        else $Format = FORMAT_UINT32;
     272      switch($Format)
    255273      {
    256         case 'b':
     274        case FORMAT_BYTE:
    257275          $Line[$I] = $this->GetByte($Row, $Columns[$I]);
    258276          break;
    259         case 'u':
     277        case FORMAT_UINT32:
    260278          $Line[$I] = $this->GetUint($Row, $Columns[$I]);
    261279          break;
    262         case 'i':
     280        case FORMAT_SINT32:
    263281          $Line[$I] = $this->GetInt($Row, $Columns[$I]);
    264282          break;
    265         case 'f':
     283        case FORMAT_SINGLE:
    266284          $Line[$i] = $this->GetFloat($Row, $Columns[$I]);
    267285          break;
    268         case 's':
     286        case FORMAT_STRING:
    269287          $Line[$I] = $this->GetString($Row, $Columns[$I]);
    270288          break;
    271         case 'x':
    272         case 'X':
    273289        default:
    274290          break;
     
    285301  public function SetRecordCount($Value)
    286302  {
    287   $this->RecordCount = $Value;
     303    $this->RecordCount = $Value;
    288304  }
    289305
     
    292308    return($this->FieldCount);
    293309  }
     310
     311  public function SetFieldCount($Value)
     312  {
     313    $this->FieldCount = $Value;
     314    $this->GenerateOffsetTable();
     315    $this->RecordSize = $this->EndOffset;
     316  }
    294317}
    295318 
  • trunk/includes/error.php

    r357 r443  
    22
    33include_once('global_function.php');
     4
     5function EmptyErrorHandler($Number, $Message, $Filename, $LineNumber, $Variables)
     6{
     7}
    48
    59function CustomErrorHandler($Number, $Message, $Filename, $LineNumber, $Variables)
     
    711  global $Config;
    812 
     13  set_error_handler('EmptyErrorHandler');
     14
    915  $Date = date('Y-m-d H:i:s');    // časové razítko položky
    1016  $ErrorType = array
     
    7581    if((E_ERROR | E_PARSE) & $Number) die();
    7682  }
     83  set_error_handler('CustomErrorHandler');
    7784}
    7885
  • trunk/includes/global_function.php

    r436 r443  
    238238    $Result[$DbRow['Id']] = $DbRow;
    239239  }
    240   $DbResult = $Database->SQLCommand('SELECT * FROM `GroupItem` ORDER BY `DBCColumnIndex`');
     240  $DbResult = $Database->SQLCommand('SELECT * FROM `GroupItem` ORDER BY `Group`, `Sequence`');
    241241  while($DbRow = mysql_fetch_assoc($DbResult))
    242242  {
     
    316316  }
    317317  return($VersionsWOW[$BuildNumber]);
    318 }
    319 
    320 function GetDBCColumns($Version, $DBCFileName)
    321 {
    322   global $Database, $DBCColumns;
    323  
    324   if(isset($DBCColumns[$Version][$DBCFileName]) == false)
    325   {
    326     $sql = 'SELECT `DBCColumns_'.$DBCFileName.'` AS `DBCColumns` FROM `ClientVersion` WHERE `Version` = "'.$Version.'"';
    327     $DbRow = mysql_fetch_assoc($Database->SQLCommand($sql));
    328     $DBCColumns[$Version][$DBCFileName] = $DbRow['DBCColumns'];
    329   }
    330   return($DBCColumns[$Version][$DBCFileName]);
    331 }
    332 
    333 function GetDBCColumnIndex($Version, $DBCFileName, $Column)
    334 {
    335   global $Database, $DBCColumnIndex;
    336  
    337   if(isset($DBCColumnIndex[$Version][$DBCFileName][$Column]) == false)
    338   {
    339     $sql = 'SELECT `'.$DBCFileName.'_'.$Column.'` AS `DBCColumns` FROM `ClientVersion` WHERE `Version` = "'.$Version.'"';
    340     $DbRow = mysql_fetch_assoc($Database->SQLCommand($sql));
    341     $DBCColumnIndex[$Version][$DBCFileName][$Column] = $DbRow['DBCColumns'];
    342   }
    343   return($DBCColumnIndex[$Version][$DBCFileName][$Column]);
    344318}
    345319
  • trunk/includes/stream.php

    r384 r443  
    125125  }
    126126
     127  public function SetSize($Size)
     128  {
     129    return(ftruncate($this->Handle, $Size));
     130  }
     131
    127132  public function EOF()
    128133  {
  • trunk/sql/text_table_init_structure.sql

    r376 r443  
    11CREATE TABLE IF NOT EXISTS `Text` (
    2   `ID` int(11) unsigned NOT NULL auto_increment,
     2  `ID` int(11) unsigned NOT NULL AUTO_INCREMENT,
    33  `Entry` int(11) NOT NULL,
    4   `Language` int(11) NOT NULL default '0',
     4  `Language` int(11) NOT NULL DEFAULT '0',
    55  `User` int(11) NOT NULL,
    66  `Complete` int(11) NOT NULL,
     7  `CompleteParts` int(11) NOT NULL,
    78  `Take` int(11) NOT NULL,
    89  `VersionStart` int(11) NOT NULL DEFAULT '8606',
    910  `VersionEnd` int(11) NOT NULL DEFAULT '8606',
    10   PRIMARY KEY  (`ID`),
     11  `ModifyTime` datetime NOT NULL,
     12  PRIMARY KEY (`ID`),
    1113  KEY `Entry` (`Entry`),
    1214  KEY `User` (`User`),
    1315  KEY `Take` (`Take`),
    14   KEY `Language` ( `Language` ),
    15   KEY `Complete` ( `Complete` )
     16  KEY `Language` (`Language`),
     17  KEY `Complete` (`Complete`),
    1618  KEY `VersionStart` (`VersionStart`),
    17   KEY `VersionEnd` (`VersionEnd`)
     19  KEY `VersionEnd` (`VersionEnd`),
     20  KEY `ModifyTime` (`ModifyTime`)
    1821) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
Note: See TracChangeset for help on using the changeset viewer.