Changeset 887 for trunk/Modules/Wiki/Wiki.php
- Timestamp:
- Nov 20, 2020, 12:08:12 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Wiki/Wiki.php
r874 r887 3 3 class ModuleWiki extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 15 15 } 16 16 17 function DoInstall() 17 function DoInstall(): void 18 18 { 19 19 parent::Install(); … … 42 42 } 43 43 44 function DoUnInstall() 44 function DoUnInstall(): void 45 45 { 46 46 $this->Database->query('DELETE TABLE `WikiPageContent`'); … … 48 48 } 49 49 50 function DoStart() 50 function DoStart(): void 51 51 { 52 52 $this->LoadPages(); 53 53 } 54 54 55 function DoStop() 56 { 57 } 58 59 function LoadPages() 55 function DoStop(): void 56 { 57 } 58 59 function LoadPages(): void 60 60 { 61 61 $DbResult = $this->Database->select('WikiPage', '*', 'VisibleInMenu=1'); 62 62 while ($DbRow = $DbResult->fetch_assoc()) 63 63 { 64 $this->System->RegisterPage( $DbRow['NormalizedName'], 'PageWiki');64 $this->System->RegisterPage([$DbRow['NormalizedName']], 'PageWiki'); 65 65 $this->System->RegisterMenuItem(array( 66 66 'Title' => $DbRow['Name'], … … 76 76 class PageWiki extends Page 77 77 { 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 83 87 { 84 88 if (array_key_exists('Action', $_GET)) … … 92 96 } 93 97 94 function ShowContent() 98 function ShowContent(): string 95 99 { 96 100 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; … … 107 111 $Output = '<h3>Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')</h3>'; 108 112 $Output .= $DbRow2['Content']; 109 if ( $this->System->User->Licence(LICENCE_MODERATOR))113 if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR)) 110 114 $Output .= '<div><a href="?Action=Edit">Upravit nejnovější</a> <a href="?Action=History">Historie</a></div>'; 111 } else $Output = Show Message('Wiki stránka nenalezena', MESSAGE_CRITICAL);115 } else $Output = ShowmMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 112 116 } else 113 117 { … … 118 122 $Output = '<h3>'.$DbRow['Name'].'</h3>'; 119 123 $Output .= $DbRow2['Content']; 120 if ( $this->System->User->Licence(LICENCE_MODERATOR))124 if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR)) 121 125 $Output .= '<div><a href="?Action=Edit">Upravit</a> <a href="?Action=History">Historie</a></div>'; 122 126 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); … … 126 130 } 127 131 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)) 131 135 { 132 136 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; … … 151 155 } 152 156 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)) 156 160 { 157 161 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; … … 162 166 if (array_key_exists('content', $_POST) and array_key_exists('save', $_POST)) 163 167 { 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'])); 166 170 $Output = ShowMessage('Wiki stránka uložena', MESSAGE_INFORMATION); 167 171 } else $Output = ShowMessage('Nezadána platná data', MESSAGE_CRITICAL); … … 172 176 } 173 177 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)) 177 181 { 178 182 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; … … 218 222 } 219 223 220 function ToHtml( $text)224 function ToHtml(string $text): string 221 225 { 222 226 $text = preg_replace('/<source lang="(.*?)">(.*?)<\/source>/', '<pre lang="$1">$2</pre>', $text);
Note:
See TracChangeset
for help on using the changeset viewer.