EditContent(); else if ($_GET['Action'] == 'EditSave') $Output = $this->SaveContent(); else if ($_GET['Action'] == 'History') $Output = $this->ShowHistory(); else $Output = $this->ShowContent(); } else $Output = $this->ShowContent(); return $Output; } function ShowContent() { $User = ModuleUser::Cast($this->System->GetModule('User'))->User; $PageName = Core::Cast($this->System)->PathItems[count(Core::Cast($this->System)->PathItems) - 1]; $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); if (array_key_exists('ver', $_GET)) { $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' AND Id='.$_GET['ver']*1); if ($DbResult2->num_rows > 0) { $DbRow2 = $DbResult2->fetch_assoc(); $Output = '

Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')

'; $Output .= $DbRow2['Content']; if ($User->Licence(LICENCE_MODERATOR)) $Output .= '
Upravit nejnovější Historie
'; } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); } else { $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1'); if ($DbResult2->num_rows > 0) { $DbRow2 = $DbResult2->fetch_assoc(); $Output = '

'.$DbRow['Name'].'

'; $Output .= $DbRow2['Content']; if ($User->Licence(LICENCE_MODERATOR)) $Output .= '
Upravit Historie
'; } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); } } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); return $Output; } function EditContent() { $User = ModuleUser::Cast($this->System->GetModule('User'))->User; if ($User->Licence(LICENCE_MODERATOR)) { $PageName = Core::Cast($this->System)->PathItems[count(Core::Cast($this->System)->PathItems) - 1]; $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $Output = '

Úprava '.$DbRow['Name'].'

'; $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1'); if ($DbResult2->num_rows > 0) { $DbRow2 = $DbResult2->fetch_assoc(); $Output .= '
'. '
'. ' '. ''. '
'; } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); return $Output; } function SaveContent() { $User = ModuleUser::Cast($this->System->GetModule('User'))->User; if ($User->Licence(LICENCE_MODERATOR)) { $PageName = Core::Cast($this->System)->PathItems[count(Core::Cast($this->System)->PathItems) - 1]; $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); if (array_key_exists('content', $_POST) and array_key_exists('save', $_POST)) { $DbResult2 = $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']), 'User' => $User->Id, 'Time' => 'NOW()', 'Page' => $DbRow['Id'])); $Output = ShowMessage('Wiki stránka uložena', MESSAGE_INFORMATION); } else $Output = ShowMessage('Nezadána platná data', MESSAGE_CRITICAL); $Output .= $this->ShowContent(); } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); return $Output; } function ShowHistory() { $User = ModuleUser::Cast($this->System->GetModule('User'))->User; if ($User->Licence(LICENCE_MODERATOR)) { $PageName = Core::Cast($this->System)->PathItems[count(Core::Cast($this->System)->PathItems) - 1]; $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $Output = '

Historie stránky '.$DbRow['Name'].'

'; $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM `WikiPageContent` WHERE Page='.$DbRow['Id']); $DbRow2 = $DbResult2->fetch_row(); $PageList = GetPageList($DbRow2[0]); $Output .= $PageList['Output']; $Output .= ''; $TableColumns = array( array('Name' => 'Time', 'Title' => 'Čas'), array('Name' => 'User', 'Title' => 'Uživatel'), array('Name' => 'Action', 'Title' => 'Akce'), ); $Order = GetOrderTableHeader($TableColumns, 'Time', 1); $Output .= $Order['Output']; $DbResult2 = $this->Database->query('SELECT *, (SELECT `Name` FROM `User` WHERE `User`.`ID`=`WikiPageContent`.`User`) AS `UserName` '. ' FROM `WikiPageContent` WHERE Page='. $DbRow['Id'].' '.$Order['SQL'].$PageList['SQLLimit']); while ($PageContent = $DbResult2->fetch_assoc()) { $Output .= ''. ''. ''. ''; $Output .= ''; } $Output .= '
'.HumanDateTime($PageContent['Time']).''.$PageContent['UserName'].'Zobrazit
'. $PageList['Output']; } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); return $Output; } function ToHtml($text) { $text = preg_replace('/<source lang="(.*?)">(.*?)<\/source>/', '
$2
', $text); $text = preg_replace('/======(.*?)======/', '
$1
', $text); $text = preg_replace('/=====(.*?)=====/', '

$1

', $text); $text = preg_replace('/====(.*?)====/', '

$1

', $text); $text = preg_replace('/===(.*?)===/', '

$1

', $text); $text = preg_replace('/==(.*?)==/', '

$1

', $text); $text = preg_replace("/'''(.*?)'''/", '$1', $text); $text = preg_replace("/''(.*?)''/", '$1', $text); $text = preg_replace('/<s>(.*?)<\/s>/', '$1', $text); $text = preg_replace('/\[\[Image:(.*?)\|(.*?)\]\]/', '$2', $text); $text = preg_replace('/\[(.*?) (.*?)\]/', '$2', $text); $text = preg_replace('/>(.*?)\n/', '
$1
', $text); $text = preg_replace('/\* (.*?)\n/', '', $text); $text = preg_replace('/<\/ul>