removed isEditMode
This commit is contained in:
parent
b92f7c1054
commit
871ffe01d0
@ -7,16 +7,7 @@ $parsedown->setSafeMode(true);
|
|||||||
|
|
||||||
$this->notesModel = new \ppa\Model\NotesModel();
|
$this->notesModel = new \ppa\Model\NotesModel();
|
||||||
|
|
||||||
$isEditMode = false;
|
|
||||||
$note = null;
|
$note = null;
|
||||||
if ($isEditMode) {
|
|
||||||
$noteId = $_GET['id'] ?? 0;
|
|
||||||
$note = $this->notesModel->getNoteById($noteId, $_SESSION['user_id']);
|
|
||||||
if (!$note) {
|
|
||||||
echo "<div class='alert alert-danger'>Note not found or you don't have permission to edit it.</div>";
|
|
||||||
echo "<a href='?controller=Notes&page=showNotes&do=showNotes' class='button secondary'>Back to Dashboard</a>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function isLoggedIn() {
|
function isLoggedIn() {
|
||||||
return isset($_SESSION['user_id']);
|
return isset($_SESSION['user_id']);
|
||||||
@ -34,33 +25,30 @@ function sanitize($data, $flags = ENT_QUOTES, $encoding = 'UTF-8') {
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2><?php echo $isEditMode ? 'Edit Note' . (isAdmin() && $note && $note['user_id'] != $_SESSION['user_id'] ? ' (Admin Edit - Owner: '.sanitize($note['owner_username']).')' : '') : 'Create New Note'; ?></h2>
|
<h2>Create New Note</h2>
|
||||||
<a href="?controller=Notes&page=showNotes&do=showNotes" class="button secondary">Cancel</a>
|
<a href="?controller=Notes&page=showNotes&do=showNotes" class="button secondary">Cancel</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="drop-zone">Drag & drop a .txt or .md file here, or fill manually.</div>
|
<div id="drop-zone">Drag & drop a .txt or .md file here, or fill manually.</div>
|
||||||
|
|
||||||
<form id="note-form" method="POST">
|
<form id="note-form" method="POST">
|
||||||
<input type="hidden" name="action" value="<?php echo $isEditMode ? 'update_note' : 'create_note'; ?>">
|
<input type="hidden" name="action" value="create_note">
|
||||||
<?php if ($isEditMode && $note): ?>
|
|
||||||
<input type="hidden" name="note_id" value="<?php echo sanitize($note['id']); ?>">
|
|
||||||
<?php endif; ?>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="title">Title:</label>
|
<label for="title">Title:</label>
|
||||||
<input type="text" id="title" name="title" value="<?php echo $isEditMode && $note ? sanitize($note['title']) : ''; ?>" required>
|
<input type="text" id="title" name="title" value="" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="content">Content (Markdown supported):</label>
|
<label for="content">Content (Markdown supported):</label>
|
||||||
<textarea id="content" name="content" rows="10" required><?php echo $isEditMode && $note ? sanitize($note['content']) : ''; ?></textarea>
|
<textarea id="content" name="content" rows="10" required></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Live Markdown Preview:</label>
|
<label>Live Markdown Preview:</label>
|
||||||
<div id="markdown-preview" class="markdown-preview">
|
<div id="markdown-preview" class="markdown-preview">
|
||||||
<?php if($isEditMode && $note && !empty($note['content'])) echo $parsedown->text(sanitize($note['content'])); else echo "Start typing or drop a file to see preview..."; ?>
|
Start typing or drop a file to see preview...
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="button"><?php echo $isEditMode ? 'Update Note' : 'Create Note'; ?></button>
|
<button type="submit" class="button">Create Note</button>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="controller" value="Notes">
|
<input type="hidden" name="controller" value="Notes">
|
||||||
<input type="hidden" name="do" value="createNote">
|
<input type="hidden" name="do" value="createNote">
|
||||||
|
@ -7,15 +7,12 @@ $parsedown->setSafeMode(true);
|
|||||||
|
|
||||||
$this->notesModel = new \ppa\Model\NotesModel();
|
$this->notesModel = new \ppa\Model\NotesModel();
|
||||||
|
|
||||||
$isEditMode = true;
|
|
||||||
$note = null;
|
$note = null;
|
||||||
if ($isEditMode) {
|
$noteId = $_GET['id'] ?? 0;
|
||||||
$noteId = $_GET['id'] ?? 0;
|
$note = $this->notesModel->getNoteById($noteId, $_SESSION['user_id']);
|
||||||
$note = $this->notesModel->getNoteById($noteId, $_SESSION['user_id']);
|
if (!$note) {
|
||||||
if (!$note) {
|
echo "<div class='alert alert-danger'>Note not found or you don't have permission to edit it.</div>";
|
||||||
echo "<div class='alert alert-danger'>Note not found or you don't have permission to edit it.</div>";
|
echo "<a href='?controller=Notes&page=showNotes&do=showNotes' class='button secondary'>Back to Dashboard</a>";
|
||||||
echo "<a href='?controller=Notes&page=showNotes&do=showNotes' class='button secondary'>Back to Dashboard</a>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isLoggedIn() {
|
function isLoggedIn() {
|
||||||
@ -34,33 +31,31 @@ function sanitize($data, $flags = ENT_QUOTES, $encoding = 'UTF-8') {
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2><?php echo $isEditMode ? 'Edit Note' . (isAdmin() && $note && $note['user_id'] != $_SESSION['user_id'] ? ' (Admin Edit - Owner: '.sanitize($note['owner_username']).')' : '') : 'Create New Note'; ?></h2>
|
<h2><?php echo 'Edit Note' . (isAdmin() && $note && $note['user_id'] != $_SESSION['user_id'] ? ' (Admin Edit - Owner: '.sanitize($note['owner_username']).')' : '') ?></h2>
|
||||||
<a href="?controller=Notes&page=showNotes&do=showNotes" class="button secondary">Cancel</a>
|
<a href="?controller=Notes&page=showNotes&do=showNotes" class="button secondary">Cancel</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="drop-zone">Drag & drop a .txt or .md file here, or fill manually.</div>
|
<div id="drop-zone">Drag & drop a .txt or .md file here, or fill manually.</div>
|
||||||
|
|
||||||
<form id="note-form" method="POST">
|
<form id="note-form" method="POST">
|
||||||
<input type="hidden" name="action" value="<?php echo $isEditMode ? 'update_note' : 'create_note'; ?>">
|
<input type="hidden" name="action" value="update_note">
|
||||||
<?php if ($isEditMode && $note): ?>
|
<input type="hidden" name="note_id" value="<?php echo sanitize($note['id']); ?>">
|
||||||
<input type="hidden" name="note_id" value="<?php echo sanitize($note['id']); ?>">
|
|
||||||
<?php endif; ?>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="title">Title:</label>
|
<label for="title">Title:</label>
|
||||||
<input type="text" id="title" name="title" value="<?php echo $isEditMode && $note ? sanitize($note['title']) : ''; ?>" required>
|
<input type="text" id="title" name="title" value="<?php echo $note ? sanitize($note['title']) : ''; ?>" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="content">Content (Markdown supported):</label>
|
<label for="content">Content (Markdown supported):</label>
|
||||||
<textarea id="content" name="content" rows="10" required><?php echo $isEditMode && $note ? sanitize($note['content']) : ''; ?></textarea>
|
<textarea id="content" name="content" rows="10" required><?php echo $note ? sanitize($note['content']) : ''; ?></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Live Markdown Preview:</label>
|
<label>Live Markdown Preview:</label>
|
||||||
<div id="markdown-preview" class="markdown-preview">
|
<div id="markdown-preview" class="markdown-preview">
|
||||||
<?php if($isEditMode && $note && !empty($note['content'])) echo $parsedown->text(sanitize($note['content'])); else echo "Start typing or drop a file to see preview..."; ?>
|
<?php if($note && !empty($note['content'])) echo $parsedown->text(sanitize($note['content'])); else echo "Start typing or drop a file to see preview..."; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="button"><?php echo $isEditMode ? 'Update Note' : 'Create Note'; ?></button>
|
<button type="submit" class="button">Update Note</button>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="controller" value="Notes">
|
<input type="hidden" name="controller" value="Notes">
|
||||||
<input type="hidden" name="do" value="editNote">
|
<input type="hidden" name="do" value="editNote">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user