diff --git a/Model/NotesModel.php b/Model/NotesModel.php index d4c6d7c..82fb70e 100644 --- a/Model/NotesModel.php +++ b/Model/NotesModel.php @@ -94,6 +94,11 @@ class NotesModel extends Database $params = [trim($title), $content, $noteId, $userId]; } $stmt->execute($params); + + $uploadResult = $this->uploadFiles($noteId); + if (!$uploadResult['success']) { + return $uploadResult; + } if ($stmt->rowCount() > 0) { return ['success' => true, 'message' => 'Note updated successfully.']; @@ -148,6 +153,19 @@ class NotesModel extends Database } } + function getFileCount() { + $pdo = $this->linkDB(); + if (!$pdo) return 0; + try { + $stmt = $pdo->prepare("SELECT COUNT(*) FROM files"); + $stmt->execute(); + return $stmt->fetchColumn(); + } catch (PDOException $e) { + error_log("Get Files Count Error: " . $e->getMessage()); + return 0; + } + } + function getNoteCount() { $pdo = $this->linkDB(); if (!$pdo) return 0; diff --git a/Views/Notes/createNote.phtml b/Views/Notes/createNote.phtml index 9df15fb..cbd9d25 100644 --- a/Views/Notes/createNote.phtml +++ b/Views/Notes/createNote.phtml @@ -67,7 +67,6 @@ function sanitize($data, $flags = ENT_QUOTES, $encoding = 'UTF-8') { -
diff --git a/Views/Notes/editNote.phtml b/Views/Notes/editNote.phtml index df170ea..5e869e4 100644 --- a/Views/Notes/editNote.phtml +++ b/Views/Notes/editNote.phtml @@ -15,6 +15,8 @@ if (!$note) { echo "Back to Dashboard"; } +$files = $this->notesModel->getUploadedFiles($noteId); + function isLoggedIn() { return isset($_SESSION['user_id']); } @@ -37,7 +39,7 @@ function sanitize($data, $flags = ENT_QUOTES, $encoding = 'UTF-8') {
Drag & drop a .txt or .md file here, or fill manually.
-
+
@@ -54,6 +56,22 @@ function sanitize($data, $flags = ENT_QUOTES, $encoding = 'UTF-8') { text(sanitize($note['content'])); else echo "Start typing or drop a file to see preview..."; ?>
+
+ + +
+ 0): ?> +
+ + +
+
diff --git a/Views/Notes/showNoteDetails.phtml b/Views/Notes/showNoteDetails.phtml index 3c7aa7f..3365142 100644 --- a/Views/Notes/showNoteDetails.phtml +++ b/Views/Notes/showNoteDetails.phtml @@ -3,6 +3,9 @@ setSafeMode(true); + +$this->notesModel = new \ppa\Model\NotesModel(); +$files = $this->notesModel->getUploadedFiles($note['id']); ?>
@@ -24,6 +27,19 @@ $parsedown->setSafeMode(true); text($note['content'] ?? ''); ?>
+
+ 0): ?> +

Attached Files:

+ + +
+
Back to Notes diff --git a/Views/Welcome/showWelcome.phtml b/Views/Welcome/showWelcome.phtml index b1fb24b..ed32bb9 100644 --- a/Views/Welcome/showWelcome.phtml +++ b/Views/Welcome/showWelcome.phtml @@ -26,7 +26,14 @@ $this->userModel = new \ppa\Model\UserModel(); echo $this->userModel->getUserCount(); ?> Users - +
+ + + notesModel->getFileCount(); + ?> + Files +