Changeset 896


Ignore:
Timestamp:
Jan 14, 2021, 7:38:26 PM (3 years ago)
Author:
chronos
Message:
  • Fixed: Correct typecasting of System class.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Core.php

    r895 r896  
    8585  {
    8686    return $this->RootURLFolder.$Target;
    87   }
    88 
    89   function ShowAction(string $Id): string
    90   {
    91     $Output = '';
    92     $DbResult = $this->Database->query('SELECT *, `ActionIcon`.`Name` AS `Icon` FROM `Action` '.
    93       'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '.
    94       'WHERE (`Action`.`Id`='.$Id.')');
    95     if ($DbResult->num_rows > 0)
    96     {
    97       $Action = $DbResult->fetch_assoc();
    98       if ($Action['Icon'] == '') $Action['Icon'] = 'clear.png';
    99       if (substr($Action['URL'], 0, 4) != 'http') $Action['URL'] = $this->Link($Action['URL']);
    100       if (!defined('NEW_PERMISSION') or ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('System', 'Read', 'Item', $Id))
    101         $Output .= '<img alt="'.$Action['Title'].'" src="'.$this->Link('/images/favicons/'.$Action['Icon']).
    102         '" width="16" height="16" /> <a href="'.$Action['URL'].'">'.$Action['Title'].'</a>';
    103     }
    104     return $Output;
    10587  }
    10688
     
    233215    unset($this->PageHeaders[$Name]);
    234216  }
     217
     218  static function Cast(System $System): Core
     219  {
     220    if ($System instanceof Core)
     221    {
     222      return $System;
     223    }
     224    throw new Exception('Expected ModuleSetup type but '.gettype($System));
     225  }
    235226}
    236227
  • trunk/Application/View.php

    r887 r896  
    119119      $Output .= '<div id="Footer">'.
    120120      '<i>| Správa webu: '.$this->System->Config['Web']['Admin'].' | e-mail: '.$this->System->Config['Web']['AdminEmail'].' | '.
    121       ' Verze: '.$Revision.' ('.$this->System->HumanDate($ReleaseTime).') |';
     121      ' Verze: '.$Revision.' ('.Core::Cast($this->System)->HumanDate($ReleaseTime).') |';
    122122      if ($this->ShowRuntimeInfo == true) $Output .= ' Doba generování: '.$Time.' s / '.ini_get('max_execution_time').
    123123        ' s | Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B |';
  • trunk/Modules/Customer/Customer.php

    r894 r896  
    195195    ));
    196196
    197     ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Customer',
     197    ModuleIS::Cast(Core::Cast($this->System)->GetModule('IS'))->RegisterDashboardItem('Customer',
    198198      array($this, 'ShowDashboardItem'));
    199199  }
  • trunk/Modules/Portal/Portal.php

    r895 r896  
    4343  function DoStart(): void
    4444  {
    45     $this->System->RegisterPage([''], 'PagePortal');
     45    Core::Cast($this->System)->RegisterPage([''], 'PagePortal');
    4646    $this->System->FormManager->RegisterClass('MemberOptions', array(
    4747      'Title' => 'Nastavení zákazníka',
     
    5959      ),
    6060    ));
    61     ModuleUser::Cast($this->System->GetModule('User'))->UserPanel[] = array('PagePortal', 'UserPanel');
     61    ModuleUser::Cast(Core::Cast($this->System)->GetModule('User'))->UserPanel[] = array('PagePortal', 'UserPanel');
    6262  }
    6363}
     
    102102    while ($Action = $DbResult->fetch_assoc())
    103103    {
    104       $Output .= $this->System->ShowAction($Action['Id']).'<br/>';
     104      $Output .= ModuleSystem::Cast($this->System->GetModule('System'))->ShowAction($Action['Id']).'<br/>';
    105105    }
    106106    return $this->Panel($ActionGroup['Name'], $Output);
  • trunk/Modules/System/System.php

    r895 r896  
    202202    $this->Manager->OnUninstallModel = array($this, 'UninstallModel');
    203203
    204     $this->System->RegisterPage(['module'], 'PageModules');
     204    Core::Cast($this->System)->RegisterPage(['module'], 'PageModules');
    205205    $this->System->FormManager->RegisterClass('Action', array(
    206206      'Title' => 'Akce',
     
    624624    throw new Exception('Expected ModuleSystem type but got '.gettype($AppModule));
    625625  }
     626
     627  function ShowAction(string $Id): string
     628  {
     629    $Output = '';
     630    $DbResult = $this->Database->query('SELECT *, `ActionIcon`.`Name` AS `Icon` FROM `Action` '.
     631      'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '.
     632      'WHERE (`Action`.`Id`='.$Id.')');
     633    if ($DbResult->num_rows > 0)
     634    {
     635      $Action = $DbResult->fetch_assoc();
     636      if ($Action['Icon'] == '') $Action['Icon'] = 'clear.png';
     637      if (substr($Action['URL'], 0, 4) != 'http') $Action['URL'] = Core::Cast($this->System)->Link($Action['URL']);
     638      if (!defined('NEW_PERMISSION') or ModuleUser::Cast(Core::Cast($this->System)->GetModule('User'))->User->CheckPermission('System', 'Read', 'Item', $Id))
     639        $Output .= '<img alt="'.$Action['Title'].'" src="'.Core::Cast($this->System)->Link('/images/favicons/'.$Action['Icon']).
     640        '" width="16" height="16" /> <a href="'.$Action['URL'].'">'.$Action['Title'].'</a>';
     641    }
     642    return $Output;
     643  }
    626644}
  • trunk/Modules/User/User.php

    r895 r896  
    4141  {
    4242    if (isset($_SERVER['REMOTE_ADDR'])) $this->User->Check();
    43     $this->System->RegisterPage(['userlist'], 'PageUserList');
    44     $this->System->RegisterPage(['user'], 'PageUser');
    45     $this->System->RegisterPageBarItem('Top', 'User', array($this, 'TopBarCallback'));
     43    Core::Cast($this->System)->RegisterPage(['userlist'], 'PageUserList');
     44    Core::Cast($this->System)->RegisterPage(['user'], 'PageUser');
     45    Core::Cast($this->System)->RegisterPageBarItem('Top', 'User', array($this, 'TopBarCallback'));
    4646    $this->System->FormManager->RegisterClass('UserLogin', array(
    4747      'Title' => 'Přihlášení uživatele',
     
    180180      'Filter' => '1',
    181181    ));
    182     ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('User',
     182    ModuleIS::Cast(Core::Cast($this->System)->GetModule('IS'))->RegisterDashboardItem('User',
    183183      array($this, 'ShowDashboardItem'));
    184184  }
     
    196196    if ($this->User->User['Id'] == null)
    197197    {
    198       $Output = '<a href="'.$this->System->Link('/user/?Action=LoginForm').'">Přihlášení</a> '.
    199         '<a href="'.$this->System->Link('/user/?Action=UserRegister').'">Registrace</a>';
     198      $Output = '<a href="'.Core::Cast($this->System)->Link('/user/?Action=LoginForm').'">Přihlášení</a> '.
     199        '<a href="'.Core::Cast($this->System)->Link('/user/?Action=UserRegister').'">Registrace</a>';
    200200    } else
    201201    {
    202202      $Output = $this->User->User['Name'].
    203         ' <a href="'.$this->System->Link('/user/?Action=UserMenu').'">Nabídka</a>'.
    204         ' <a href="'.$this->System->Link('/user/?Action=Logout').'">Odhlásit</a>';
     203        ' <a href="'.Core::Cast($this->System)->Link('/user/?Action=UserMenu').'">Nabídka</a>'.
     204        ' <a href="'.Core::Cast($this->System)->Link('/user/?Action=Logout').'">Odhlásit</a>';
    205205      //   <a href="'.$this->System->Link('/?Action=UserOptions').'">Nastavení</a>';
    206206    }
  • trunk/Packages/Common/AppModule.php

    r895 r896  
    5353  public array $Dependencies;
    5454  public Database $Database;
    55   public Application $System;
     55  public System $System;
    5656  public AppModuleManager $Manager;
    5757  public $OnChange;
  • trunk/Packages/Common/Setup.php

    r895 r896  
    425425  function DoStart(): void
    426426  {
    427     $this->System->RegisterPage([''], 'PageSetupRedirect');
    428     $this->System->RegisterPage(['setup'], 'PageSetup');
    429     $this->System->RegisterPage(['setup', 'modules'], 'PageSetupModules');
     427    Core::Cast($this->System)->RegisterPage([''], 'PageSetupRedirect');
     428    Core::Cast($this->System)->RegisterPage(['setup'], 'PageSetup');
     429    Core::Cast($this->System)->RegisterPage(['setup', 'modules'], 'PageSetupModules');
    430430  }
    431431
     
    433433  {
    434434    unset($this->UpdateManager);
    435     $this->System->UnregisterPage(['']);
    436     $this->System->UnregisterPage(['setup']);
    437     $this->System->UnregisterPage(['setup', 'modules']);
     435    Core::Cast($this->System)->UnregisterPage(['']);
     436    Core::Cast($this->System)->UnregisterPage(['setup']);
     437    Core::Cast($this->System)->UnregisterPage(['setup', 'modules']);
    438438  }
    439439
Note: See TracChangeset for help on using the changeset viewer.