78 lines
2.3 KiB
PHTML
78 lines
2.3 KiB
PHTML
<?php
|
|
use ppa\Model\NotesModel;
|
|
include dirname(__DIR__).'/header.phtml';
|
|
|
|
//// Test write permissions
|
|
//// This is the directory we will upload files to.
|
|
//$uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/EIANotesApp/Uploads/';
|
|
//if (!file_exists($uploadDir)) {
|
|
// mkdir($uploadDir, 0777, true);
|
|
//}
|
|
//$testFile = $uploadDir . 'test_write.txt';
|
|
//$testContent = 'Test write operation at ' . date('Y-m-d H:i:s');
|
|
//$writeResult = file_put_contents($testFile, $testContent);
|
|
|
|
$parsedown = new Parsedown();
|
|
$parsedown->setSafeMode(true);
|
|
|
|
$this->notesModel = new \ppa\Model\NotesModel();
|
|
|
|
$note = null;
|
|
|
|
function isLoggedIn() {
|
|
return isset($_SESSION['user_id']);
|
|
}
|
|
|
|
function isAdmin() {
|
|
return isLoggedIn() && isset($_SESSION['role']) && $_SESSION['role'] === 'admin';
|
|
}
|
|
|
|
function sanitize($data, $flags = ENT_QUOTES, $encoding = 'UTF-8') {
|
|
return htmlspecialchars((string)$data, $flags, $encoding);
|
|
}
|
|
?>
|
|
|
|
<div class="container">
|
|
|
|
<div class="page-header">
|
|
<h2>Create New Note</h2>
|
|
<a href="?controller=Notes&page=showNotes&do=showNotes" class="button secondary">Cancel</a>
|
|
</div>
|
|
|
|
<label class="error-message"><?php if (isset($errmsg)):?>
|
|
<?php echo $errmsg;?>
|
|
<?php endif; ?></label>
|
|
|
|
<div id="drop-zone">Drag & drop a .txt or .md file here, or fill manually.</div>
|
|
|
|
<form id="note-form" method="POST" enctype="multipart/form-data">
|
|
<input type="hidden" name="action" value="create_note">
|
|
<div class="form-group">
|
|
<label for="title">Title:</label>
|
|
<input type="text" id="title" name="title" value="" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="content">Content (Markdown supported):</label>
|
|
<textarea id="content" name="content" rows="10" required></textarea>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Live Markdown Preview:</label>
|
|
<div id="markdown-preview" class="markdown-preview">
|
|
Start typing or drop a file to see preview...
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="attachments">Attach Files:</label>
|
|
<input type="file" id="attachments" name="attachments[]" multiple>
|
|
</div>
|
|
|
|
|
|
<div class="form-actions">
|
|
<button type="submit" class="button">Create Note</button>
|
|
</div>
|
|
<input type="hidden" name="controller" value="Notes">
|
|
<input type="hidden" name="do" value="createNote">
|
|
</form>
|
|
|
|
</div>
|