X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/3e188c002a26457a93ec3844bc6c7db3b0b23b10..da2d6e5537e9fdcd6f424ea1cc8ab6ef8f45727e:/issue/index.php diff --git a/issue/index.php b/issue/index.php index abd9611..87b22a3 100644 --- a/issue/index.php +++ b/issue/index.php @@ -1,42 +1,53 @@ path, '/')); -if ($id) { - $Article->title = "Issue #$id"; - - $row = $Db->query( - 'SELECT * FROM issues WHERE id = ?', [$id] +if ($id and ctype_digit($id)) { + $Page->title = "Issue #$id"; + $Page->path = "/$id"; # minimal reference + $Issue = $Db->query( + 'SELECT * FROM issues WHERE page = ? AND id = ?', [$Page->handler, $id] )->fetch(); - if (!$row) throw new Exception('Issuenummer niet gevonden'); + if (!$Issue) throw new Exception('Issuenummer niet gevonden'); - $Article->title .= ': '.htmlspecialchars($row->subject); - print "
%s%s %s
'."\n", - 'Geplaatst', - $row->author ? " door {$row->author}" : '', - showdate(preg_split('/\D/', $row->created)) - ); - if ($row->closed) { - printf('%s%s %s
'."\n", - 'Opgelost', '', - showdate(preg_split('/\D/', $row->closed)) - ); + $replies = $Page->widget('reply'); # handle updates + + $Page->title .= ': '.htmlspecialchars($Issue->subject); + $Page->teaser = $Issue->body; + if ($Page->api) return; + $Page->body = $replies; # find image + + print "$html
"; - $query = $Db->insert('issues', [ - 'page' => $Page, + require_once 'upload.inc.php'; + $query = $Db->set('issues', [ + 'page' => $Page->handler, 'subject' => $_POST['subject'], - 'body' => $html, + 'body' => messagehtml($_POST['body']), 'author' => $User->login, ]); if (!$query->rowCount()) { @@ -44,24 +55,48 @@ if ($_POST) { } $_POST = []; } +if ($Page->api) return; -$sql = 'SELECT * FROM issues'; +$subsql = "SELECT count(*) FROM comments WHERE page=i.page||'/'||i.id"; +$cols = "*, ($subsql AND message IS NOT NULL) AS replycount"; +$cols .= ", ($subsql AND message ~ '