diff --git a/engine/mysql.php b/engine/mysql.php index 2c97e38..66c1400 100644 --- a/engine/mysql.php +++ b/engine/mysql.php @@ -2,6 +2,9 @@ class mysql { + const DATE_FORMAT = 'Y-m-d'; + const DATETIME_FORMAT = 'Y-m-d H:i:s'; + protected ?mysqli $link = null; function __construct( diff --git a/lib/posts.php b/lib/posts.php index 5c8aecf..d7a8b44 100644 --- a/lib/posts.php +++ b/lib/posts.php @@ -15,12 +15,18 @@ class Post extends model { public int $id; public string $date; + public ?string $updateTime; public bool $visible; public string $shortName; public string $sourceUrl; protected array $texts = []; + public function edit(array $fields) { + $fields['update_time'] = date(mysql::DATETIME_FORMAT, time()); + parent::edit($fields); + } + public function addText(PostLanguage $lang, string $title, string $md, bool $toc): ?PostText { $html = markup::markdownToHtml($md, lang: $lang); $text = markup::htmlToText($html);