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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.