diff options
Diffstat (limited to 'model')
-rw-r--r-- | model/Post.php | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/model/Post.php b/model/Post.php index b0360ac..6f3f1ab 100644 --- a/model/Post.php +++ b/model/Post.php @@ -8,10 +8,12 @@ class Post extends Model { public string $title; public string $md; public string $html; + public string $tocHtml; public string $text; public int $ts; public int $updateTs; public bool $visible; + public bool $toc; public string $shortName; public function edit(array $data) { @@ -26,6 +28,10 @@ class Post extends Model { $data['text'] = markup::htmlToText($data['html']); } + if ((isset($data['toc']) && $data['toc']) || $this->toc) { + $data['toc_html'] = markup::toc($data['md']); + } + parent::edit($data); $this->updateImagePreviews(); } @@ -87,6 +93,10 @@ class Post extends Model { return $html; } + public function getToc(): ?string { + return $this->toc ? $this->tocHtml : null; + } + public function isUpdated(): bool { return $this->updateTs && $this->updateTs != $this->ts; } |