X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/55cb3025c5506ec7faaa1818a4d8161aaad19c27..7983570288ed2798470a552ec04f64aa646b664a:/issue/index.php diff --git a/issue/index.php b/issue/index.php index d8f9c26..181d5b7 100644 --- a/issue/index.php +++ b/issue/index.php @@ -1,36 +1,52 @@ 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'); - - $Article->title .= ': '.htmlspecialchars($row->subject); - print "

{$Article->title}

\n"; - print $row->body; - if ($row->closed) { - printf('

%s %s

'."\n", - 'Opgelost', showdate(preg_split('/\D/', $row->closed)) - ); + if (!$Issue) throw new Exception('Issuenummer niet gevonden'); + + $replies = $Page->widget('reply'); # handle updates + + $Page->title .= ': '.htmlspecialchars($Issue->subject); + $Page->teaser = $Issue->body; + $Page->body = $replies; # find image + + print "

{$Page->title}

\n"; + print '\n\n"; + + print '
'; + print $Issue->body; + print $replies; + print "
\n"; return; } if ($_POST) { - $html = nl2br(htmlspecialchars($_POST['body'])); - $html = empty($html) ? NULL : "

$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()) { @@ -39,18 +55,46 @@ if ($_POST) { $_POST = []; } -$query = $Db->query('SELECT * FROM issues ORDER BY created DESC'); +$subsql = "SELECT count(*) FROM comments WHERE page=i.page||'/'||i.id"; +$cols = "*, ($subsql AND message IS NOT NULL) AS replycount"; +$cols .= ", ($subsql AND message ~ 'query($sql, [$Page->handler]); + +if ($id == 'feed') { + require 'issue/feed.inc.php'; +} ob_start(); print '\n"; $Place['issuelist'] = ob_get_clean();