Ignore:
Timestamp:
Mar 6, 2023, 1:48:45 AM (22 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/Translation
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Translation/Comparison.php

    r888 r893  
    4040  function Show(): string
    4141  {
     42    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    4243    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    4344
    4445    $Output = '';
    4546
    46     if ($this->System->User->Licence(LICENCE_USER))
     47    if ($User->Licence(LICENCE_USER))
    4748    {
    4849    $Output = 'Text je porovnáván vždy ku předešlému (vlevo). Změny jsou zvýrazněny <span class="edit">barvou.</span><br /><br />';
  • trunk/Modules/Translation/Form.php

    r888 r893  
    1919  function ShowForm(): string
    2020  {
     21    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    2122    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    2223
     
    4142      } else
    4243      {
    43         if ($this->System->Config['OriginalLanguage'] == $Line['Language']){
     44        if (Core::Cast($this->System)->Config['OriginalLanguage'] == $Line['Language']){
    4445          $LineAJ = $Line;
    4546
    46           if ($this->System->User->Language <> '') $Language = '`Language` = '.$this->System->User->Language;
    47           else $Language = '`Language` != '.$this->System->Config['OriginalLanguage'];
     47          if ($User->Language <> '') $Language = '`Language` = '.$User->Language;
     48          else $Language = '`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'];
    4849          $Columns = '';
    4950          foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
     
    5556          $where = ' WHERE '.'( `Tran`.'.$Language.' ) AND '.'(`Tran`.`Entry` = '.$Line['Entry'].') ORDER BY `Tran`.`ModifyTime` DESC';
    5657          $DbResult = $this->Database->query($sql.$join.$where);
    57           while ($LineSearch = $DbResult->fetch_assoc()) {
     58          while ($LineSearch = $DbResult->fetch_assoc())
     59          {
    5860            foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
     61            {
    5962              if ($TextItem['Visible'] == 1)
     63              {
    6064                if (($LineAJ[$TextItem['Column']] <> '') and
    6165                    ($LineSearch[$TextItem['Column']] <> '') and
    6266                    ($LineSearch['Orig_'.$TextItem['Column']] <> $LineSearch[$TextItem['Column']]) and
    6367                    ($LineAJ[$TextItem['Column']] == $Line[$TextItem['Column']])
    64                    )
    65                  {
    66                    $Line[$TextItem['Column']] = $LineSearch[$TextItem['Column']];
    67                  }
    68           }
    69 
    70         } else {
     68                  )
     69                {
     70                  $Line[$TextItem['Column']] = $LineSearch[$TextItem['Column']];
     71                }
     72              }
     73            }
     74          }
     75        } else
     76        {
    7177          $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE '.
    72           '(`Language` = '.$this->System->Config['OriginalLanguage'].') AND '.
     78          '(`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND '.
    7379          '(`Entry` = '.$Line['Entry'].') AND (`VersionEnd` = '.$Line['VersionEnd'].') LIMIT 1');
    7480          $LineAJ = $DbResult->fetch_assoc();
     
    7985        } else
    8086        {
    81 
    8287          if ($Line['User'] != '')
    8388          {
     
    128133            <input type="hidden" name="ID2" value="'.$TextID.'" />';
    129134
    130             if ($this->System->User->Licence(LICENCE_USER)) { // allow to compare only to user
     135            if ($User->Licence(LICENCE_USER)) { // allow to compare only to user
    131136              $Output .= '<select onchange="this.form.submit();" name="ID1">
    132137              <option value="-1">'.T('Select text for comparison').'</option>
     
    155160
    156161          // Special characters: $B - New line, $N - Name, $C - profession
    157           if ($this->System->User->Licence(LICENCE_USER))
     162          if ($User->Licence(LICENCE_USER))
    158163          {
    159164            $Output .= '<form action="'.$this->System->Link('/save.php?group='.$GroupId).'" method="post"><div>';
     
    175180
    176181          $Output .= '<input type="hidden" name="entry" value="'.$LineAJ['Entry'].'" />
    177           <input type="hidden" name="user" value="'.$this->System->User->Id.'" />
     182          <input type="hidden" name="user" value="'.$User->Id.'" />
    178183          <input type="hidden" name="ID" value="'.$TextID.'" />
    179184          <table class="BaseTable">
     
    188193          <td>';
    189194          if ($Line['Language'] <> 0) $Language = $Line['Language'];
    190           else if ($this->System->User->Id != 0)
    191           {
    192             $Language = $this->System->User->Language;
     195          else if ($User->Id != 0)
     196          {
     197            $Language = $User->Language;
    193198          } else $Language = 0;
    194           if ($this->System->User->Licence(LICENCE_USER)) $Output .= WriteLanguages($Language);
    195             else {
     199          if ($User->Licence(LICENCE_USER))
     200          {
     201            $Output .= WriteLanguages($Language);
     202          }
     203          else
     204          {
    196205            $DbResult3 = $this->Database->select('Language', '`Id`, `Name`', '(`Enabled` = 1) AND (`Id`='.$Language.')');
    197206            if ($DbResult3->num_rows > 0)
     
    200209              $Output .= T($Language['Name']);
    201210            }
    202             }
     211          }
    203212
    204213          $Output .= '</td></tr>';
     
    210219          $Output .=    '$(document).ready(function() {';
    211220          foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
     221          {
    212222            $Output .=   '$("#'.$TextItem['Column'].'").load("'.$this->System->Link('/LoadNames.php?ID='.$LineAJ['ID'].'&Column='.$TextItem['Column'].'&GroupId='.$GroupId).'");';
     223          }
    213224
    214225          $Output .= '});'.
    215226            '</script>';
    216227
    217           foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
     228          foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)         
     229          {
    218230            if ($TextItem['Visible'] == 1)
    219231            {
     
    225237                $Output .= '<td id="'.$TextItem['Column'].'">'.str_replace("\n", '<br/>', htmlspecialchars($LineAJ[$TextItem['Column']])).'</td>
    226238                <td>';
    227                 if ($this->System->User->Licence(LICENCE_USER))
     239                if ($User->Licence(LICENCE_USER))
    228240                  $Output .= '<textarea rows="8" cols="40" onkeydown="ResizeTextArea(this)" class="textedit" id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'">';
    229241                $Output .=  htmlspecialchars($Line[$TextItem['Column']]);
    230                 if ($this->System->User->Licence(LICENCE_USER)) $Output .= '</textarea></td></tr>';
     242                if ($User->Licence(LICENCE_USER)) $Output .= '</textarea></td></tr>';
    231243              }
    232244            } else
     
    234246              $Output .= '<input id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'" type="hidden" value="'.htmlspecialchars($Line[$TextItem['Column']]).'" />';
    235247            }
    236             $Output .= '</table></div>';
    237             if ($this->System->User->Licence(LICENCE_USER)) {
    238               $Output .= '</form>';
    239 
    240               if (isset($this->System->Config['Web']['EnableGoogleTranslate']) and
    241                 $this->System->Config['Web']['EnableGoogleTranslate'])
    242               {
     248          }
     249
     250          $Output .= '</table></div>';
     251          if ($User->Licence(LICENCE_USER))
     252          {
     253            $Output .= '</form>';
     254
     255            if (isset(Core::Cast($this->System)->Config['Web']['EnableGoogleTranslate']) and
     256              Core::Cast($this->System)->Config['Web']['EnableGoogleTranslate'])
     257            {
    243258              $Output .= '<br/><table class="BaseTable">'.
    244259              '<tr><th>'.T('Google translator').':</th><th>'.T('Not translated').'</th><th>'.T('Translated').'</th>';
    245260              foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
     261              {
    246262                if ($TextItem['Visible'] == 1)
     263                {
    247264                  if ($LineAJ[$TextItem['Column']] <> '')
     265                  {
    248266                    $Output .= '<tr><td>'.$TextItem['Column'].'</td>'.
    249267                      '<td>'.$LineAJ[$TextItem['Column']].'</td>'.
    250                       '<td>'.GetTranslateGoogle($LineAJ[$TextItem['Column']]).'</td></tr>';
    251 
     268                      '<td>'.GetTranslateGoogle($this->System, $LineAJ[$TextItem['Column']]).'</td></tr>';
     269                  }
     270                }
     271              }
    252272              $Output .= '</table>';
    253               }
    254             }
     273            }
     274          }
    255275        }
    256276      }
     
    261281  function Delete()
    262282  {
     283    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    263284    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    264285
    265     if ($this->System->User->Licence(LICENCE_MODERATOR))
     286    if ($User->Licence(LICENCE_MODERATOR))
    266287    {
    267288      $GroupId = LoadGroupIdParameter();
     
    269290      $Table = $TranslationTree[$GroupId]['TablePrefix'];
    270291      $TextID = $_GET['ID'];
    271       $this->Database->query('DELETE FROM `'.$Table.'` WHERE `ID` = '.$TextID.' AND `Language` <> '.$this->System->Config['OriginalLanguage']);
     292      $this->Database->query('DELETE FROM `'.$Table.'` WHERE `ID` = '.$TextID.' AND `Language` <> '.Core::Cast($this->System)->Config['OriginalLanguage']);
    272293      $Output = ShowMessage('Překlad byl smazán.');
    273294      $this->System->ModuleManager->Modules['Log']->WriteLog('Překlad byl smazán! <a href="'.$this->System->Link('/form.php?group='.$this->GroupId.'&amp;ID='.$TextID).'">'.$TextID.'</a>', LOG_TYPE_MODERATOR);
  • trunk/Modules/Translation/LoadNames.php

    r888 r893  
    2020    return $Text;
    2121  }
     22
    2223  function ReplaceNotTranslated($orig,$tran,$Text,$ID,$Group)
    2324  {
     
    4445    $Text = str_replace('$r','<span Title="Znamená rasu hráče, překladu zachovej na stejné pozici." class="edit">$R</span>',$Text);
    4546    $Text = str_replace('$g','<span Title="Vybere oslovení podle pohlaví hráče, překladu zachovej na stejné pozici." class="edit">$G</span>',$Text);
    46     foreach ($names as $Line) {
    47      if (($_GET['ID'] <> $Line[0]) or ($Line[1] <> $_GET['GroupId']))
    48       if ($Line[3] <> '')  {
    49         $Text = $this->ReplaceTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]);
    50 
    51       } else {
    52         $Text = $this->ReplaceNotTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]);
     47    foreach ($names as $Line)
     48    {
     49      if (($_GET['ID'] <> $Line[0]) or ($Line[1] <> $_GET['GroupId']))
     50      {
     51        if ($Line[3] <> '') 
     52        {
     53          $Text = $this->ReplaceTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]);     
     54        } else
     55        {
     56          $Text = $this->ReplaceNotTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]);
     57        }
    5358      }
    5459    }
     
    5863  function LoadNames()
    5964  {
     65    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    6066    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    6167
     
    7278          $Text = $LineAJ[$Column];
    7379          $names = array();
    74           if ($this->System->User->Licence(LICENCE_USER))
     80          if ($User->Licence(LICENCE_USER))
    7581          if (($GroupId < 4) or ($GroupId == 10) or ($GroupId == 11))
    7682          {
    7783            //<span class="edit">barvou.</span>
    7884            $names = GetTranslatNames($Text, 0, GetTranslatNamesArray());
    79           } else {
    80             if (($GroupId == 13)) {
     85          } else
     86          {
     87            if (($GroupId == 13))
     88            {
    8189              $names = GetTranslatNames($Text, 0, array('Dictionary' => 'Text',
    8290                'TextGlobalString' => 'Text', 'TextArea' => 'Name',
    8391                'TextItemSubClass' => 'Name', 'TextCharacterRace' => 'Name1',), false);
    84             } else {
     92            } else
     93            {
    8594              $names = GetTranslatNames($Text, 0, GetTranslatNamesArray());
    8695            }
    8796          }
    88                                    //$LineAJ[$Column]
     97          //$LineAJ[$Column]
    8998          return $this->ColorNames(htmlspecialchars($Text),$names);
    9099    }
  • trunk/Modules/Translation/Progress.php

    r888 r893  
    99    $BuildNumber = GetBuildNumber($_SESSION['StatVersion']);
    1010    if (is_numeric($_SESSION['language'])) $LanguageFilter = 'AND (`Language`='.$_SESSION['language'].')';
    11     else $LanguageFilter = ' AND (`Language`!='.$this->System->Config['OriginalLanguage'].')';
     11    else $LanguageFilter = ' AND (`Language`!='.Core::Cast($this->System)->Config['OriginalLanguage'].')';
    1212
    1313    $GroupListQuery = 'SELECT `Id`, `TablePrefix`, `Name` FROM `Group`';
     
    2525          '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
    2626          'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '.
    27           'WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].') '.
     27          'WHERE (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') '.
    2828          'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'.
    2929          ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name` UNION ';
     
    5959      else $TotalCount = 0;
    6060      $Output .= '<tr><td><strong>'.T('Total').'</strong></td><td><strong>'.$Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.ProgressBar(150, $TotalCount).'</strong></td></tr>'.
    61           '</table>';
     61        '</table>';
    6262    }
    6363    return $Output;
     
    6666  function Show(): string
    6767  {
     68    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    6869    $this->Title = T('Progress');
    6970    $LanguageList = GetLanguageList();
     
    7273    if (!array_key_exists('StatVersion', $_SESSION))
    7374    {
    74       if ($this->System->User->Licence(LICENCE_USER) and ($this->System->User->PreferredVersionGame != ''))
     75      if ($User->Licence(LICENCE_USER) and ($User->PreferredVersionGame != ''))
    7576      {
    76         $_SESSION['StatVersion'] = $this->System->User->PreferredVersionGame;
    77       } else {
    78         $_SESSION['StatVersion'] = $this->System->Config['Web']['GameVersion'];
     77        $_SESSION['StatVersion'] = $User->PreferredVersionGame;
     78      } else
     79      {
     80        $_SESSION['StatVersion'] = Core::Cast($this->System)->Config['Web']['GameVersion'];
    7981      }
    8082    }
     
    8284    if (!isset($_SESSION['language']))
    8385    {
    84       if ($this->System->User->Licence(LICENCE_USER))
     86      if ($User->Licence(LICENCE_USER))
    8587      {
    86         $_SESSION['language'] = $this->System->User->Language;
    87       } else {
     88        $_SESSION['language'] = $User->Language;
     89      } else
     90      {
    8891        $_SESSION['language'] = '';
    8992      }
     
    9396      if ($_GET['language'] == '') {
    9497        $_SESSION['language'] = '';
    95       } else {
     98      } else
     99      {
    96100        $_SESSION['language'] = $_GET['language'] * 1;
    97101      }
     
    103107    $DbResult = $this->Database->query('SELECT `Version`, `Title` FROM `ClientVersion` WHERE `Imported`=1 ORDER BY `Version`');
    104108    while ($DbRow = $DbResult->fetch_assoc())
     109    {
    105110      $Output .= '<a href="?Version='.$DbRow['Version'].'" title="'.$DbRow['Title'].'">'.$DbRow['Version'].'</a> ';
     111    }
    106112    $Output .= '<br/>';
    107113
  • trunk/Modules/Translation/Save.php

    r888 r893  
    55  function Translate($Group, $TextID, $Complete, $Language)
    66  {
     7    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    78    $Output = '';
    89    $Table = $Group['TablePrefix'];
     
    1718      // Get data for english original
    1819      $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE (`Entry`='.$SourceText['Entry'].') '.
    19           'AND (`Language` = '.$this->System->Config['OriginalLanguage'].') AND (`VersionStart` = '.$SourceText['VersionStart'].') '.
     20          'AND (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND (`VersionStart` = '.$SourceText['VersionStart'].') '.
    2021          'AND (`VersionEnd` = '.$SourceText['VersionEnd'].')');
    2122      if ($DbResult->num_rows > 0)
     
    3334          else $Filter = ' AND 0';
    3435
    35           $Query = 'SELECT * FROM `'.$Table.'` WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].')'.$Filter;
     36          $Query = 'SELECT * FROM `'.$Table.'` WHERE (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].')'.$Filter;
    3637          $DbResult = $this->Database->query($Query);
    3738          while ($EnglishFound = $DbResult->fetch_assoc())
    3839          {
    3940            // Get user translation paired to found english item entry
    40             $DbResult2 = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE (`User` = '.$this->System->User->Id.
     41            $DbResult2 = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE (`User` = '.$User->Id.
    4142              ') AND (`Entry` = '.$EnglishFound['Entry'].') AND (`VersionStart` = '.$EnglishFound['VersionStart'].
    4243              ') AND (`VersionEnd` = '.$EnglishFound['VersionEnd'].')');
     
    110111              $Columns = '`Entry`, `VersionStart`, `VersionEnd`, `Language`, `User`, `Take`, `ModifyTime`';
    111112              $Values = $EnglishFound['Entry'].', '.$EnglishFound['VersionStart'].', '.
    112                   $EnglishFound['VersionEnd'].', '.$Language.', '.$this->System->User->Id.', '.$TakeID.', NOW()';
     113                  $EnglishFound['VersionEnd'].', '.$Language.', '.$User->Id.', '.$TakeID.', NOW()';
    113114
    114115              $CompleteParts = 0;
     
    178179    global $Message, $MessageType;
    179180
     181    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    180182    $Output = '';
    181183    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
     
    188190    $Group = $TranslationTree[$GroupId];
    189191    $Table = $Group['TablePrefix'];
    190     if ($this->System->User->Licence(LICENCE_USER))
     192    if ($User->Licence(LICENCE_USER))
    191193    {
    192194      if (array_key_exists('ID', $_POST) and is_numeric($_POST['ID']))
     
    202204        $Output .= $this->ShowRedirection($GroupId, $Table, $TextID);
    203205
    204         UserLevelUpdate($this->System->User->Id);
     206        UserLevelUpdate($User->Id);
    205207      } else $Output .= ShowMessage('Položka nenalezena', MESSAGE_CRITICAL);
    206208    } else
     
    237239  function ShowRedirection($GroupId, $Table, $TextID)
    238240  {
     241    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    239242    // Address and redirecting
    240243    $Output = '<br />'.T('Translate').': <a href="'.$this->System->Link('/TranslationList.php?group='.$GroupId.'&amp;state=1&amp;user=0&entry=').'">'.T('Not translated').'</a> ';
     
    243246    $next = FollowingTran($TextID, $Table, $GroupId);
    244247    $Output .= '<br /><br />';
    245     $DbResult = $this->Database->query('SELECT `Redirecting` FROM `User` WHERE `ID`='.$this->System->User->Id);
     248    $DbResult = $this->Database->query('SELECT `Redirecting` FROM `User` WHERE `ID`='.$User->Id);
    246249    $redirecting = $DbResult->fetch_assoc();
    247250
  • trunk/Modules/Translation/Translation.php

    r888 r893  
    1111class ModuleTranslation extends Module
    1212{
     13  public array $TranslationTree;
     14
    1315  function __construct(System $System)
    1416  {
     
    7981      (
    8082        'Title' => strip_tags($DbRow['Text'].' ('.$DbRow['UserName'].')'),
    81         'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/'),
     83        'Link' => 'http://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/'),
    8284        'Description' => $DbRow['Text'],
    8385        'Time' => $DbRow['Date'],
     
    8688    $Output = GenerateRSS(array
    8789    (
    88       'Title' => $this->System->Config['Web']['Title'].' - '.T('Last translations'),
    89       'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/'),
    90       'Description' => $this->System->Config['Web']['Description'],
    91       'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'],
     90      'Title' => Core::Cast($this->System)->Config['Web']['Title'].' - '.T('Last translations'),
     91      'Link' => 'https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/'),
     92      'Description' => Core::Cast($this->System)->Config['Web']['Description'],
     93      'WebmasterEmail' => Core::Cast($this->System)->Config['Web']['AdminEmail'],
    9294      'Items' => $Items,
    9395    ));
     
    113115            $DbRow['Id'].' AS `Group`, "'.addslashes($DbRow['Name']).'" AS `GroupName`, `T`.`Take` FROM `'.
    114116            $DbRow['TablePrefix'].'` AS `T`'.
    115             ' WHERE (`T`.`Complete` = 1) AND (`T`.`Language` != '.$this->System->Config['OriginalLanguage'].') ORDER BY `T`.`ModifyTime` DESC LIMIT '.
     117            ' WHERE (`T`.`Complete` = 1) AND (`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'].') ORDER BY `T`.`ModifyTime` DESC LIMIT '.
    116118            $Count.') AS `T`';
    117119      }
     
    139141  {
    140142    if (isset($this->TranslationTree)) return $this->TranslationTree;
    141     else {
     143    else
     144    {
    142145      $Result = array();
    143146      $Groups = array();
     
    164167  function ShowTranslatedMenu()
    165168  {
     169    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    166170    $TranslationTree = $this->GetTranslationTree();
    167171
     
    183187        '&nbsp;<a title="Přeložené texty, můžete zde hlasovat, nebo opravovat překlady" href="'.
    184188        $this->System->Link('/TranslationList.php?group='.$Group['Id'].'&amp;state=2&amp;user=0&amp;entry=&amp;text=').'">'.T('Translated').'</a><br />';
    185       if (isset($this->System->User) and $this->System->User->Licence(LICENCE_USER))
     189      if (isset($User) and $User->Licence(LICENCE_USER))
    186190      {
    187191        $Output .= '&nbsp;<a title="'.T('Unfinished translations').'" href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&amp;state=3').'">'.T('Unfinished').'</a><br />'.
    188192          '&nbsp;<a title="Všechny překlady, které jste přeložil" href="'.
    189193          $this->System->Link('/TranslationList.php?group='.$Group['Id'].'&amp;state=1&amp;user='.
    190           $this->System->User->Id).'&amp;entry=&amp;text=">'.T('Own').'</a><br />';
     194          $User->Id).'&amp;entry=&amp;text=">'.T('Own').'</a><br />';
    191195      }
    192196      $Output .= '&nbsp;<a title="'.T('Compose special filter').'" href="'.
     
    198202    return $Output;
    199203  }
     204
     205  static function Cast(Module $Module): ModuleTranslation
     206  {
     207    if ($Module instanceof ModuleTranslation)
     208    {
     209      return $Module;
     210    }
     211    throw new Exception('Expected '.ModuleTranslation::GetClassName().' type but got '.gettype($Module));
     212  }
    200213}
  • trunk/Modules/Translation/TranslationList.php

    r888 r893  
    1313}
    1414
    15 
    1615class PageTranslationList extends Page
    1716{
    1817  function ShowFilter($GroupId = 0)
    1918  {
    20     $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
     19    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     20    $TranslationTree = ModuleTranslation::Cast($this->System->GetModule('Translation'))->GetTranslationTree();
    2121
    2222    $Filter = array('SQL' => '');
     
    8585    $Output .= '</select></td>';
    8686
    87     if ($this->System->User->Licence(LICENCE_USER))
    88       $Filter['Version'] = GetParameter('version', $this->System->User->PreferredVersion, true, true);
     87    if ($User->Licence(LICENCE_USER))
     88      $Filter['Version'] = GetParameter('version', $User->PreferredVersion, true, true);
    8989    else
    9090      $Filter['Version'] = GetParameter('version', 0, true, true);
     
    176176    {
    177177        $WithoutAlter =       ' AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '.
    178           '(`Sub`.`Language` <> '.$this->System->Config['OriginalLanguage'].')'.$LanguageFilterSub.
     178          '(`Sub`.`Language` <> '.Core::Cast($this->System)->Config['OriginalLanguage'].')'.$LanguageFilterSub.
    179179          ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`ID` != `T`.`ID`) AND (`Sub`.`Complete` = 1) AND '.
    180180          '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`) LIMIT 1 ) ';
     
    184184                           ' < ('.
    185185                                          'SELECT LENGTH(`Sub`.`'.$GroupItem['Column'].'`) - LENGTH( REPLACE( `Sub`.`'.$GroupItem['Column'].'`,  \'$\',  \'\' ) ) FROM `'.$Table.'` AS `Sub` WHERE '.
    186                                           ' `Sub`.`Entry` = `T`.`Entry` AND `Sub`.`Language` = '.$this->System->Config['OriginalLanguage'].' AND '.
     186                                          ' `Sub`.`Entry` = `T`.`Entry` AND `Sub`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].' AND '.
    187187                                          '`Sub`.`VersionStart` = `T`.`VersionStart` AND `Sub`.`VersionEnd` = `T`.`VersionEnd` LIMIT 1 '.
    188188                              ')';
     
    192192      } else
    193193      if ($Filter['State'] == CompletionState::NotTranslated) {
    194         $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$this->System->Config['OriginalLanguage'].') '.
     194        $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') '.
    195195          'AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '.
    196           '(`Sub`.`Language` <> '.$this->System->Config['OriginalLanguage'].') '.$LanguageFilterSub.$UserFilter.
     196          '(`Sub`.`Language` <> '.Core::Cast($this->System)->Config['OriginalLanguage'].') '.$LanguageFilterSub.$UserFilter.
    197197          ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`Complete` = 1) AND '.
    198198          '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`))';
     
    202202      } else
    203203      if ($Filter['State'] == CompletionState::NotFinished) {
    204         $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '.$this->System->Config['OriginalLanguage'].
     204        $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'].
    205205      ') AND (`T`.`Complete` = 0)';
    206206      } else
    207207      if ($Filter['State'] == CompletionState::Original) {
    208         $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$this->System->Config['OriginalLanguage'].')';
     208        $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].')';
    209209      } else
    210210      if ($Filter['State'] == CompletionState::NotFinishedNotTranslated) {
    211211        $Filter['SQL'] .= $UserFilter.$VersionFilter.$WithoutAlter.
    212       ' AND (`T`.`Language` != '.$this->System->Config['OriginalLanguage'].
     212      ' AND (`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'].
    213213      ') AND (`T`.`Complete` = 0)';
    214214      } else
    215215      if ($Filter['State'] == CompletionState::Missing1) {
    216         $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.$this->System->Config['OriginalLanguage'];
     216        $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'];
    217217        $Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') ';
    218218      } else
    219219      if ($Filter['State'] == CompletionState::Missing2) {
    220         $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.$this->System->Config['OriginalLanguage'];
     220        $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'];
    221221        $Filter['SQL'] .= ' '. $WithoutAlter;
    222222        $Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') ';
     
    333333  function ShowMenu()
    334334  {
     335    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    335336    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    336337
     
    351352          '<td>'.T('Texts marked as unfinished').'</td></tr>';
    352353
    353       if ($this->System->User->Licence(LICENCE_USER))
     354      if ($User->Licence(LICENCE_USER))
    354355      {
    355         $Output .= '<tr><td><a title="'.T('Unfinished texts').'" href="?group='.$GroupId.'&amp;state=3&amp;user='.$this->System->User->Id.'">'.T('My unfinished').'</a></td>
     356        $Output .= '<tr><td><a title="'.T('Unfinished texts').'" href="?group='.$GroupId.'&amp;state=3&amp;user='.$User->Id.'">'.T('My unfinished').'</a></td>
    356357        <td>'.T('Unfinished texts of logged-in user').'</td></tr>
    357         <tr><td><a title="'.T('Translated texts of logged-in user').'" href="?group='.$GroupId.'&amp;state=2&amp;user='.$this->System->User->Id.'">'.T('My translated').'</a></td>
     358        <tr><td><a title="'.T('Translated texts of logged-in user').'" href="?group='.$GroupId.'&amp;state=2&amp;user='.$User->Id.'">'.T('My translated').'</a></td>
    358359        <td>'.T('Translated texts of logged-in user').'</td></tr>';
    359360      }
     
    395396  function ShowList()
    396397  {
     398    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    397399    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Group`');
    398400    $DbRow = $DbResult->fetch_row();
     
    408410      array('Name' => 'LastImport', 'Title' => T('Date of last import')),
    409411      array('Name' => 'LastVersion', 'Title' => T('Version of last import')),
    410    );
    411    if ($this->System->User->Licence(LICENCE_ADMIN))
    412    $TableColumns[] = array('Name' => '', 'Title' => T('Actions'));
    413 
    414    $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
    415    $Output .= $Order['Output'];
    416 
    417    $DbResult = $this->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']);
    418    while ($Group = $DbResult->fetch_assoc())
    419    {
    420      $Output .= '<tr><td><a href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&amp;action=filter').'">'.T($Group['Name']).'</a></td>'.
    421        '<td>'.$Group['SourceType'].'</td><td>';
    422      if ($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql ';
    423      if ($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc ';
    424      if ($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua ';
    425      $Output .= '</td>';
    426      if ($this->System->User->Licence(LICENCE_ADMIN))
    427        $Output .= '<td><a title="Změny po posledním importu u vybrané překladové skupiny" href="'.$this->System->Link('/log/?group='.
    428      $Group['Id'].'&amp;type=11').'">'.HumanDate($Group['LastImport']).'</a></td>';
    429        else $Output .= '<td>'.HumanDate($Group['LastImport']).'</td>';
    430      $Output .= '<td><a href="'.$this->System->Link('/client-version/?action=item&amp;id='.
    431        GetVersionWOWId($Group['LastVersion'])).'">'.GetVersionWOW($Group['LastVersion']).'</a></td>';
    432      if ($this->System->User->Licence(LICENCE_ADMIN))
    433        $Output .= '<td><a href="?action=groupdelete&amp;id='.$Group['Id'].'">'.T('Remove').'</a></td>';
    434      $Output .= '</tr>';
     412    );
     413    if ($User->Licence(LICENCE_ADMIN))
     414    $TableColumns[] = array('Name' => '', 'Title' => T('Actions'));
     415
     416    $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
     417    $Output .= $Order['Output'];
     418
     419    $DbResult = $this->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']);
     420    while ($Group = $DbResult->fetch_assoc())
     421    {
     422      $Output .= '<tr><td><a href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&amp;action=filter').'">'.T($Group['Name']).'</a></td>'.
     423        '<td>'.$Group['SourceType'].'</td><td>';
     424      if ($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql ';
     425      if ($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc ';
     426      if ($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua ';
     427      $Output .= '</td>';
     428      if ($User->Licence(LICENCE_ADMIN))
     429        $Output .= '<td><a title="Změny po posledním importu u vybrané překladové skupiny" href="'.$this->System->Link('/log/?group='.
     430      $Group['Id'].'&amp;type=11').'">'.HumanDate($Group['LastImport']).'</a></td>';
     431        else $Output .= '<td>'.HumanDate($Group['LastImport']).'</td>';
     432      $Output .= '<td><a href="'.$this->System->Link('/client-version/?action=item&amp;id='.
     433        GetVersionWOWId($Group['LastVersion'])).'">'.GetVersionWOW($Group['LastVersion']).'</a></td>';
     434      if ($User->Licence(LICENCE_ADMIN))
     435        $Output .= '<td><a href="?action=groupdelete&amp;id='.$Group['Id'].'">'.T('Remove').'</a></td>';
     436      $Output .= '</tr>';
    435437    }
    436438    $Output .= '</table>'.
    437439      '<br /><a title="'.T('Changelog of changes after import').'" href="'.$this->System->Link('/log/?type=11').'">'.T('Changelog of text modification during import').'</a><br/>';
    438     if ($this->System->User->Licence(LICENCE_ADMIN)) $Output .= '<a href="?action=groupadd">'.T('Add translation group').'</a>';
     440    if ($User->Licence(LICENCE_ADMIN)) $Output .= '<a href="?action=groupadd">'.T('Add translation group').'</a>';
    439441    return $Output;
    440442  }
     
    442444  function ShowGroupAdd()
    443445  {
    444     if ($this->System->User->Licence(LICENCE_ADMIN))
     446    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     447    if ($User->Licence(LICENCE_ADMIN))
    445448    {
    446449      $Output = '<h3>Vložení nové překladové skupiny</h3>'.
     
    457460  function ShowGroupAddFinish()
    458461  {
    459     if ($this->System->User->Licence(LICENCE_ADMIN))
     462    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     463    if ($User->Licence(LICENCE_ADMIN))
    460464    {
    461465      $TableName = 'Text'.$_POST['TablePrefix'];
     
    505509  function ShowGroupDelete()
    506510  {
    507     if ($this->System->User->Licence(LICENCE_ADMIN))
     511    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     512    if ($User->Licence(LICENCE_ADMIN))
    508513    {
    509514      $DbResult = $this->System->Database->select('Group', '*', '`Id`='.$_GET['id']);
Note: See TracChangeset for help on using the changeset viewer.