Changeset 893 for trunk/Modules/Wiki
- Timestamp:
- Mar 6, 2023, 1:48:45 AM (21 months ago)
- Location:
- trunk/Modules/Wiki
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Wiki/Wiki.php
r888 r893 1 1 <?php 2 2 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 } 3 include_once(dirname(__FILE__).'/ModuleWiki.php'); 37 4 38 5 class PageWiki extends Page … … 52 19 function ShowContent() 53 20 { 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]; 55 23 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 56 24 if ($DbResult->num_rows > 0) … … 65 33 $Output = '<h3>Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')</h3>'; 66 34 $Output .= $DbRow2['Content']; 67 if ($ this->System->User->Licence(LICENCE_MODERATOR))35 if ($User->Licence(LICENCE_MODERATOR)) 68 36 $Output .= '<div><a href="?Action=Edit">Upravit nejnovější</a> <a href="?Action=History">Historie</a></div>'; 69 37 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); … … 76 44 $Output = '<h3>'.$DbRow['Name'].'</h3>'; 77 45 $Output .= $DbRow2['Content']; 78 if ($ this->System->User->Licence(LICENCE_MODERATOR))46 if ($User->Licence(LICENCE_MODERATOR)) 79 47 $Output .= '<hr><div><a href="?Action=Edit">Upravit</a> <a href="?Action=History">Historie</a></div>'; 80 48 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); … … 86 54 function EditContent() 87 55 { 88 if ($this->System->User->Licence(LICENCE_MODERATOR)) 56 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 57 if ($User->Licence(LICENCE_MODERATOR)) 89 58 { 90 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];59 $PageName = Core::Cast($this->System)->PathItems[count(Core::Cast($this->System)->PathItems) - 1]; 91 60 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 92 61 if ($DbResult->num_rows > 0) … … 111 80 function SaveContent() 112 81 { 113 if ($this->System->User->Licence(LICENCE_MODERATOR)) 82 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 83 if ($User->Licence(LICENCE_MODERATOR)) 114 84 { 115 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];85 $PageName = Core::Cast($this->System)->PathItems[count(Core::Cast($this->System)->PathItems) - 1]; 116 86 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 117 87 if ($DbResult->num_rows > 0) … … 121 91 { 122 92 $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'])); 124 94 $Output = ShowMessage('Wiki stránka uložena', MESSAGE_INFORMATION); 125 95 } else $Output = ShowMessage('Nezadána platná data', MESSAGE_CRITICAL); … … 132 102 function ShowHistory() 133 103 { 134 if ($this->System->User->Licence(LICENCE_MODERATOR)) 104 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 105 if ($User->Licence(LICENCE_MODERATOR)) 135 106 { 136 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];107 $PageName = Core::Cast($this->System)->PathItems[count(Core::Cast($this->System)->PathItems) - 1]; 137 108 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 138 109 if ($DbResult->num_rows > 0)
Note:
See TracChangeset
for help on using the changeset viewer.