Changeset 880 for trunk/Modules/Wiki
- Timestamp:
- Apr 7, 2020, 10:15:48 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Wiki/Wiki.php
r843 r880 22 22 { 23 23 $DbResult = $this->Database->select('WikiPage', '*', '`VisibleInMenu`=1'); 24 while ($DbRow = $DbResult->fetch_assoc())24 while ($DbRow = $DbResult->fetch_assoc()) 25 25 { 26 26 $this->System->RegisterPage($DbRow['NormalizedName'], 'PageWiki'); … … 40 40 function Show() 41 41 { 42 if (array_key_exists('Action', $_GET))43 { 44 if ($_GET['Action'] == 'Edit') $Output = $this->EditContent();45 else if ($_GET['Action'] == 'EditSave') $Output = $this->SaveContent();46 else if ($_GET['Action'] == 'History') $Output = $this->ShowHistory();42 if (array_key_exists('Action', $_GET)) 43 { 44 if ($_GET['Action'] == 'Edit') $Output = $this->EditContent(); 45 else if ($_GET['Action'] == 'EditSave') $Output = $this->SaveContent(); 46 else if ($_GET['Action'] == 'History') $Output = $this->ShowHistory(); 47 47 else $Output = $this->ShowContent(); 48 48 } else $Output = $this->ShowContent(); 49 return ($Output);49 return $Output; 50 50 } 51 51 … … 54 54 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 55 55 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 56 if ($DbResult->num_rows > 0)56 if ($DbResult->num_rows > 0) 57 57 { 58 58 $DbRow = $DbResult->fetch_assoc(); 59 if (array_key_exists('ver', $_GET))59 if (array_key_exists('ver', $_GET)) 60 60 { 61 61 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' AND Id='.$_GET['ver']*1); 62 if ($DbResult2->num_rows > 0)62 if ($DbResult2->num_rows > 0) 63 63 { 64 64 $DbRow2 = $DbResult2->fetch_assoc(); 65 65 $Output = '<h3>Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')</h3>'; 66 66 $Output .= $DbRow2['Content']; 67 if ($this->System->User->Licence(LICENCE_MODERATOR))67 if ($this->System->User->Licence(LICENCE_MODERATOR)) 68 68 $Output .= '<div><a href="?Action=Edit">Upravit nejnovější</a> <a href="?Action=History">Historie</a></div>'; 69 69 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); … … 71 71 { 72 72 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1'); 73 if ($DbResult2->num_rows > 0)73 if ($DbResult2->num_rows > 0) 74 74 { 75 75 $DbRow2 = $DbResult2->fetch_assoc(); 76 76 $Output = '<h3>'.$DbRow['Name'].'</h3>'; 77 77 $Output .= $DbRow2['Content']; 78 if ($this->System->User->Licence(LICENCE_MODERATOR))78 if ($this->System->User->Licence(LICENCE_MODERATOR)) 79 79 $Output .= '<hr><div><a href="?Action=Edit">Upravit</a> <a href="?Action=History">Historie</a></div>'; 80 80 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 81 81 } 82 82 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 83 return ($Output);83 return $Output; 84 84 } 85 85 86 86 function EditContent() 87 87 { 88 if ($this->System->User->Licence(LICENCE_MODERATOR))88 if ($this->System->User->Licence(LICENCE_MODERATOR)) 89 89 { 90 90 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 91 91 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 92 if ($DbResult->num_rows > 0)92 if ($DbResult->num_rows > 0) 93 93 { 94 94 $DbRow = $DbResult->fetch_assoc(); 95 95 $Output = '<h3>Úprava '.$DbRow['Name'].'</h3>'; 96 96 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1'); 97 if ($DbResult2->num_rows > 0)97 if ($DbResult2->num_rows > 0) 98 98 { 99 99 $DbRow2 = $DbResult2->fetch_assoc(); … … 106 106 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 107 107 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 108 return ($Output);108 return $Output; 109 109 } 110 110 111 111 function SaveContent() 112 112 { 113 if ($this->System->User->Licence(LICENCE_MODERATOR))113 if ($this->System->User->Licence(LICENCE_MODERATOR)) 114 114 { 115 115 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 116 116 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 117 if ($DbResult->num_rows > 0)117 if ($DbResult->num_rows > 0) 118 118 { 119 119 $DbRow = $DbResult->fetch_assoc(); 120 if (array_key_exists('content', $_POST) and array_key_exists('save', $_POST))120 if (array_key_exists('content', $_POST) and array_key_exists('save', $_POST)) 121 121 { 122 122 $DbResult2 = $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']), … … 127 127 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 128 128 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 129 return ($Output);129 return $Output; 130 130 } 131 131 132 132 function ShowHistory() 133 133 { 134 if ($this->System->User->Licence(LICENCE_MODERATOR))134 if ($this->System->User->Licence(LICENCE_MODERATOR)) 135 135 { 136 136 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 137 137 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 138 if ($DbResult->num_rows > 0)138 if ($DbResult->num_rows > 0) 139 139 { 140 140 $DbRow = $DbResult->fetch_assoc(); … … 160 160 ' FROM `WikiPageContent` WHERE Page='. 161 161 $DbRow['Id'].' '.$Order['SQL'].$PageList['SQLLimit']); 162 while ($PageContent = $DbResult2->fetch_assoc())162 while ($PageContent = $DbResult2->fetch_assoc()) 163 163 { 164 164 $Output .= '<tr>'. … … 173 173 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 174 174 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 175 return ($Output);175 return $Output; 176 176 } 177 177 … … 200 200 $text = str_replace("\r\n", '<br/>', $text); 201 201 $text = '<p>'.$text.'</p>'; 202 return ($text);202 return $text; 203 203 } 204 204 }
Note:
See TracChangeset
for help on using the changeset viewer.