X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/084f4a795fb5874eecd7b17b3999f716432ad41c..d96a8550867531e92b109a0a675cd12ce1ff7843:/widget/reply.php diff --git a/widget/reply.php b/widget/reply.php index 4d504bb..6fe9eb1 100644 --- a/widget/reply.php +++ b/widget/reply.php @@ -1,56 +1,136 @@ Reacties'."\n"; +require_once 'upload.inc.php'; if ($_POST) { try { - $html = nl2br(htmlspecialchars($_POST['reply'])); - $html = "
$html
"; - $query = $Db->set('comments', [ - 'page' => $Page, - 'message' => $html, - 'author' => $User->login, - ]); - if (!$query->rowCount()) { - throw new Exception('Fout bij opslaan'); - } - if (@list ($cat, $issue) = explode('/', $Page) and ctype_digit($issue)) { - $row = ['updated' => ['now()']]; - $Db->set('issues', $row, ['page = ? AND id = ?', $cat, $issue]); - } + $newcomment = createcomment($_POST, $Issue); + $target = "/{$Page->link}/$newcomment#$newcomment"; + abort($target, ($Page->api ? 200 : 303) . ' reply success'); $_POST['reply'] = NULL; } catch (Exception $e) { + if ($Page->api) { + abort(ucfirst($e->getMessage()), '500 reply error'); + } print "Antwoord niet opgeslagen: {$e->getMessage()}.
\n\n"; } } -$query = $Db->query('SELECT * FROM comments WHERE page = ? ORDER BY created', [$Page]); +$cols = '*, (SELECT json_agg(journal.*) FROM journal WHERE comment_id = comments.id) 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 '%s\n", $row->message); + if ($html = $row->message) { + $html = preg_replace('/(?<= 2 ? 'loading="lazy" ' : '', $html, -1, $found); + $imagecount += $found; + printf("
\n%s\n", $html); + } + if ($changes = json_decode($row->journal)) { + print '
%2$s' : + (!isset($change->value) ? 'verwijderd (
%snaar
%s'), + $change->old_value, $change->value + ) + ); + } + print "