<?php require_once 'includes/class_Wiki.inc.php'; try { //Used for editing, we already have an id $wikiDocument = Wiki::getDocument($_GET['page']); } catch (Exception $e) { //Used for processing $wikiDocument = new WikiDocument($_POST['title']); } if (isset($_POST['process'])) { if (is_array($_POST['fieldTitle']) && is_array($_POST['fieldBody'])) { for ($i = 0; $i < sizeOf($_POST['fieldTitle']); $i++) { $body = trim($_POST['fieldBody'][$i]); $field = trim($_POST['fieldTitle'][$i]); if (strlen($body) > 0 && strlen($field) > 0 && $body != "Field Title" && $field != "Field Body") { $wikiDocument->addField($_POST['fieldTitle'][$i], $_POST['fieldBody'][$i]); } } $wikiDocument->addField(WikiDocument::FIELD_DATETIME, time()); Wiki::addDocument($wikiDocument); header("Location: viewPage.php?page=" . $wikiDocument->getId()); exit; } } require_once "header.php"; ?> <script type="text/javascript"> function addField() { var tmpNode = document.createElement("div"); tmpNode.innerHTML = '<div class="formTitle"><input type="text" name="fieldTitle[]" onclick="if(this.value==\'Field Title\') this.value=\'\';" value="Field Title">:</div><textarea name="fieldBody[]" onclick="if(this.value==\'Field Body\') this.value=\'\';">Field Body</textarea>';
<?php require_once 'includes/class_Wiki.inc.php'; //$_GET['page'] = utf8_encode($_GET['page']); try { $wikiDocument = Wiki::getDocument($_GET['page'], $_GET['revision']); } catch (Exception $e) { //Page Not Found header("Location: index.php"); exit; } require_once "header.php"; ?> <div> <?php foreach ($wikiDocument->getField(WikiDocument::ALL_SHOWN_FIELDS) as $key => $field) { if (strlen(trim($field)) == 0) { continue; } ?> <h2><?php echo $key; ?> </h2> <p><?php echo str_replace("\n", "</p><p>", $field); ?> </p> <?php } ?>