Changeset 385 for trunk


Ignore:
Timestamp:
Mar 14, 2010, 5:24:06 PM (15 years ago)
Author:
george
Message:
  • Opraveno: Import a export gossip_menu_option, kde je identifikační klíč řádku dán dvěma slouci. Do importu a exportu SQL doplněna podpora pro MangosTableIndex vytvořený více sloupci a spojený do řetězce přes CONCAT.
Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/export/export.php

    r380 r385  
    9999          $Values = '';
    100100          foreach($TranslationTree[$Group['Id']]['Items'] as $GroupItem)
     101          if($GroupItem['Column'] != $Group['PrimaryKeyItem']) // Do not update primary key
    101102          {
    102103            if($GroupItem['MangosColumn'] == '') $GroupItem['MangosColumn'] = $GroupItem['Column'];
     
    104105          }
    105106          $Values = substr($Values, 2);
    106           $Buffer .= 'UPDATE `'.$Group['MangosTable'].'` SET '.$Values.' WHERE `'.$Group['MangosTableIndex'].'` = '.$Line['Entry'].';'."\n";
     107
     108          $ColumnItems = explode(',', $Group['MangosTableIndex']);
     109          if(count($ColumnItems) > 1)
     110          {
     111            $Where = 'CONCAT(';
     112            foreach($ColumnItems as $ColumnItem)
     113              $Where .= '`'.$ColumnItem.'`, "_", ';
     114            $Where = substr($Where, 0, -7).')';
     115          } else $Where = '`'.$Group['MangosTableIndex'].'`';
     116          $Where .= ' = "'.$Line[$Group['PrimaryKeyItem']].'";'."\n";
     117          $Buffer .= 'UPDATE `'.$Group['MangosTable'].'` SET '.$Values.' WHERE '.$Where;
    107118        }     
    108119      }
  • trunk/import/import.php

    r383 r385  
    55  var $Version; 
    66  var $Group;
     7  var $NewItemCount;
    78 
    89  function SetVersion($Version)
     
    2526    $Columns = substr($Columns, 1);
    2627    $Where = ' (`'.$this->Group['PrimaryKeyItem'].'` = "'.$Value[$this->Group['PrimaryKeyItem']].'")';
     28    //print_r($Value);
    2729 
    2830    $DbResult2 = $Database->SQLCommand('SELECT `VersionEnd`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND (`Language`=0) ORDER BY `VersionStart` DESC LIMIT 1');
     31    //echo('SELECT `VersionEnd`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND (`Language`=0) ORDER BY `VersionStart` DESC LIMIT 1');
    2932    if(isset($DbResult2) and (mysql_num_rows($DbResult2) > 0))
    3033    {
     
    5457    {
    5558      // Insert new text
    56       $Entry = 1;
    57       $DbResult = $Database->SQLCommand('SELECT MAX(`Entry`) FROM `'.$this->Group['TablePrefix'].'`');
    58       if(mysql_num_rows($DbResult) > 0)
    59       {
    60         $DbRow = mysql_fetch_row($DbResult);
    61         $Entry += $DbRow[0];
    62       }           
     59      if(is_numeric($Value[$this->Group['PrimaryKeyItem']])) $Value['Entry'] = $Value[$this->Group['PrimaryKeyItem']];
     60      else
     61      {
     62        // Get new unused Entry for tables without numeric id
     63        $Value['Entry'] = 1;
     64        $DbResult = $Database->SQLCommand('SELECT MAX(`Entry`) FROM `'.$this->Group['TablePrefix'].'`');
     65        if(mysql_num_rows($DbResult) > 0)
     66        {
     67          $DbRow = mysql_fetch_row($DbResult);
     68          $Value['Entry'] += $DbRow[0];
     69        }           
     70      }
    6371      $Columns = '`Entry`, `Language`, `VersionStart`, `VersionEnd`';
    64       $Values = $Entry.', 0, '.$BuildNumber.', '.$BuildNumber;
     72      $Values = $Value['Entry'].', 0, '.$this->Version['BuildNumber'].', '.$this->Version['BuildNumber'];
    6573      foreach($this->Group['Items'] as $GroupItem)
    6674      {
     
    7078      $Database->SQLCommand('INSERT `'.$this->Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')');
    7179      echo('+ ');
    72       $NewCount++;
    73       WriteLog('Text <a href="form.php?group='.$this->Group['Id'].'&amp;ID='.mysql_insert_id().'">'.mysql_insert_id().'</a> ('.$Entry.') ze skupiny '.$this->Group['Name'].' byl v nové verzi '.$this->Version['Version'].' přidán.', LOG_TYPE_IMPORT);
     80      $this->NewItemCount++;
     81      WriteLog('Text <a href="form.php?group='.$this->Group['Id'].'&amp;ID='.mysql_insert_id().'">'.mysql_insert_id().'</a> ('.$Value['Entry'].') ze skupiny '.$this->Group['Name'].' byl v nové verzi '.$this->Version['Version'].' přidán.', LOG_TYPE_IMPORT);
    7482    }
    7583  }
     
    8795          $File = new FileStream();
    8896          $File->OpenFile('../source/'.$this->Version['Version'].'/lua/'.$this->Group['LuaFileName'].'.lua');
    89           $NewCount = 0;
     97          $this->NewItemCount = 0;
    9098          $Count = 0;
    9199          while(!$File->EOF())
     
    117125            $Count++;
    118126          }
    119           echo('<br />Celkem: '.$Count.'  Nových: '.$NewCount.'<br />');
    120           $Database->SQLCommand('UPDATE `Group` SET `LastVersion` = "'.$this->Version['BuildNumber'].'", `LastImport` = NOW() WHERE `Id`='.$Group['Id']);
     127          echo('<br />Celkem: '.$Count.'  Nových: '.$this->NewItemCount.'<br />');
     128          $Database->SQLCommand('UPDATE `Group` SET `LastVersion` = "'.$this->Version['BuildNumber'].'", `LastImport` = NOW() WHERE `Id`='.$this->Group['Id']);
    121129        } else echo('Již importován pro verzi '.$this->Version['Version']);
    122130      } else echo('Není definováno jméno zdrojového souboru');
     
    201209          $DBCFile->OpenFile('../source/'.$this->Version['Version'].'/dbc/'.$this->Group['DBCFileName'].'.dbc', GetDBCColumns($this->Version['Version'], $this->Group['DBCFileName']));
    202210      $ItemCount = $DBCFile->GetRecordCount();
    203       $NewCount = 0;
     211      $this->NewItemCount = 0;
    204212      $Count = 0;
    205213      for($i = 0; $i < $ItemCount; $i++)
     
    213221        $Count++;
    214222      }   
    215       echo('<br />Celkem: '.$Count.'  Nových: '.$NewCount.'<br />');
     223      echo('<br />Celkem: '.$Count.'  Nových: '.$this->NewItemCount.'<br />');
    216224      $Database->SQLCommand('UPDATE `Group` SET `LastVersion` = "'.$this->Version['BuildNumber'].'", `LastImport` = NOW() WHERE `Id`='.$this->Group['Id']);
    217225    }
     
    235243    global $Database, $TranslationTree, $PatchVersion, $Config;
    236244 
    237     $files = scandir('../source/'.$this->Version['Version'].'/sql/', 1);
    238     unset($files[count($files) - 1]);
    239     unset($files[count($files) - 1]);
    240      
    241245    $File = new FileStream();
    242     $File->OpenFile('../source/'.$this->Version['Version'].'/sql/'.$files[0]);
    243     $NewCount = 0;
     246    $File->OpenFile('../source/'.$this->Version['Version'].'/sql/'.$this->Group['MangosTable'].'.sql');
     247    $this->NewItemCount = 0;
    244248    $Count = 0;
    245     $folow_structure = False;
     249    $folow_structure = false;
    246250    $i = 0;
    247251    while((!$File->EOF()))
    248252    {
    249253      $Line = $File->ReadLine();
    250       //Struktura
     254      // Struktura
    251255      if(strpos($Line, 'CREATE TABLE `'.$this->Group['MangosTable'].'`') !== false)
    252256      {
    253257        $Line = '';
    254         $folow_structure = True;
     258        $folow_structure = true;
    255259        $i = 0;
    256260      }
    257261      if((strpos($Line, ';') !== false) and ($folow_structure == true))
    258262      {
    259         $folow_structure = False;
     263        $folow_structure = false;
    260264        //  echo ('Struktura: <br />');
    261265        //  print_r($structure);
     
    301305              $LinePart = substr($LinePart, strlen($value_buff) + 2);
    302306            }
    303             if (($value_buff != 'null') and ($value_buff != 'NULL'))
     307            if(($value_buff != 'null') and ($value_buff != 'NULL'))
    304308            {
    305309              $str = '';
     
    322326            //  echo ($column.'-"'.$Value[$column].'"<br>');
    323327          }
    324           $Value[$this->Group['PrimaryKeyItem']] = $Value[$this->Group['MangosTableIndex']];
     328          foreach($this->Group['Items'] as $GroupItem)
     329          {
     330            if($GroupItem['MangosColumn'] != '')
     331              $Value[$GroupItem['Column']] = $Value[$GroupItem['MangosColumn']];
     332          }
     333           
     334          // Get multicolumn value
     335          $Columns = explode(',', $this->Group['MangosTableIndex']);
     336          $ColumnValue = '';
     337          foreach($Columns as $Column)
     338            $ColumnValue .= '_'.$Value[$Column];
     339          $ColumnValue = substr($ColumnValue, 1);         
     340          $Value[$this->Group['PrimaryKeyItem']] = $ColumnValue;
    325341          $this->InsertItem($Value);
    326342          $Count++;
     
    328344      }
    329345    }
    330     echo('<br />Celkem: '.$Count.'  Nových: '.$NewCount.'<br />');
     346    echo('<br />Celkem: '.$Count.'  Nových: '.$this->NewItemCount.'<br />');
    331347  $Database->SQLCommand('UPDATE `Group` SET `LastVersion` = "'.$this->Version['BuildNumber'].'", `LastImport` = NOW() WHERE `Id`='.$this->Group['Id']);
    332348  }
  • trunk/import/index.php

    r383 r385  
    6969    array('Name' => 'SourceType', 'Title' => 'Typ zdroje'),
    7070    array('Name' => 'SourceName', 'Title' => 'Jméno zdroje'),
     71    array('Name' => 'LastImport', 'Title' => 'Datum'),
     72    array('Name' => 'LastVersion', 'Title' => 'Verze'),
    7173    array('Name' => '', 'Title' => 'Akce'),
    7274  );
     
    7880  while($Group = mysql_fetch_assoc($ID))
    7981  {
    80     echo('<tr><td>'.$Group['Name'].'</td><td>'.$Group['SourceType'].'</td><td>'.$Group['SourceName'].'</td><td><a href="?action=importgroup&amp;id='.$Group['Id'].'">Imporotovat</a></td></tr>');
     82    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>');
    8183  }
    8284  echo('</table>');
  • trunk/sql/updates/382.sql

    r382 r385  
    1313UPDATE  `Group` SET  `SourceType` =  'dbc' WHERE  `Group`.`Id` =21;
    1414UPDATE  `Group` SET  `SourceType` =  'dbc' WHERE  `Group`.`Id` =13;
     15UPDATE  `Group` SET  `SourceType` =  'dbc' WHERE  `Group`.`Id` =22;
     16UPDATE  `Group` SET  `SourceType` =  'lua' WHERE  `Group`.`Id` =23;
    1517
    1618ALTER TABLE  `Group` DROP  `DBCColumns`;
Note: See TracChangeset for help on using the changeset viewer.