X-Git-Url: https://git.cweiske.de/anoweco.git/blobdiff_plain/ccb7bb3c75555c01e7dbc78e0b971abc86f3a59d..43f8f35bc5bdeec439329b14a30707f925c491ed:/www/comment.php diff --git a/www/comment.php b/www/comment.php index 6dc1b0c..df39c3c 100644 --- a/www/comment.php +++ b/www/comment.php @@ -18,7 +18,7 @@ if (!is_numeric($_GET['id'])) { $id = intval($_GET['id']); $storage = new Storage(); -$comment = $storage->getComment($id); +$comment = $storage->getJsonComment($id); if ($comment === null) { header('HTTP/1.0 404 Not Found'); header('Content-Type: text/plain'); @@ -26,29 +26,41 @@ if ($comment === null) { exit(1); } -if (isset($comment->properties->content['html'])) { - $htmlContent = $comment->properties->content['html']; -} else { - $htmlContent = nl2br($comment->properties->content[0]); -} - $rowComment = $comment->Xrow; $rowUser = $comment->user; -render( - 'comment', - array( - 'json' => $comment->properties, - 'crow' => $rowComment, - 'comment' => $comment, - 'author' => array( - 'name' => $rowUser->user_name, - 'url' => Urls::full(Urls::user($rowUser->user_id)), - 'imageurl' => Urls::userImg($rowUser), - ), - 'htmlContent' => $htmlContent, - 'replyUrl' => Urls::full( - '/reply.php?url=' . urlencode(Urls::full($rowComment->comment_id)) - ), - ) + +$vars = array( + 'json' => $comment->properties, + 'crow' => $rowComment, + 'comment' => $comment, + 'author' => array( + 'name' => $rowUser->user_name, + 'url' => Urls::full(Urls::user($rowUser->user_id)), + 'imageurl' => Urls::userImg($rowUser), + ), + 'postUrl' => Urls::full(Urls::comment($rowComment->comment_id)), + 'replyUrl' => Urls::reply( + Urls::full(Urls::comment($rowComment->comment_id)) + ), ); + +if ($rowComment->comment_type == 'like') { + $template = 'post-like'; +} else { + //reply + $template = 'post-reply'; + if (isset($comment->properties->content['html'])) { + $htmlContent = $comment->properties->content['html']; + } else { + $htmlContent = nl2br($comment->properties->content[0]); + } + $vars['htmlContent'] = $htmlContent; +} + +if (isset($linkbackEndpoint) && $linkbackEndpoint) { + header('X-Pingback: ' . $linkbackEndpoint); + header('Link: <' . $linkbackEndpoint . '>; rel="webmention"'); +} + +render($template, $vars); ?>