EIANotesApp/Views/Notes/showNoteDetails.phtml
2025-07-07 10:54:32 +02:00

59 lines
2.5 KiB
PHTML

<?php include dirname(__DIR__).'/header.phtml'; ?>
<?php
$parsedown = new Parsedown();
$parsedown->setSafeMode(true);
$this->notesModel = new \ppa\Model\NotesModel();
$files = $this->notesModel->getUploadedFiles($note['id']);
?>
<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-files">
<?php if (isset($files) && count($files) > 0): ?>
<h3>Attached Files:</h3>
<ul>
<?php foreach ($files as $file): ?>
<li>
<a href="/EIANotesApp/Uploads/<?php echo $file['stored_filename']; ?>" download target="_blank"><?php echo htmlspecialchars($file['original_filename']); ?></a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
<div class="note-actions">
<a href="?controller=Notes&page=showNotes&do=showNotes" class="button">Back to Notes</a>
<?php if (isset($note['id'])): ?>
<a href="?controller=Notes&do=editNote&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=Notes&page=showNotes&do=showNotes" class="button">Back to Notes</a>
</div>
<?php endif; ?>
</div>
<?php include dirname(__DIR__).'/footer.phtml'; ?>