From 8e1d3422ac745d49bcf56152f11d5b07ea45cb38 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Fri, 26 Nov 2021 00:41:25 +0100 Subject: [PATCH] issue: formatted main message, edit links in admin dates Allow first comment to be edited. --- widget/reply.php | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/widget/reply.php b/widget/reply.php index 4f6a2c8..0c5d5a3 100644 --- a/widget/reply.php +++ b/widget/reply.php @@ -23,32 +23,38 @@ if ($_POST) { $cols = "*, (SELECT json_agg(journal.*) FROM journal WHERE comment_id = comments.id AND property = 'attr') AS journal"; $query = $Db->query("SELECT $cols FROM comments WHERE page = ? ORDER BY created", [$Page->link]); -if ($row = $query->fetch()) { - print $row->message; - $Page->teaser = $row->raw; -} - print '
'; $imagecount = 0; -while ($row = $query->fetch()) { +for ($i = 0; $row = $query->fetch(); $i++) { $rowuser = new User("profile/{$row->author}"); printf('
', $row->id); - printf('%s', $rowuser->html); + if ($i) { + # subsequent reply header + printf('%s', $rowuser->html); + } + else { + $Page->teaser = $row->raw; + } $rowdate = showdate(preg_split('/\D/', $row->created)); - if ($User->admin('beheer') and $row->updated) { - $rowdate = "$rowdate " . showdate(preg_split('/\D/', $row->updated)); + if ($User->admin('beheer')) { + if ($row->updated) { + $rowdate = "$rowdate " . showdate(preg_split('/\D/', $row->updated)); + } + if ($User->admin('user') || $User->login === $row->author) { + $rowdate .= sprintf(' %s', + "/{$Page->link}/{$row->id}", 'reactie aanpassen', "\u{270D}"); + } } printf(' %s', $rowdate); - if ($User->admin('beheer') and $User->admin('user') || $User->login === $row->author) { - printf(' %s', - "/{$Page->link}/{$row->id}", 'reactie aanpassen', "\u{270D}"); - } if ($html = $row->message) { $html = preg_replace('/(?<= 2 ? 'loading="lazy" ' : '', $html, -1, $found); $imagecount += $found; - printf("
\n%s
\n", $html); + if ($i) { + $html = "
\n$html
\n"; + } + print $html; } if ($changes = json_decode($row->journal)) { print '
    '; -- 2.30.0