Ignore:
Timestamp:
Nov 20, 2020, 12:08:12 AM (3 years ago)
Author:
chronos
Message:
  • Added: Static types added to almost all classes, methods and function. Supported by PHP 7.4.
  • Fixed: Various found code issues.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Wiki/Wiki.php

    r874 r887  
    33class ModuleWiki extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1515  }
    1616
    17   function DoInstall()
     17  function DoInstall(): void
    1818  {
    1919    parent::Install();
     
    4242  }
    4343
    44   function DoUnInstall()
     44  function DoUnInstall(): void
    4545  {
    4646    $this->Database->query('DELETE TABLE `WikiPageContent`');
     
    4848  }
    4949
    50   function DoStart()
     50  function DoStart(): void
    5151  {
    5252    $this->LoadPages();
    5353  }
    5454
    55   function DoStop()
    56   {
    57   }
    58 
    59   function LoadPages()
     55  function DoStop(): void
     56  {
     57  }
     58
     59  function LoadPages(): void
    6060  {
    6161    $DbResult = $this->Database->select('WikiPage', '*', 'VisibleInMenu=1');
    6262    while ($DbRow = $DbResult->fetch_assoc())
    6363    {
    64       $this->System->RegisterPage($DbRow['NormalizedName'], 'PageWiki');
     64      $this->System->RegisterPage([$DbRow['NormalizedName']], 'PageWiki');
    6565      $this->System->RegisterMenuItem(array(
    6666        'Title' => $DbRow['Name'],
     
    7676class PageWiki extends Page
    7777{
    78   var $FullTitle = 'Wiki stránky';
    79   var $ShortTitle = 'Wiki';
    80   var $ParentClass = 'PagePortal';
    81 
    82   function Show()
     78  function __construct(System $System)
     79  {
     80    parent::__construct($System);
     81    $this->FullTitle = 'Wiki stránky';
     82    $this->ShortTitle = 'Wiki';
     83    $this->ParentClass = 'PagePortal';
     84  }
     85
     86  function Show(): string
    8387  {
    8488    if (array_key_exists('Action', $_GET))
     
    9296  }
    9397
    94   function ShowContent()
     98  function ShowContent(): string
    9599  {
    96100    $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     
    107111          $Output = '<h3>Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')</h3>';
    108112          $Output .= $DbRow2['Content'];
    109           if ($this->System->User->Licence(LICENCE_MODERATOR))
     113          if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR))
    110114            $Output .= '<div><a href="?Action=Edit">Upravit nejnovější</a> <a href="?Action=History">Historie</a></div>';
    111         } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
     115        } else $Output = ShowmMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
    112116      } else
    113117      {
     
    118122          $Output = '<h3>'.$DbRow['Name'].'</h3>';
    119123          $Output .= $DbRow2['Content'];
    120           if ($this->System->User->Licence(LICENCE_MODERATOR))
     124          if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR))
    121125            $Output .= '<div><a href="?Action=Edit">Upravit</a> <a href="?Action=History">Historie</a></div>';
    122126        } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
     
    126130  }
    127131
    128   function EditContent()
    129   {
    130     if ($this->System->User->Licence(LICENCE_MODERATOR))
     132  function EditContent(): string
     133  {
     134    if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR))
    131135    {
    132136    $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     
    151155  }
    152156
    153   function SaveContent()
    154   {
    155     if ($this->System->User->Licence(LICENCE_MODERATOR))
     157  function SaveContent(): string
     158  {
     159    if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR))
    156160    {
    157161    $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     
    162166      if (array_key_exists('content', $_POST) and array_key_exists('save', $_POST))
    163167      {
    164         $DbResult2 = $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']),
    165           'User' => $this->System->User->Id, 'Time' => 'NOW()', 'Page' => $DbRow['Id']));
     168        $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']),
     169          'User' => ModuleUser::Cast($this->System->GetModule('User'))->User->Id, 'Time' => 'NOW()', 'Page' => $DbRow['Id']));
    166170        $Output = ShowMessage('Wiki stránka uložena', MESSAGE_INFORMATION);
    167171      } else $Output = ShowMessage('Nezadána platná data', MESSAGE_CRITICAL);
     
    172176  }
    173177
    174   function ShowHistory()
    175   {
    176     if ($this->System->User->Licence(LICENCE_MODERATOR))
     178  function ShowHistory(): string
     179  {
     180    if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR))
    177181    {
    178182      $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     
    218222  }
    219223
    220   function ToHtml($text)
     224  function ToHtml(string $text): string
    221225  {
    222226    $text = preg_replace('/&lt;source lang=&quot;(.*?)&quot;&gt;(.*?)&lt;\/source&gt;/', '<pre lang="$1">$2</pre>', $text);
Note: See TracChangeset for help on using the changeset viewer.