added note detail view

This commit is contained in:
Felix Ivo
2025-06-16 15:11:33 +02:00
parent a4d6aeea18
commit b06536baf6
4 changed files with 70 additions and 1 deletions

View File

@@ -0,0 +1,43 @@
<?php include dirname(__DIR__).'/header.phtml'; ?>
<?php
$parsedown = new Parsedown();
$parsedown->setSafeMode(true);
?>
<div class="container">
<?php if (isset($note) && $note): ?>
<div class="note-details">
<div class="note-header">
<h2><?php echo htmlspecialchars($note['title'] ?? ''); ?></h2>
<div class="note-meta">
<?php if (($isAdmin ?? false) && isset($note['owner_username'])): ?>
<span class="note-owner">Owner: <?php echo htmlspecialchars($note['owner_username']); ?></span>
<?php endif; ?>
<span class="note-date">
Last updated: <?php echo isset($note['updated_at']) ? date("d.m.Y H:i", strtotime($note['updated_at'])) : 'N/A'; ?>
</span>
</div>
</div>
<div class="note-content">
<?php echo $parsedown->text($note['content'] ?? ''); ?>
</div>
<div class="note-actions">
<a href="?controller=NotesController&page=showNotes" class="button">Back to Notes</a>
<?php if (isset($note['id'])): ?>
<a href="?controller=NotesController&page=editNote&note_id=<?php echo (int)$note['id']; ?>" class="button">Edit Note</a>
<?php endif; ?>
</div>
</div>
<?php else: ?>
<div class="error-message">
<h2>Note Not Found</h2>
<p><?php echo htmlspecialchars($error ?? 'The requested note could not be found.'); ?></p>
<a href="?controller=NotesController&page=showNotes" class="button">Back to Notes</a>
</div>
<?php endif; ?>
</div>
<?php include dirname(__DIR__).'/footer.phtml'; ?>

View File

@@ -38,7 +38,7 @@
<?php foreach ($notes as $note): ?>
<tr>
<td><?php echo sanitize($note['id']); ?></td>
<td><a href="index.php?page=view_note&id=<?php echo $note['id']; ?>"><?php echo sanitize($note['title']); ?></a></td>
<td><a href="?controller=Notes&do=showNoteDetails&id=<?php echo $note['id']; ?>"><?php echo sanitize($note['title']); ?></a></td>
<?php if (isAdmin()): ?>
<td><?php echo sanitize($note['owner_username']); ?></td>
<?php endif; ?>