From 62b0b360fa8a1a2d1fd6d89d4d227a0ef559cb8a Mon Sep 17 00:00:00 2001 From: Laria Carolin Chabowski Date: Mon, 10 Feb 2020 22:36:13 +0100 Subject: Implement simple attachment support It is now possible to upload and view attachments! Attachments are saved by their content hash, therefore they are automatically deduplicated and we can later easily add integrity checks. Still missing: - Deleting attachments - Multiple file inputs (idea: when the user fills in a file input, create a new empty file input beneath with js) - (nice to have) Thumbnails --- src/TemplateModelWrappers/NoteForTemplate.php | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/TemplateModelWrappers/NoteForTemplate.php (limited to 'src/TemplateModelWrappers') diff --git a/src/TemplateModelWrappers/NoteForTemplate.php b/src/TemplateModelWrappers/NoteForTemplate.php new file mode 100644 index 0000000..baafe21 --- /dev/null +++ b/src/TemplateModelWrappers/NoteForTemplate.php @@ -0,0 +1,44 @@ +db = $db; + $this->note = $note; + } + + /** + * @param SQLite3 $db + * @param Note[] $notes + * @return self[] + */ + public static function wrapMany(SQLite3 $db, array $notes): array + { + return array_map(static fn(Note $note) => new self($db, $note), $notes); + } + + public function getId(): string { return $this->note->getId(); } + public function getContent(): string { return $this->note->getContent(); } + public function getTags(): array { return $this->note->getTags(); } + + public function getAttachments(): array + { + return $this->note->getAttachments($this->db); + } +} \ No newline at end of file -- cgit v1.2.3-70-g09d2