Ignore:
Timestamp:
Mar 6, 2023, 12:16:38 PM (14 months ago)
Author:
chronos
Message:
  • Fixed: Export error due to PHP 8.1 deprecated code.
  • Modified: Code cleanup.
File:
1 edited

Legend:

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

    r893 r894  
    3939
    4040    $Output .= '<h3>'.T('List of export').'</h3>'.
    41         $PageList['Output'];
     41      $PageList['Output'];
    4242
    4343    $TableColumns = array(
    44         array('Name' => 'TimeCreate', 'Title' => T('Time made')),
    45         array('Name' => 'UserName', 'Title' => T('Translator')),
    46         array('Name' => 'Title', 'Title' => T('Name od export')),
    47         //  array('Name' => 'UserCount', 'Title' => 'Vybraných překladatelů'),
    48         //  array('Name' => 'GroupCount', 'Title' => 'Překladových skupin'),
    49         array('Name' => 'OutputType', 'Title' => T('Type of output')),
    50         array('Name' => 'ClientVersion', 'Title' => T('Client version')),
    51         array('Name' => 'UsedCount', 'Title' => T('Viewed count')),
    52         array('Name' => '', 'Title' => T('Action')),
     44      array('Name' => 'TimeCreate', 'Title' => T('Time made')),
     45      array('Name' => 'UserName', 'Title' => T('Translator')),
     46      array('Name' => 'Title', 'Title' => T('Name od export')),
     47      //  array('Name' => 'UserCount', 'Title' => 'Vybraných překladatelů'),
     48      //  array('Name' => 'GroupCount', 'Title' => 'Překladových skupin'),
     49      array('Name' => 'OutputType', 'Title' => T('Type of output')),
     50      array('Name' => 'ClientVersion', 'Title' => T('Client version')),
     51      array('Name' => 'UsedCount', 'Title' => T('Viewed count')),
     52      array('Name' => '', 'Title' => T('Action')),
    5353    );
    5454    $Order = GetOrderTableHeader($TableColumns, 'TimeCreate', 1);
    5555    $Output .= '<table class="BaseTable">'.
    56         $Order['Output'];
     56      $Order['Output'];
    5757
    5858    $DbResult = $this->System->Database->query('SELECT `User`.`Name` AS `UserName`, `Export`.`Id`, `Export`.`TimeCreate`, `Export`.`Title`, `Export`.`User`, `Export`.`UsedCount`, '.
     
    7070      if ($User->Id != null) $Action .= ' <a href="?Action=Clone&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a>';
    7171      $Output .= '<tr><td>'.HumanDate($Export['TimeCreate']).'</td>'.
    72           '<td><a href="'.$this->System->Link('/user/?user='.$Export['User']).'">'.$Export['UserName'].'</a></td>'.
    73           '<td>'.htmlspecialchars($Export['Title']).'</td>'.
    74           '<td>'.$Export['OutputType'].'</td>'.
    75           '<td><a href="'.$this->System->Link('/client-version/?action=item&amp;id='.$Export['ClientVersionId']).'">'.$Export['ClientVersion'].'</a></td>'.
    76           '<td>'.$Export['UsedCount'].'</td>'.
    77           '<td>'.$Action.'</td></tr>';
     72        '<td><a href="'.$this->System->Link('/user/?user='.$Export['User']).'">'.$Export['UserName'].'</a></td>'.
     73        '<td>'.htmlspecialchars($Export['Title']).'</td>'.
     74        '<td>'.$Export['OutputType'].'</td>'.
     75        '<td><a href="'.$this->System->Link('/client-version/?action=item&amp;id='.$Export['ClientVersionId']).'">'.$Export['ClientVersion'].'</a></td>'.
     76        '<td>'.$Export['UsedCount'].'</td>'.
     77        '<td>'.$Action.'</td></tr>';
    7878    }
    7979    $Output .= '</table>'.
    80         $PageList['Output'];
     80      $PageList['Output'];
    8181
    8282    return $Output;
     
    9393      {
    9494        $Output = '<form action="?Action=CreateFinish" method="post">'.
    95             '<fieldset><legend>'.T('Creation of new export').'</legend>'.
    96             '<table><tr><td>'.T('Identification').':</td><td><input type="text" name="Title" /></td></tr>'.
    97             '<tr><td>'.T('Description').':</td><td><textarea name="Description" cols="54" rows="10"></textarea></td></tr>'.
    98             '<tr><td colspan="2"><input type="submit" value="'.T('Create').'" /></td></tr>'.
    99             '</table></fieldset></form>';
     95          '<fieldset><legend>'.T('Creation of new export').'</legend>'.
     96          '<table><tr><td>'.T('Identification').':</td><td><input type="text" name="Title" /></td></tr>'.
     97          '<tr><td>'.T('Description').':</td><td><textarea name="Description" cols="54" rows="10"></textarea></td></tr>'.
     98          '<tr><td colspan="2"><input type="submit" value="'.T('Create').'" /></td></tr>'.
     99          '</table></fieldset></form>';
    100100      } else $Output = ShowMessage(sprintf(T('You can\'t create another export. Max for one user is %d.'), Core::Cast($this->System)->Config['MaxExportPerUser']), MESSAGE_CRITICAL);
    101101    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
     
    152152  function SaveAllUsers()
    153153  {
    154    global $System;
    155       $Export = new Export($System);
    156       $Export->Id = $_GET['ExportId'];
    157       $Export->SaveAllUsers();
    158 
     154    $Export = new Export($this->System);
     155    $Export->Id = $_GET['ExportId'];
     156    $Export->SaveAllUsers();
    159157  }
    160158
     
    162160  {
    163161    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    164     $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    165162
    166163    $Output = '';
     
    174171    {
    175172      if ($_POST['Operation'] == 'Save')
    176       {
    177         //print_r($_POST);
     173      {       
    178174        // Update user selection page
    179175        foreach ($_POST as $Index => $Value)
     
    197193        }
    198194
    199         if (array_key_exists('AllUsers', $_POST)) {
    200             //add allusers to export
    201             $this->System->Database->query('UPDATE `Export` SET `AllUsers`=1 WHERE `Id`='.$_GET['ExportId']);
    202 
    203             //update export stat
    204             $Export['AllUsers'] = 1;
    205             $this->SaveAllUsers();
    206           } else {
    207             //update export stat
    208             $Export['AllUsers'] = 0;
    209             $this->System->Database->query('UPDATE `Export` SET `AllUsers`=0 WHERE `Id`='.$_GET['ExportId']);
    210           }
     195        if (array_key_exists('AllUsers', $_POST))
     196        {
     197          //add allusers to export
     198          $this->System->Database->query('UPDATE `Export` SET `AllUsers`=1 WHERE `Id`='.$_GET['ExportId']);
     199
     200          //update export stat
     201          $Export['AllUsers'] = 1;
     202          $this->SaveAllUsers();
     203        } else
     204        {
     205          //update export stat
     206          $Export['AllUsers'] = 0;
     207          $this->System->Database->query('UPDATE `Export` SET `AllUsers`=0 WHERE `Id`='.$_GET['ExportId']);
     208        }
    211209
    212210        // Recalculate sequence number
     
    218216
    219217    $TableColumns = array(
    220         array('Name' => 'Name', 'Title' => T('Name')),
    221         array('Name' => 'TranslatedCount', 'Title' => T('Translated count')),
    222         array('Name' => 'XP', 'Title' => T('Level')),
    223         array('Name' => 'XP', 'Title' => T('Experience')),
    224         array('Name' => '', 'Title' => T('Select')),
    225         array('Name' => 'Sequence2', 'Title' => T('Order')),
     218      array('Name' => 'Name', 'Title' => T('Name')),
     219      array('Name' => 'TranslatedCount', 'Title' => T('Translated count')),
     220      array('Name' => 'XP', 'Title' => T('Level')),
     221      array('Name' => 'XP', 'Title' => T('Experience')),
     222      array('Name' => '', 'Title' => T('Select')),
     223      array('Name' => 'Sequence2', 'Title' => T('Order')),
    226224    );
    227225    $Order = GetOrderTableHeader($TableColumns, 'TranslatedCount', 1);
    228226    if ($Order['Column'] != 'Sequence2') $InitialOrder = ', '.substr($Order['SQL'], 10);
    229     else $InitialOrder = '';
     227      else $InitialOrder = '';
    230228
    231229    $Query = 'SELECT (@I := @I + 1) AS `Sequence2`, `TT`.* FROM (SELECT `ExportUser`.`Sequence`, `T`.`ID`, `T`.`TranslatedCount`, `T`.`Name`, `T`.`XP` FROM (SELECT `User`.`ID`, `User`.`Name`, `User`.`XP`, `TranslatedCount` FROM `User`) AS T';
     
    238236
    239237    $Output .= '<form name="Translators" action="?Action=View&amp;ExportId='.$_GET['ExportId'].'" method="post">'.
    240         '<h3>'.T('Translators').'</h3>';
     238      '<h3>'.T('Translators').'</h3>';
    241239    if ($Editable)
    242240    {
    243241      $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
    244           '<input type="hidden" name="Operation" value="Save"/><br />'.
    245           ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' '.T('Select all on page').'</span> <br />'.
    246           ' <span>'.CheckBox('AllUsers', $Export['AllUsers']).' '.T('Export allways from all users').'</span> '.
    247           '<br />'.
    248           T('Select users from list which you want to export from. And edit their order.').'<br />'.
    249           T('Order is done by numeric value which is can be edit to desirable order. Lines with same number will be renumbered in ascending order.');
     242        '<input type="hidden" name="Operation" value="Save"/><br />'.
     243        ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' '.T('Select all on page').'</span> <br />'.
     244        ' <span>'.CheckBox('AllUsers', $Export['AllUsers']).' '.T('Export allways from all users').'</span> '.
     245        '<br />'.
     246        T('Select users from list which you want to export from. And edit their order.').'<br />'.
     247        T('Order is done by numeric value which is can be edit to desirable order. Lines with same number will be renumbered in ascending order.');
    250248    }
    251249
     
    264262      $Sequence = '<input type="text" name="seq'.$UserLine['ID'].'" style="text-align: center; width: 40px;" value="'.$UserLine['Sequence2'].'"'.$DisabledInput[$Editable].'/>';
    265263      $Output .= '<tr>'.
    266           '<td><a href="'.$this->System->Link('/TranslationList.php?user='.$UserLine['ID'].'&amp;state=2&amp;group=0').'" title="Zobrazit všechny jeho přeložené texty">'.$UserLine['Name'].'</a></td>'.
    267           '<td>'.$UserLine['TranslatedCount'].'</td>'.
    268           '<td>'.$XP['Level'].'</td>'.
    269           '<td>'.ProgressBar(150, round($XP['XP'] / $XP['MaxXP'] * 100, 2), $XP['XP'].' / '.$XP['MaxXP']).'</td>'.
    270           '<td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>';
     264        '<td><a href="'.$this->System->Link('/TranslationList.php?user='.$UserLine['ID'].'&amp;state=2&amp;group=0').'" title="Zobrazit všechny jeho přeložené texty">'.$UserLine['Name'].'</a></td>'.
     265        '<td>'.$UserLine['TranslatedCount'].'</td>'.
     266        '<td>'.$XP['Level'].'</td>'.
     267        '<td>'.ProgressBar(150, round($XP['XP'] / $XP['MaxXP'] * 100, 2), $XP['XP'].' / '.$XP['MaxXP']).'</td>'.
     268        '<td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>';
    271269    }
    272270    $Output .= '</table>'.
    273         '</form>'.
    274         $PageList['Output'];
     271      '</form>'.
     272      $PageList['Output'];
    275273    return $Output;
    276274  }
     
    288286
    289287    if (array_key_exists('Operation', $_POST))
     288    {
    290289      if ($_POST['Operation'] == 'Save')  if ($Editable and array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
    291290      {
     
    301300        $Output .= ShowMessage('Nastavení uloženo.');
    302301      }
    303 
    304       if ($Export['WithDiacritic'] == 1) $WithDiacritic = ' checked="checked"';
     302    }
     303
     304    if ($Export['WithDiacritic'] == 1) $WithDiacritic = ' checked="checked"';
    305305      else $WithDiacritic = '';
    306       $Output .= '<form action="?Action=View&amp;Tab=0&amp;ExportId='.$Export['Id'].'" method="post">'.
    307           '<table>';
    308       if ($User->Id != null)
    309       {
    310         $Output .= '<input type="hidden" name="Operation" value="Save"/>'.
    311             '<tr><td colspan="2">';
    312         if ($Editable) $Output .= ' <input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>';
    313         $Output .= ' <a href="?Action=Clone&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a> ';
    314         if ($User->Licence(LICENCE_ADMIN))
    315           $Output .= CheckBox('Featured', $Export['Featured'], '', 'CheckBox', !$Editable). ' '.T('Recommended').' ';
    316         $Output .= '</td></tr>';
    317       }
    318       $Output .= '<tr><td>'.T('Identification').':</td><td><input type="text" style="width: 400px" name="Title" value="'.htmlspecialchars($Export['Title']).'"'.$DisabledInput[$Editable].'/></td></tr>'.
    319           '<tr><td>'.T('Description').':</td><td><textarea name="Description" cols="54" rows="10"'.$DisabledTextArea[$Editable].'>'.htmlspecialchars($Export['Description']).'</textarea></td></tr>'.
    320           '<tr><td>'.T('With diacritics').'</td><td><input type="checkbox" name="WithDiacritic" '.$WithDiacritic.''.$DisabledInput[$Editable].'/></td></tr>'.
    321           '</table></form>';
    322       return $Output;
     306    $Output .= '<form action="?Action=View&amp;Tab=0&amp;ExportId='.$Export['Id'].'" method="post">'.
     307      '<table>';
     308    if ($User->Id != null)
     309    {
     310      $Output .= '<input type="hidden" name="Operation" value="Save"/>'.
     311        '<tr><td colspan="2">';
     312      if ($Editable) $Output .= ' <input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>';
     313      $Output .= ' <a href="?Action=Clone&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a> ';
     314      if ($User->Licence(LICENCE_ADMIN))
     315        $Output .= CheckBox('Featured', $Export['Featured'], '', 'CheckBox', !$Editable). ' '.T('Recommended').' ';
     316      $Output .= '</td></tr>';
     317    }
     318    $Output .= '<tr><td>'.T('Identification').':</td><td><input type="text" style="width: 400px" name="Title" value="'.htmlspecialchars($Export['Title']).'"'.$DisabledInput[$Editable].'/></td></tr>'.
     319      '<tr><td>'.T('Description').':</td><td><textarea name="Description" cols="54" rows="10"'.$DisabledTextArea[$Editable].'>'.htmlspecialchars($Export['Description']).'</textarea></td></tr>'.
     320      '<tr><td>'.T('With diacritics').'</td><td><input type="checkbox" name="WithDiacritic" '.$WithDiacritic.''.$DisabledInput[$Editable].'/></td></tr>'.
     321      '</table></form>';
     322    return $Output;
    323323  }
    324324
     
    326326  {
    327327    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    328     $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    329328
    330329    $Output = '';
     
    339338      if ($_POST['Operation'] == 'Save')
    340339      {
    341         //print_r($_POST);
    342340        // Update user selection page
    343341        foreach ($_POST as $Index => $Value)
     
    377375
    378376    $TableColumns = array(
    379         array('Name' => 'Name', 'Title' => T('Name')),
    380         array('Name' => '', 'Title' => T('Select')),
    381         array('Name' => 'Sequence2', 'Title' => T('Order')),
     377      array('Name' => 'Name', 'Title' => T('Name')),
     378      array('Name' => '', 'Title' => T('Select')),
     379      array('Name' => 'Sequence2', 'Title' => T('Order')),
    382380    );
    383381    $Order = GetOrderTableHeader($TableColumns, 'Sequence2');
     
    394392
    395393    $Output .= $PageList['Output'].
    396     '<table class="BaseTable">'.
     394      '<table class="BaseTable">'.
    397395    $Order['Output'];
    398396
     
    410408    }
    411409    $Output .= '</table>'.
    412         '</form>'.
    413         $PageList['Output'];
     410      '</form>'.
     411      $PageList['Output'];
    414412    return $Output;
    415413  }
     
    425423    $Export = $DbRows->fetch_assoc();
    426424    if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    427     else $Editable = false;
     425      else $Editable = false;
    428426
    429427    if (array_key_exists('Operation', $_POST))
    430428    {
    431429      if ($_POST['Operation'] == 'Save')
    432       {
    433         //print_r($_POST);
     430      {       
    434431        // Update user selection page
    435432        foreach ($_POST as $Index => $Value)
     
    459456          if (array_key_exists('item'.$Column['Id'], $_POST)) $Selected = true;
    460457          else $Selected = false;
    461           //we will save only forbitten collums and need to be visible
     458          // we will save only forbitten collums and need to be visible
    462459          $Selected = !$Selected;
    463460          if (!$Column['Visible']) $Selected = false;
    464461
    465             $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `GroupItem`='.$Column['Id'];
    466             $DbResult = $this->System->Database->query('SELECT * FROM `ExportGroupItem` '.$Condition);
    467             if ($DbResult->num_rows > 0)
    468             {
    469               if (!$Selected) $this->System->Database->query('DELETE FROM `ExportGroupItem` '.$Condition);
    470             } else
    471             {
    472               if ($Selected) $this->System->Database->query('INSERT INTO `ExportGroupItem` (`Export`, `GroupItem`) VALUES ('.$_GET['ExportId'].', '.$Column['Id'].')');
    473             }
    474 
     462          $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `GroupItem`='.$Column['Id'];
     463          $DbResult = $this->System->Database->query('SELECT * FROM `ExportGroupItem` '.$Condition);
     464          if ($DbResult->num_rows > 0)
     465          {
     466            if (!$Selected) $this->System->Database->query('DELETE FROM `ExportGroupItem` '.$Condition);
     467          } else
     468          {
     469            if ($Selected) $this->System->Database->query('INSERT INTO `ExportGroupItem` (`Export`, `GroupItem`) VALUES ('.$_GET['ExportId'].', '.$Column['Id'].')');
     470          }
    475471        }
    476472      }
     
    484480
    485481    $TableColumns = array(
    486         array('Name' => '', 'Title' => T('Select')),
    487         array('Name' => 'Name', 'Title' => T('Name')),
    488         array('Name' => 'MangosTable', 'Title' => 'Mangos/DBC/Lua'),
    489     //    array('Name' => 'DBCFileName', 'Title' => 'DBC soubor'),
    490     //    array('Name' => 'LuaFileName', 'Title' => 'Lua soubor'),
    491         array('Name' => '', 'Title' => T('Items of translation')),
     482      array('Name' => '', 'Title' => T('Select')),
     483      array('Name' => 'Name', 'Title' => T('Name')),
     484      array('Name' => 'MangosTable', 'Title' => 'Mangos/DBC/Lua'),
     485    //  array('Name' => 'DBCFileName', 'Title' => 'DBC soubor'),
     486    //  array('Name' => 'LuaFileName', 'Title' => 'Lua soubor'),
     487      array('Name' => '', 'Title' => T('Items of translation')),
    492488    );
    493489    $Order = GetOrderTableHeader($TableColumns, 'Name');
    494490    $Output .= '<form action="?Action=View&amp;ExportId='.$_GET['ExportId'].'" method="post">'.
    495         '<h3>'.T('Translation groups').'</h3>';
     491      '<h3>'.T('Translation groups').'</h3>';
    496492    if ($Editable)
    497493    {
    498494      $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
    499           '<input type="hidden" name="Operation" value="Save"/>'.
    500           ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' '.T('Select all').'</span> '.
    501           '<br />'.
    502           T('Select translation groups witch you want to export.').'<br />';
     495        '<input type="hidden" name="Operation" value="Save"/>'.
     496        ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' '.T('Select all').'</span> '.
     497        '<br />'.
     498        T('Select translation groups witch you want to export.').'<br />';
    503499    }
    504500
     
    518514    {
    519515      $Columns = '';
    520       foreach ($TranslationTree[$Group['Id']]['Items'] as $Column) {
     516      foreach ($TranslationTree[$Group['Id']]['Items'] as $Column)
     517      {
    521518        if ($Column['Visible']) $Columns .= CheckBox('item'.$Column['Id'],
    522519          !isset($GroupItems[$Column['Id']]), '', 'CheckBox', !$Editable).' '.T($Column['Name']).' <br/>';
     
    525522      $Selection = CheckBox('sel'.$Group['Id'], $Checked, '', 'CheckBox', !$Editable);
    526523      $Output .= '<tr>'.
    527           '<td>'.$Selection.'<input type="hidden" name="seq'.$Group['Id'].'"/></td>'.
    528           '<td>'.T($Group['Name']).'</td><td>';
    529           if ($Group['MangosTable'] <> '')
    530             $Output .= $Group['MangosTable'].'.sql ';
    531           if ($Group['LuaFileName'] <> '')
    532             $Output .= $Group['LuaFileName'].'.lua ';
    533           if ($Group['DBCFileName'] <> '')
    534             $Output .= $Group['DBCFileName'].'.dbc ';
     524        '<td>'.$Selection.'<input type="hidden" name="seq'.$Group['Id'].'"/></td>'.
     525        '<td>'.T($Group['Name']).'</td><td>';
     526      if ($Group['MangosTable'] <> '')
     527        $Output .= $Group['MangosTable'].'.sql ';
     528      if ($Group['LuaFileName'] <> '')
     529        $Output .= $Group['LuaFileName'].'.lua ';
     530      if ($Group['DBCFileName'] <> '')
     531        $Output .= $Group['DBCFileName'].'.dbc ';
    535532
    536533      $Output .= '</td><td>';
     
    556553        $Export = $DbRows->fetch_assoc();
    557554        if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    558         else $Editable = false;
     555          else $Editable = false;
    559556
    560557        if (array_key_exists('Operation', $_POST))
     558        {
    561559          if ($_POST['Operation'] == 'Save')
    562560          {
     
    567565            } else $Output .= ShowMessage(T('Format wasn\'t selected'), MESSAGE_CRITICAL);
    568566          }
    569 
    570           $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    571           $Export = $DbResult->fetch_assoc();
    572 
    573           $Output .= '<h3>'.T('Format the generated output').'</h3>'.
    574               '<form action="?Action=View&amp;ExportId='.$_GET['ExportId'].'" method="post">';
    575           if ($Editable)
    576           {
    577             $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
    578                 '<input type="hidden" name="Operation" value="Save"/>'.
    579                 '<br />';
    580           }
    581           $DbResult = $this->System->Database->query('SELECT * FROM `ExportOutputType` ORDER BY `Name`');
    582           while ($ExportFormat = $DbResult->fetch_assoc())
    583           {
    584             $Output .= RadioButton('OutputType', $ExportFormat['Id'], $Export['OutputType'] == $ExportFormat['Id'], '', !$Editable).' '.$ExportFormat['Name'].'<br/>';
    585           }
    586           $Output .= '</form>';
     567        }
     568
     569        $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     570        $Export = $DbResult->fetch_assoc();
     571
     572        $Output .= '<h3>'.T('Format the generated output').'</h3>'.
     573          '<form action="?Action=View&amp;ExportId='.$_GET['ExportId'].'" method="post">';
     574        if ($Editable)
     575        {
     576          $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
     577            '<input type="hidden" name="Operation" value="Save"/>'.
     578            '<br />';
     579        }
     580        $DbResult = $this->System->Database->query('SELECT * FROM `ExportOutputType` ORDER BY `Name`');
     581        while ($ExportFormat = $DbResult->fetch_assoc())
     582        {
     583          $Output .= RadioButton('OutputType', $ExportFormat['Id'], $Export['OutputType'] == $ExportFormat['Id'], '', !$Editable).' '.$ExportFormat['Name'].'<br/>';
     584        }
     585        $Output .= '</form>';
    587586      } else $Output .= ShowMessage(T('Item not found'), MESSAGE_CRITICAL);
    588587    } else $Output .= ShowMessage(T('Is isn\'t select'), MESSAGE_CRITICAL);
     
    601600
    602601    if (array_key_exists('Operation', $_POST))
     602    {
    603603      if (($_POST['Operation'] == 'Save') and (array_key_exists('ClientVersion', $_POST)))
    604604      {
     
    606606        $Output .= ShowMessage(T('Select saved.'));
    607607      }
    608 
    609       $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    610       $Export = $DbResult->fetch_assoc();
    611 
    612       if ($Export['OutputType'] == '') $Output .= ShowMessage('Nevybrán typ exportu', MESSAGE_CRITICAL);
    613       else {
    614         $Query = 'SELECT `ClientVersion`.* FROM `ExportVersion` '.
    615           'LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id`=`ExportVersion`.`ClientVersion` WHERE `ExportType`='.$Export['OutputType'];
    616 
    617         $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `X`');
    618         $DbRow = $DbResult->fetch_row();
    619         $PageList = GetPageList($DbRow[0]);
    620 
    621         $TableColumns = array(
    622             array('Name' => 'Version', 'Title' => T('Version')),
    623             array('Name' => 'BuildNumber', 'Title' => T('Build')),
    624             array('Name' => 'ReleaseDate', 'Title' => T('Release date')),
    625             array('Name' => 'Title', 'Title' => T('Name2')),
    626             array('Name' => '', 'Title' => T('Select')),
    627         );
    628         $Order = GetOrderTableHeader($TableColumns, 'BuildNumber', 1);
    629         $Output .= '<form action="?Action=View&amp;ExportId='.$_GET['ExportId'].'" method="post">'.
    630             '<h3>'.T('Client version').'</h3>';
    631 
    632         if ($Editable)
    633         {
    634           $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
    635               '<input type="hidden" name="Operation" value="Save"/>'.
    636               '<br />'.
    637               T('Select version of game client witch you want to export.').'<br />';
    638         }
    639         $Output .= $PageList['Output'].
    640         '<table class="BaseTable">'.
    641         $Order['Output'];
    642 
    643         $Query = 'SELECT * FROM ('.$Query.') AS `TX` '.$Order['SQL'].$PageList['SQLLimit'];
    644         $DbResult = $this->System->Database->query($Query);
    645         while ($Version = $DbResult->fetch_assoc())
    646         {
    647           $Output .= '<tr><td><a href="'.$this->System->Link('/client-version/?action=item&amp;id='.$Version['Id']).'">'.
    648               $Version['Version'].'</a></td><td>'.$Version['BuildNumber'].'</td><td>'.
    649               HumanDate($Version['ReleaseDate']).'</td><td>'.$Version['Title'].'</td><td>'.
    650               RadioButton('ClientVersion', $Version['Id'], $Export['ClientVersion'] == $Version['Id'], '', !$Editable
    651               ).'</td></tr>';
    652 
    653         }
    654         $Output .= '</table>'.
    655             '</form>'.
    656             $PageList['Output'];
    657       }
    658       return $Output;
     608    }
     609
     610    $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     611    $Export = $DbResult->fetch_assoc();
     612
     613    if ($Export['OutputType'] == '')
     614    {
     615      $Output .= ShowMessage('Nevybrán typ exportu', MESSAGE_CRITICAL);
     616    } else
     617    {
     618      $Query = 'SELECT `ClientVersion`.* FROM `ExportVersion` '.
     619        'LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id`=`ExportVersion`.`ClientVersion` WHERE `ExportType`='.$Export['OutputType'];
     620
     621      $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `X`');
     622      $DbRow = $DbResult->fetch_row();
     623      $PageList = GetPageList($DbRow[0]);
     624
     625      $TableColumns = array(
     626        array('Name' => 'Version', 'Title' => T('Version')),
     627        array('Name' => 'BuildNumber', 'Title' => T('Build')),
     628        array('Name' => 'ReleaseDate', 'Title' => T('Release date')),
     629        array('Name' => 'Title', 'Title' => T('Name2')),
     630        array('Name' => '', 'Title' => T('Select')),
     631      );
     632      $Order = GetOrderTableHeader($TableColumns, 'BuildNumber', 1);
     633      $Output .= '<form action="?Action=View&amp;ExportId='.$_GET['ExportId'].'" method="post">'.
     634        '<h3>'.T('Client version').'</h3>';
     635
     636      if ($Editable)
     637      {
     638        $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
     639          '<input type="hidden" name="Operation" value="Save"/>'.
     640          '<br />'.
     641          T('Select version of game client witch you want to export.').'<br />';
     642      }
     643      $Output .= $PageList['Output'].
     644      '<table class="BaseTable">'.
     645      $Order['Output'];
     646
     647      $Query = 'SELECT * FROM ('.$Query.') AS `TX` '.$Order['SQL'].$PageList['SQLLimit'];
     648      $DbResult = $this->System->Database->query($Query);
     649      while ($Version = $DbResult->fetch_assoc())
     650      {
     651        $Output .= '<tr><td><a href="'.$this->System->Link('/client-version/?action=item&amp;id='.$Version['Id']).'">'.
     652          $Version['Version'].'</a></td><td>'.$Version['BuildNumber'].'</td><td>'.
     653          HumanDate($Version['ReleaseDate']).'</td><td>'.$Version['Title'].'</td><td>'.
     654          RadioButton('ClientVersion', $Version['Id'], $Export['ClientVersion'] == $Version['Id'], '', !$Editable
     655          ).'</td></tr>';
     656      }
     657      $Output .= '</table>'.
     658        '</form>'.
     659        $PageList['Output'];
     660    }
     661    return $Output;
    659662  }
    660663
     
    666669    if ($Export['OutputType'] == '') $Output .= ShowMessage('Nevybrán typ exportu', MESSAGE_CRITICAL);
    667670    else if ($Export['ClientVersion'] == '') $Output .= ShowMessage(T('Export don\'t have selected version of client'), MESSAGE_CRITICAL);
    668     else {
     671    else
     672    {
    669673      $DbResult = $this->System->Database->query('SELECT * FROM `ExportOutputType` WHERE `Id`='.$Export['OutputType']);
    670674      if ($DbResult->num_rows > 0)
     
    691695    if (($Export->Export['ClientVersion'] == '') or ($Export->ClientVersion['BuildNumber'] == ''))
    692696      $Output = ShowMessage(T('Export don\'t have selected version of client'), MESSAGE_CRITICAL);
    693     else {
     697    else
     698    {
    694699      $GroupListQuery = 'SELECT `Group`.* FROM `Group` '.
    695           ' JOIN `ExportGroup` ON (`ExportGroup`.`Export`='.$Export->Id.') AND (`ExportGroup`.`Group`=`Group`.`Id`)';
     700        ' JOIN `ExportGroup` ON (`ExportGroup`.`Export`='.$Export->Id.') AND (`ExportGroup`.`Group`=`Group`.`Id`)';
    696701      $Query = '';
    697702      $UnionItems = array();
     
    700705      {
    701706        $UnionItems[] = 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
    702             ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'.
    703             ' JOIN `ExportUser` ON (`ExportUser`.`User`=`T`.`User`) AND (`ExportUser`.`Export`='.$Export->Id.') '.
    704             ' JOIN `ExportLanguage` ON (`ExportLanguage`.`Export`='.$Export->Id.')'.
    705             ' WHERE (`Complete` = 1) AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
    706             ') AS `C1`) AS `Translated`, '.
    707             '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
    708             ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'.
    709             ' WHERE (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
    710             ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name`';
     707          ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'.
     708          ' JOIN `ExportUser` ON (`ExportUser`.`User`=`T`.`User`) AND (`ExportUser`.`Export`='.$Export->Id.') '.
     709          ' JOIN `ExportLanguage` ON (`ExportLanguage`.`Export`='.$Export->Id.')'.
     710          ' WHERE (`Complete` = 1) AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
     711          ') AS `C1`) AS `Translated`, '.
     712          '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
     713          ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'.
     714          ' WHERE (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
     715          ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name`';
    711716      }
    712717      $Query = substr($Query, 0, - 6);
Note: See TracChangeset for help on using the changeset viewer.