posts: save post update time

This commit is contained in:
E. S. 2024-04-21 01:37:08 +00:00
parent bf8b8f22b6
commit 9ddc847aee
2 changed files with 9 additions and 0 deletions

View File

@ -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(

View File

@ -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);