Changeset 893 for trunk/Modules/Export


Ignore:
Timestamp:
Mar 6, 2023, 1:48:45 AM (21 months ago)
Author:
chronos
Message:
  • Fixed: Class types casting for better type checking.
  • Fixed: XML direct export.
  • Modified: User class instance moved from Core class to ModuleUser class.
Location:
trunk/Modules/Export
Files:
1 added
4 edited

Legend:

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

    r888 r893  
    55class ExportAddon extends Export
    66{
    7 
    87  // Replace special codes by lua functions
    98  function ReplaceVarInText($string, $strlower = 'strlower')
    109  {
    11 
    1210    $string = str_replace('$N', '"..'.$strlower.'(UnitName("player")).."', $string);
    1311    $string = str_replace('$n', '"..'.$strlower.'(UnitName("player")).."', $string);
     
    149147        $ID = $this->Database->query('SELECT `BuildNumber` FROM `ClientVersion` WHERE '.
    150148        ' `Imported` = 1 AND `BuildNumber` < '.$BuildNumber.' ORDER BY  `BuildNumber` DESC LIMIT 1');
    151         if ($ID->num_rows > 0) {
     149        if ($ID->num_rows > 0)
     150        {
    152151          $ExportVersionOld = $ID->fetch_assoc();
    153152          $ExportVersionOld = $ExportVersionOld['BuildNumber'];
     
    164163          }
    165164        }
    166                 //last version
     165        //last version
    167166
    168167        $DbResult2 = $this->Database->query($this->BuildQuery($Group,$ExportVersion));
     
    177176        }
    178177
    179         foreach ($TableTexts as $key => $value) {
    180             $Buffer .= "\n".'["'.$key.'"]="'.$value.'",';
    181             $i++;
     178        foreach ($TableTexts as $key => $value)
     179        {
     180          $Buffer .= "\n".'["'.$key.'"]="'.$value.'",';
     181          $i++;
    182182        }
    183 
    184183
    185184        $Buffer = $Buffer."\n};if not CZWOW_".$Column['AddonFileName']." then CZWOW_".$Column['AddonFileName']."=0; end; CZWOW_".$Column['AddonFileName']."=CZWOW_".$Column['AddonFileName']."+".$i.";\n";
     
    189188      }
    190189    }
    191 
    192190
    193191    // Generete list file of translated
     
    195193    $Buffer = '';
    196194    foreach ($CreatedFileList as $CreatedFile)
     195    {
    197196      $Buffer .= 'CZWOW_'.str_replace('_','_count=',$CreatedFile).';'."\n";
     197    }
    198198    foreach ($TranslationTree as $Group)
     199    {
    199200      foreach ($TranslationTree[$Group['Id']]['Items'] as $Column)
    200       if (($Column['AddonFileName'] != '') and (!in_array($Column['AddonFileName'].'_1', $CreatedFileList)))
    201201      {
    202         $Buffer .= 'CZWOW_'.$Column['AddonFileName'].'_count=0;'."\n";
     202        if (($Column['AddonFileName'] != '') and (!in_array($Column['AddonFileName'].'_1', $CreatedFileList)))
     203        {
     204          $Buffer .= 'CZWOW_'.$Column['AddonFileName'].'_count=0;'."\n";
     205        }
     206      }
    203207    }
    204208
    205209    file_put_contents($this->TempDir.'CzWoW/'.$CountFiles, $Buffer);
    206 
    207210
    208211    // Generate file Translates.xml
     
    210213    $Buffer .= '<script file="'.$CountFiles.'"/>'."\n";
    211214    foreach ($CreatedFileList as $CreatedFile)
     215    {
    212216      $Buffer .= '<script file="'.$CreatedFile.'.lua"/>'."\n";
     217    }
    213218    $Buffer .= '</Ui>';
    214219    file_put_contents($this->TempDir.'CzWoW/Translates.xml', $Buffer);
    215220    return $Output;
    216221  }
    217 
    218222
    219223  function MakeClientStrings()
     
    282286
    283287    ';
    284     $DbResult = $System->Database->query('SELECT * FROM `CzWoWPackageVersion` ORDER BY `Date` DESC');
     288    $DbResult = $this->Database->query('SELECT * FROM `CzWoWPackageVersion` ORDER BY `Date` DESC');
    285289    while ($Line = $DbResult->fetch_assoc())
    286290    {
  • trunk/Modules/Export/Export.php

    r891 r893  
    11<?php
    22
    3 class ModuleExport extends Module
    4 {
    5   function __construct(System $System)
    6   {
    7     parent::__construct($System);
    8     $this->Name = 'Export';
    9     $this->Version = '1.0';
    10     $this->Creator = 'Chronos';
    11     $this->License = 'GNU/GPL';
    12     $this->Description = 'Allow parametric export of translated texts to various supported output formats';
    13     $this->Dependencies = array('Translation');
    14   }
    15 
    16   function DoStart(): void
    17   {
    18     $this->System->RegisterPage(['export'], 'PageExport');
    19     $this->System->RegisterPage(['export', 'progress'], 'PageExportProgress');
    20     Core::Cast($this->System)->RegisterMenuItem(array(
    21       'Title' => 'Exporty',
    22       'Hint' => 'Zde si můžete stáhnout přeložené texty',
    23       'Link' => $this->System->Link('/export/'),
    24       'Permission' => LICENCE_ANONYMOUS,
    25       'Icon' => '',
    26     ), 2);
    27   }
    28 
    29   function GetTaskProgress($TaskId)
    30   {
    31     $Output = '';
    32     $DbResult = $this->Database->query('SELECT * FROM `ExportTask` '.
    33       'LEFT JOIN `Export` ON `Export`.`Id` = `ExportTask`.`Export` WHERE '.
    34       '((`Export`.`OutputType` = 9) OR (`Export`.`OutputType` = 10)) AND '.
    35       '(`TimeFinish` IS NULL) OR (`Export` ='.$TaskId.') ORDER BY `TimeQueued`'); // `Export`='.$Export->Id
    36     while ($Task = $DbResult->fetch_assoc())
    37     {
    38       $Export = '<a href="'.$this->System->Link('/export/?Action=View&amp;ExportId='.$Task['Export']).'">'.$Task['Export'].'</a>';
    39       if ($TaskId == $Task['Export'])
    40         $Export = ''.$Export.' (tento)';
    41 
    42       // Show progress bar
    43       $Output .= ' <strong>Export '.$Export.':</strong> <div id="progress'.$Task['Export'].'">'.
    44         '<strong>'.ProgressBar(300, $Task['Progress']).'</strong> ';
    45 
    46       // Show estimated time to complete
    47       $PrefixMultiplier = new PrefixMultiplier();
    48       if ($Task['Progress'] > 0) {
    49         $ElapsedTime = time() - MysqlDateTimeToTime($Task['TimeStart']);
    50         $Output .= T('Elapsed time').': <strong>'.$PrefixMultiplier->Add($ElapsedTime, '', 4, 'Time').'</strong> / ';
    51         $EstimatedTime = (time() - MysqlDateTimeToTime($Task['TimeStart'])) / $Task['Progress'] * (100 - $Task['Progress']);
    52         $Output .= T('Estimated remaining time').': <strong>'.$PrefixMultiplier->Add($EstimatedTime, '', 4, 'Time').'</strong><br/>';
    53       }
    54       $Output .= '</div>';
    55 
    56       if ($Task['Progress'] > 99)
    57         $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
    58         'setTimeout("parent.location.href=\''.$this->System->Link('/export/?Action=View&Tab=7&ExportId='.$TaskId).'\'", 500)'.
    59         '</script>';
    60     }
    61     return $Output;
    62   }
    63 }
     3include_once(dirname(__FILE__).'/ModuleExport.php');
     4include_once(dirname(__FILE__).'/Page.php');
     5include_once(dirname(__FILE__).'/ExportOutput.php');
    646
    657class Export extends Model
    668{
    67   var $Id;
    68   var $AnoNe = array('Ne', 'Ano');
     9  public int $Id;
     10  public array $AnoNe = array('Ne', 'Ano');
    6911  var $WhereLang;
    7012  var $WhereUsers;
     
    7315  var $ClientVersion;
    7416  var $OrderByUserList;
    75   var $TempDir;
    76   var $SourceDir;
     17  public string $TempDir;
     18  public string $TempDirRelative;
     19  public string $SourceDir;
     20  public string $SourceDirRelative;
     21  public array $Export;
    7722
    7823  function Init()
    7924  {
    80     $this->TempDir = dirname(__FILE__).'/../../'.$this->System->Config['Web']['TempFolder'].'Export/'.$this->Id.'/';
     25    $this->TempDir = dirname(__FILE__).'/../../'.Core::Cast($this->System)->Config['Web']['TempFolder'].'Export/'.$this->Id.'/';
    8126    if (!file_exists($this->TempDir)) mkdir($this->TempDir, 0777, true);
    82     $this->TempDirRelative = $this->System->Config['Web']['TempFolder'].'Export/'.$this->Id.'/';
    83     $this->SourceDir = dirname(__FILE__).'/../../'.$this->System->Config['Web']['SourceFolder'];
    84     $this->SourceDirRelative = $this->System->Config['Web']['SourceFolder'];
     27    $this->TempDirRelative = Core::Cast($this->System)->Config['Web']['TempFolder'].'Export/'.$this->Id.'/';
     28    $this->SourceDir = dirname(__FILE__).'/../../'.Core::Cast($this->System)->Config['Web']['SourceFolder'];
     29    $this->SourceDirRelative = Core::Cast($this->System)->Config['Web']['SourceFolder'];
    8530    if (!file_exists($this->SourceDir)) mkdir($this->SourceDir, 0777, true);
    8631  }
     
    158103  //  $Columns = substr($Columns, 0, -2);
    159104
    160     $Query = 'SELECT * FROM (SELECT ANY_VALUE(`TT`.`ID`) AS `TTID` FROM (SELECT '.$Columns.' T.`ID`,T.`Language`,T.`User`,T.`Entry`,T.`VersionEnd`,T.`VersionStart`, `User`.`Name` AS `UserName` FROM `'.$Group['TablePrefix'].'` AS `T`'.
     105    $Query = 'SELECT * FROM (SELECT MIN(`TT`.`ID`) AS `TTID` FROM
     106    (SELECT '.$Columns.' T.`ID`,T.`Language`,T.`User`,T.`Entry`,T.`VersionEnd`,T.`VersionStart`, `User`.`Name` AS `UserName` FROM `'.$Group['TablePrefix'].'` AS `T`'.
    161107    ' JOIN `ExportUser` ON (`ExportUser`.`User`=`T`.`User`) AND (`ExportUser`.`Export`='.$this->Id.') '.
    162108    ' JOIN `User` ON `User`.`ID`=`T`.`User`'.
     
    179125    $Query = 'SELECT `T4`.*, '.$OriginalColumns.' FROM ('.$Query.') AS `T4` '.
    180126    ' LEFT JOIN `'.$Group['TablePrefix'].'` AS `T3` ON (`T3`.`Entry` = `T4`.`Entry`) '.
    181     'AND (`T3`.`Language` = '.$this->System->Config['OriginalLanguage'].') AND '.
     127    'AND (`T3`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND '.
    182128    '(`T3`.`VersionStart` = `T4`.`VersionStart`) AND (`T3`.`VersionEnd` = `T4`.`VersionEnd`)';
    183129
     
    219165  function ExportToMangosSQL()
    220166  {
     167    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    221168    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    222169
     
    227174      "-- ===========================================\n".
    228175      "--\n".
    229       "-- Web projektu: ".$this->System->Config['Web']['Host'].$this->System->Link('/')."\n".
     176      "-- Web projektu: ".Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/')."\n".
    230177      "-- Datum exportu: ".date("j.n.Y  H:i:s")."\n".
    231       "-- Znaková sada: ".$this->System->Config['Database']['Charset']." / ".$this->System->Config['Web']['Charset']."\n".
     178      "-- Znaková sada: ".Core::Cast($this->System)->Config['Database']['Charset']." / ".Core::Cast($this->System)->Config['Web']['Charset']."\n".
    232179      "-- Diakritika: ".$this->AnoNe[$this->Export['WithDiacritic']]."\n".
    233       "-- Vygeneroval uživatel: ".$this->System->User->Name."\n".
     180      "-- Vygeneroval uživatel: ".$User->Name."\n".
    234181      "-- Vzato od uživatelů: ".$this->UserNames."\n".
    235182      "-- Generované tabulky: ";
     
    370317  }
    371318
    372   function AddProgress($add = 1)
    373   {
    374     $DbResult = $this->System->Database->query('SELECT Progress FROM `ExportTask` WHERE `Export`='.$this->Id);
    375     $Task = $DbResult->fetch_assoc();
    376     $per = $Task['Progress']+$add;
    377     $this->System->Database->query('UPDATE `ExportTask` SET `Progress`='.$per.' WHERE `Export`='.$this->Id);
     319  function AddProgress($Add = 1)
     320  {
     321    $DbResult = $this->System->Database->query('SELECT `Progress` FROM `ExportTask` WHERE `Export`='.$this->Id);   
     322    if ($DbResult->num_rows > 0)
     323    {
     324      $Task = $DbResult->fetch_assoc();
     325      $Progress = $Task['Progress'] + $Add;
     326      $this->System->Database->query('UPDATE `ExportTask` SET `Progress`='.$Progress.' WHERE `Export`='.$this->Id);
     327    }
    378328  }
    379329
     
    723673  function ExportToXML()
    724674  {
     675    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    725676    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    726677
     
    730681    "<document>\n".
    731682    "  <meta>\n".
    732     "    <projecturl>".$this->System->Config['Web']['Host'].$this->System->Link('/')."</projecturl>\n".
     683    "    <projecturl>".Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/')."</projecturl>\n".
    733684    "    <time>".date('r')."</time>\n".
    734685    "    <diacritics mode=".'"'.$this->Export['WithDiacritic'].'"'." />\n".
    735     "    <author>".$this->System->User->Name."</author>\n".
     686    "    <author>".$User->Name."</author>\n".
    736687    "    <contributors>\n";
    737688    foreach (explode(',', $this->UserNames) as $UserName)
    738       $Buffer .= "      <user>".$UserName."</user>\n";
     689    {
     690      $Buffer .= "      <user>".trim($UserName)."</user>\n";
     691    }
    739692    $Buffer .=
    740693    "    </contributors>\n".
     
    755708      while ($Line = $DbResult2->fetch_assoc())
    756709      {
    757         $Buffer .= '      <item id="'.$Line['Entry'].'" user="'.$Line['UserName'].'">'."\n";
    758         $Values = '';
     710        $Buffer .= '      <item id="'.$Line['Entry'].'" user="'.$Line['User'].'">'."\n";
    759711        foreach ($TranslationTree[$Group['Id']]['Items'] as $GroupItem)
    760712        {
     
    774726  }
    775727}
    776 
    777 include_once(dirname(__FILE__).'/Page.php');
    778 include_once(dirname(__FILE__).'/ExportOutput.php');
    779 
  • trunk/Modules/Export/ExportOutput.php

    r880 r893  
    2222function OutputAoWoWToFile($ExportId)
    2323{
    24   global $System, $Config;
     24  global $System;
    2525
    2626  $Output = '';
     
    5050function OutputAoWoWToHTML($ExportId)
    5151{
    52   global $System, $Config;
     52  global $System;
    5353
    5454  $Export = new Export($System);
     
    6363function OutputMangosSQLToFile($ExportId)
    6464{
    65   global $System, $Config;
     65  global $System;
    6666
    6767  $Output = '';
     
    140140function OutputXMLToFile($ExportId)
    141141{
    142   global $Config, $System;
     142  global $System;
    143143
    144144  $Output = '';
     
    318318function OutputLua($ExportId)
    319319{
    320   global $System, $Config;
     320  global $System;
    321321
    322322  $Export = new Export($System);
  • trunk/Modules/Export/Page.php

    r888 r893  
    1616  function ExportList()
    1717  {
     18    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    1819    $Output = '<a href="?Action=ViewList">'.T('All').'</a>';
    19     if ($this->System->User->Licence(LICENCE_USER))
     20    if ($User->Licence(LICENCE_USER))
    2021    {
    2122      $Output .= ' <a href="?Action=ViewList&amp;Filter=Others">'.T('Others').'</a>'.
     
    2324    }
    2425
    25     if ($this->System->User->Licence(LICENCE_USER))
     26    if ($User->Licence(LICENCE_USER))
    2627      $Output .= '<br/><div style="text-align: center;"><a href="?Action=Create">'.T('Create new export').'</a></div><br/>';
    2728
     
    2930    if (array_key_exists('Filter', $_GET))
    3031    {
    31       if ($_GET['Filter'] == 'My') $Filter = ' WHERE `Export`.`User` = '.$this->System->User->Id;
    32       if ($_GET['Filter'] == 'Others') $Filter = ' WHERE `Export`.`User` != '.$this->System->User->Id;
     32      if ($_GET['Filter'] == 'My') $Filter = ' WHERE `Export`.`User` = '.$User->Id;
     33      if ($_GET['Filter'] == 'Others') $Filter = ' WHERE `Export`.`User` != '.$User->Id;
    3334    }
    3435
     
    6667      $Action = '<a href="?Action=View&amp;ExportId='.$Export['Id'].'&amp;Tab=0">'.T('View').'</a> '.
    6768        '<a href="?Action=View&amp;ExportId='.$Export['Id'].'&amp;Tab=7">'.T('Make export').'</a>';
    68       if ($Export['User'] == $this->System->User->Id) $Action .= ' <a href="?Action=Delete&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy delete item?').'\');">'.T('Delete').'</a>';
    69       if ($this->System->User->Id != null) $Action .= ' <a href="?Action=Clone&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a>';
     69      if ($Export['User'] == $User->Id) $Action .= ' <a href="?Action=Delete&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy delete item?').'\');">'.T('Delete').'</a>';
     70      if ($User->Id != null) $Action .= ' <a href="?Action=Clone&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a>';
    7071      $Output .= '<tr><td>'.HumanDate($Export['TimeCreate']).'</td>'.
    7172          '<td><a href="'.$this->System->Link('/user/?user='.$Export['User']).'">'.$Export['UserName'].'</a></td>'.
     
    8485  function ExportCreate()
    8586  {
    86     if ($this->System->User->Licence(LICENCE_USER))
    87     {
    88       $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id);
     87    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     88    if ($User->Licence(LICENCE_USER))
     89    {
     90      $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$User->Id);
    8991      $DbRow = $DbResult->fetch_row();
    90       if ($DbRow[0] < $this->System->Config['MaxExportPerUser'])
     92      if ($DbRow[0] < Core::Cast($this->System)->Config['MaxExportPerUser'])
    9193      {
    9294        $Output = '<form action="?Action=CreateFinish" method="post">'.
     
    9698            '<tr><td colspan="2"><input type="submit" value="'.T('Create').'" /></td></tr>'.
    9799            '</table></fieldset></form>';
    98       } else $Output = ShowMessage(sprintf(T('You can\'t create another export. Max for one user is %d.'), $this->System->Config['MaxExportPerUser']), MESSAGE_CRITICAL);
     100      } 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);
    99101    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    100102    return $Output;
     
    103105  function ExportCreateFinish()
    104106  {
    105     if ($this->System->User->Licence(LICENCE_USER))
     107    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     108    if ($User->Licence(LICENCE_USER))
    106109    {
    107110      if (array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
    108111      {
    109         $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id);
     112        $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$User->Id);
    110113        $DbRow = $DbResult->fetch_row();
    111         if ($DbRow[0] < $this->System->Config['MaxExportPerUser'])
     114        if ($DbRow[0] < Core::Cast($this->System)->Config['MaxExportPerUser'])
    112115        {
    113           $this->System->Database->query('INSERT INTO `Export` (`Title`, `User`, `TimeCreate`, `WithDiacritic`, `Description`) VALUES ("'.$_POST['Title'].'", '.$this->System->User->Id.', NOW(), 1, "'.$_POST['Description'].'")');
     116          $this->System->Database->query('INSERT INTO `Export` (`Title`, `User`, `TimeCreate`, `WithDiacritic`, `Description`) VALUES ("'.$_POST['Title'].'", '.$User->Id.', NOW(), 1, "'.$_POST['Description'].'")');
    114117          $ExportId = $this->System->Database->insert_id;
    115118          $Output = ShowMessage(T('New export created.<br />Direct link to export').': <a href="?Action=View&amp;ExportId='.$ExportId.'">'.T('here').'</a>');
     
    117120          $_GET['Filter'] = 'my';
    118121          $this->ExportList();
    119         } else $Output = ShowMessage(sprintf(T('You can\'t create another export. Max for one user is %d.'),$this->System->Config['MaxExportPerUser']), MESSAGE_CRITICAL);
     122        } 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);
    120123      } else $Output = ShowMessage(T('Missing data in form.'), MESSAGE_CRITICAL);
    121124    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
     
    125128  function ExportDelete()
    126129  {
    127     if ($this->System->User->Licence(LICENCE_USER))
    128     {
    129       $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE (`Id`='.($_GET['ExportId'] * 1).') AND (`User`='.$this->System->User->Id.')');
     130    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     131    if ($User->Licence(LICENCE_USER))
     132    {
     133      $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE (`Id`='.($_GET['ExportId'] * 1).') AND (`User`='.$User->Id.')');
    130134      if ($DbResult->num_rows > 0)
    131135      {
     
    157161  function ExportViewTranslators()
    158162  {
     163    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    159164    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    160165
     
    163168    $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    164169    $Export = $DbResult->fetch_assoc();
    165     if ($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     170    if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    166171    else $Editable = false;
    167172
     
    273278  function ExportViewGeneral()
    274279  {
     280    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    275281    $DisabledInput = array(false => ' disabled="disabled"', true => '');
    276282    $DisabledTextArea = array(false => ' readonly="yes"', true => '');
     
    278284    $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    279285    $Export = $DbRows->fetch_assoc();
    280     if ($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     286    if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    281287    else $Editable = false;
    282288
     
    300306      $Output .= '<form action="?Action=View&amp;Tab=0&amp;ExportId='.$Export['Id'].'" method="post">'.
    301307          '<table>';
    302       if ($this->System->User->Id != null)
     308      if ($User->Id != null)
    303309      {
    304310        $Output .= '<input type="hidden" name="Operation" value="Save"/>'.
     
    306312        if ($Editable) $Output .= ' <input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>';
    307313        $Output .= ' <a href="?Action=Clone&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a> ';
    308         if ($this->System->User->Licence(LICENCE_ADMIN))
     314        if ($User->Licence(LICENCE_ADMIN))
    309315          $Output .= CheckBox('Featured', $Export['Featured'], '', 'CheckBox', !$Editable). ' '.T('Recommended').' ';
    310316        $Output .= '</td></tr>';
     
    319325  function ExportViewLanguages()
    320326  {
     327    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    321328    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    322329
     
    325332    $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    326333    $Export = $DbRows->fetch_assoc();
    327     if ($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     334    if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    328335    else $Editable = false;
    329336
     
    410417  function ExportViewGroups()
    411418  {
     419    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    412420    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    413421
     
    416424    $DbRows = $this->System->Database->query('SELECT * FROM Export WHERE Id='.$_GET['ExportId']);
    417425    $Export = $DbRows->fetch_assoc();
    418     if ($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     426    if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    419427    else $Editable = false;
    420428
     
    538546  function ExportViewOutputFormat()
    539547  {
     548    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    540549    $Output = '';
    541550    $DisabledInput = array(false => ' disabled="disabled"', true => '');
     
    546555      {
    547556        $Export = $DbRows->fetch_assoc();
    548         if ($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     557        if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    549558        else $Editable = false;
    550559
     
    583592  function ExportViewVersion()
    584593  {
     594    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    585595    $Output = '';
    586596    $DisabledInput = array(false => ' disabled="disabled"', true => '');
    587597    $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    588598    $Export = $DbRows->fetch_assoc();
    589     if ($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     599    if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    590600    else $Editable = false;
    591601
     
    697707            '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
    698708            ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'.
    699             ' WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].') AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
     709            ' WHERE (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
    700710            ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name`';
    701711      }
     
    777787  function ExportClone()
    778788  {
    779     if ($this->System->User->Licence(LICENCE_USER))
     789    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     790    if ($User->Licence(LICENCE_USER))
    780791    {
    781792      if (array_key_exists('ExportId', $_GET) and is_numeric($_GET['ExportId']))
    782793      {
    783         $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id);
     794        $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$User->Id);
    784795        $DbRow = $DbResult->fetch_row();
    785         if ($DbRow[0] < $this->System->Config['MaxExportPerUser'])
     796        if ($DbRow[0] < Core::Cast($this->System)->Config['MaxExportPerUser'])
    786797        {
    787798          $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     
    791802            unset($DbRow['Id']);
    792803            $DbRow['UsedCount'] = '0';
    793             $DbRow['User'] = $this->System->User->Id;
     804            $DbRow['User'] = $User->Id;
    794805            $DbRow['TimeCreate'] = 'NOW()';
    795806            $DbRow['Title'] .= ' - '.T('clone');
     
    807818          } else $Output = ShowMessage('Zdrojový export nenalezen', MESSAGE_CRITICAL);
    808819        } else $Output = ShowMessage(sprintf(T('You can\'t create another export. Max for one user is %d.'),
    809           $this->System->Config['MaxExportPerUser']), MESSAGE_CRITICAL);
     820        Core::Cast($this->System)->Config['MaxExportPerUser']), MESSAGE_CRITICAL);
    810821      } else $Output = ShowMessage(T('Export not found.'), MESSAGE_CRITICAL);
    811822    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
Note: See TracChangeset for help on using the changeset viewer.