Changeset 893 for trunk/Modules/Wiki


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/Wiki
Files:
1 added
1 edited

Legend:

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

    r888 r893  
    11<?php
    22
    3 class ModuleWiki extends Module
    4 {
    5   function __construct(System $System)
    6   {
    7     parent::__construct($System);
    8     $this->Name = 'Wiki';
    9     $this->Version = '1.0';
    10     $this->Creator = 'Chronos';
    11     $this->License = 'GNU/GPLv3';
    12     $this->Description = 'Mediawiki style page management';
    13     $this->Dependencies = array();
    14   }
    15 
    16   function DoStart(): void
    17   {
    18     $this->LoadPages();
    19   }
    20 
    21   function LoadPages()
    22   {
    23     $DbResult = $this->Database->select('WikiPage', '*', '`VisibleInMenu`=1');
    24     while ($DbRow = $DbResult->fetch_assoc())
    25     {
    26       $this->System->RegisterPage($DbRow['NormalizedName'], 'PageWiki');
    27       Core::Cast($this->System)->RegisterMenuItem(array(
    28           'Title' => $DbRow['Name'],
    29           'Hint' => '',
    30           'Link' => $this->System->Link('/'.$DbRow['NormalizedName'].'/'),
    31           'Permission' => LICENCE_ANONYMOUS,
    32           'Icon' => '',
    33       ), 6);
    34     }
    35   }
    36 }
     3include_once(dirname(__FILE__).'/ModuleWiki.php');
    374
    385class PageWiki extends Page
     
    5219  function ShowContent()
    5320  {
    54     $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     21    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     22    $PageName = Core::Cast($this->System)->PathItems[count(Core::Cast($this->System)->PathItems) - 1];
    5523    $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"');
    5624    if ($DbResult->num_rows > 0)
     
    6533          $Output = '<h3>Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')</h3>';
    6634          $Output .= $DbRow2['Content'];
    67           if ($this->System->User->Licence(LICENCE_MODERATOR))
     35          if ($User->Licence(LICENCE_MODERATOR))
    6836            $Output .= '<div><a href="?Action=Edit">Upravit nejnovější</a> <a href="?Action=History">Historie</a></div>';
    6937        } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
     
    7644          $Output = '<h3>'.$DbRow['Name'].'</h3>';
    7745          $Output .= $DbRow2['Content'];
    78           if ($this->System->User->Licence(LICENCE_MODERATOR))
     46          if ($User->Licence(LICENCE_MODERATOR))
    7947            $Output .= '<hr><div><a href="?Action=Edit">Upravit</a> <a href="?Action=History">Historie</a></div>';
    8048        } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
     
    8654  function EditContent()
    8755  {
    88     if ($this->System->User->Licence(LICENCE_MODERATOR))
     56    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     57    if ($User->Licence(LICENCE_MODERATOR))
    8958    {
    90     $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     59    $PageName = Core::Cast($this->System)->PathItems[count(Core::Cast($this->System)->PathItems) - 1];
    9160    $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"');
    9261    if ($DbResult->num_rows > 0)
     
    11180  function SaveContent()
    11281  {
    113     if ($this->System->User->Licence(LICENCE_MODERATOR))
     82    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     83    if ($User->Licence(LICENCE_MODERATOR))
    11484    {
    115     $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     85    $PageName = Core::Cast($this->System)->PathItems[count(Core::Cast($this->System)->PathItems) - 1];
    11686    $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"');
    11787    if ($DbResult->num_rows > 0)
     
    12191      {
    12292        $DbResult2 = $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']),
    123           'User' => $this->System->User->Id, 'Time' => 'NOW()', 'Page' => $DbRow['Id']));
     93          'User' => $User->Id, 'Time' => 'NOW()', 'Page' => $DbRow['Id']));
    12494        $Output = ShowMessage('Wiki stránka uložena', MESSAGE_INFORMATION);
    12595      } else $Output = ShowMessage('Nezadána platná data', MESSAGE_CRITICAL);
     
    132102  function ShowHistory()
    133103  {
    134     if ($this->System->User->Licence(LICENCE_MODERATOR))
     104    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     105    if ($User->Licence(LICENCE_MODERATOR))
    135106    {
    136       $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     107      $PageName = Core::Cast($this->System)->PathItems[count(Core::Cast($this->System)->PathItems) - 1];
    137108      $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"');
    138109      if ($DbResult->num_rows > 0)
Note: See TracChangeset for help on using the changeset viewer.