Changeset 575 for trunk/Modules/Wiki/Wiki.php
- Timestamp:
- Aug 28, 2013, 11:31:10 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Wiki/Wiki.php
r573 r575 60 60 if($_GET['Action'] == 'Edit') $Output = $this->EditContent(); 61 61 else if($_GET['Action'] == 'EditSave') $Output = $this->SaveContent(); 62 else if($_GET['Action'] == 'History') $Output = $this->ShowHistory(); 62 63 else $Output = $this->ShowContent(); 63 64 } else $Output = $this->ShowContent(); … … 72 73 { 73 74 $DbRow = $DbResult->fetch_assoc(); 74 $Output = '<h3>'.$DbRow['Name'].'</h3>'; 75 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1'); 76 if($DbResult2->num_rows > 0) 77 { 78 $DbRow2 = $DbResult2->fetch_assoc(); 79 $Output .= $DbRow2['Content']; 80 if($this->System->User->Licence(LICENCE_MODERATOR)) 81 $Output .= '<div><a href="?Action=Edit">Upravit</a></div>'; 82 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 75 if(array_key_exists('ver', $_GET)) 76 { 77 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' AND Id='.$_GET['ver']*1); 78 if($DbResult2->num_rows > 0) 79 { 80 $DbRow2 = $DbResult2->fetch_assoc(); 81 $Output = '<h3>Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')</h3>'; 82 $Output .= $DbRow2['Content']; 83 if($this->System->User->Licence(LICENCE_MODERATOR)) 84 $Output .= '<div><a href="?Action=Edit">Upravit nejnovější</a> <a href="?Action=History">Historie</a></div>'; 85 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 86 } else 87 { 88 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1'); 89 if($DbResult2->num_rows > 0) 90 { 91 $DbRow2 = $DbResult2->fetch_assoc(); 92 $Output = '<h3>'.$DbRow['Name'].'</h3>'; 93 $Output .= $DbRow2['Content']; 94 if($this->System->User->Licence(LICENCE_MODERATOR)) 95 $Output .= '<div><a href="?Action=Edit">Upravit</a> <a href="?Action=History">Historie</a></div>'; 96 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 97 } 83 98 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 84 99 return($Output); … … 87 102 function EditContent() 88 103 { 104 if($this->System->User->Licence(LICENCE_MODERATOR)) 105 { 89 106 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 90 107 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); … … 98 115 $DbRow2 = $DbResult2->fetch_assoc(); 99 116 $Output .= '<form action="?Action=EditSave" method="post">'. 100 '<textarea name="content" rows="8" cols="80" onkeydown="ResizeTextArea(this)" class="textedit">'.$DbRow2['Content'].'</textarea>'. 101 '<input type="submit" value="Uložit"/>'. 117 '<textarea name="content" rows="8" cols="80" onkeydown="ResizeTextArea(this)" class="textedit">'.$DbRow2['Content'].'</textarea><br/>'. 118 '<input type="submit" name="save" value="Uložit"/> '. 119 '<input type="button" name="cancel" value="Zrušit" onclick="location.href=\'?\'"/>'. 102 120 '</form>'; 103 121 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 104 122 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 123 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 105 124 return($Output); 106 125 } … … 108 127 function SaveContent() 109 128 { 129 if($this->System->User->Licence(LICENCE_MODERATOR)) 130 { 110 131 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 111 132 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); … … 113 134 { 114 135 $DbRow = $DbResult->fetch_assoc(); 115 $DbResult2 = $this->Database->insert('WikiPageContent', array('Content' => $_POST['content'], 116 'User' => $this->System->User->Id, 'Time' => 'NOW()', 'Page' => $DbRow['Id'])); 117 $Output = ShowMessage('Wiki stránka uložena', MESSAGE_INFORMATION); 136 if(array_key_exists('content', $_POST) and array_key_exists('save', $_POST)) 137 { 138 $DbResult2 = $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']), 139 'User' => $this->System->User->Id, 'Time' => 'NOW()', 'Page' => $DbRow['Id'])); 140 $Output = ShowMessage('Wiki stránka uložena', MESSAGE_INFORMATION); 141 } else $Output = ShowMessage('Nezadána platná data', MESSAGE_CRITICAL); 118 142 $Output .= $this->ShowContent(); 119 143 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 144 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 145 return($Output); 146 } 147 148 function ShowHistory() 149 { 150 if($this->System->User->Licence(LICENCE_MODERATOR)) 151 { 152 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 153 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 154 if($DbResult->num_rows > 0) 155 { 156 $DbRow = $DbResult->fetch_assoc(); 157 158 $Output = '<h3>Historie stránky '.$DbRow['Name'].'</h3>'; 159 $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM `WikiPageContent` WHERE Page='.$DbRow['Id']); 160 $DbRow2 = $DbResult2->fetch_row(); 161 $PageList = GetPageList($DbRow2[0]); 162 163 $Output .= $PageList['Output']; 164 $Output .= '<table class="BaseTable">'; 165 166 $TableColumns = array( 167 array('Name' => 'Time', 'Title' => 'Čas'), 168 array('Name' => 'User', 'Title' => 'Uživatel'), 169 array('Name' => 'Action', 'Title' => 'Akce'), 170 ); 171 172 $Order = GetOrderTableHeader($TableColumns, 'Time', 1); 173 $Output .= $Order['Output']; 174 175 $DbResult2 = $this->Database->query('SELECT *, (SELECT `Name` FROM `User` WHERE `User`.`ID`=`WikiPageContent`.`User`) AS `UserName` '. 176 ' FROM `WikiPageContent` WHERE Page='. 177 $DbRow['Id'].' '.$Order['SQL'].$PageList['SQLLimit']); 178 while($PageContent = $DbResult2->fetch_assoc()) 179 { 180 $Output .= '<tr>'. 181 '<td>'.HumanDateTime($PageContent['Time']).'</td>'. 182 '<td><a href="'.$this->System->Link('/user.php?user='.$PageContent['User']).'">'.$PageContent['UserName'].'</a></td>'. 183 '<td><a href="?id='.$PageContent['Id'].'&ver='.$PageContent['Id'].'">Zobrazit</a></td>'; 184 $Output .= '</tr>'; 185 } 186 187 $Output .= '</table>'. 188 $PageList['Output']; 189 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 190 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 120 191 return($Output); 121 192 }
Note:
See TracChangeset
for help on using the changeset viewer.