formatting

This commit is contained in:
Zdenek Borovec 2024-07-18 23:53:59 +02:00
parent 83a4d00ca5
commit b04d38c9e9

View file

@ -26,20 +26,25 @@ class BlogpostComment
<label for=\"reveal-response-%s\" class=\"checkbox-button\">
Respond
</label>
<input type=\"checkbox\" id=\"reveal-response-%s\" style=\"display: none;\">
<input type=\"checkbox\" id=\"reveal-response-%s\"
style=\"display: none;\">
<hr>
<div class=\"comment-content\">
%s
</div>
<div class=\"comment-response\">
<form method=\"post\" action=\"%s\">
<input type=\"hidden\" name=\"blogpost_id\" value=\"%s\">
<input type=\"hidden\" name=\"comment_id\" value=\"%s\">
<input type=\"hidden\" name=\"blogpost_id\"
value=\"%s\">
<input type=\"hidden\" name=\"comment_id\"
value=\"%s\">
<label for=\"comment_entry\">Write response:</label>
<div class=\"centered-container\">
<textarea name=\"comment_entry\" class=\"comment-box\"> </textarea>
<textarea name=\"comment_entry\"
class=\"comment-box\"> </textarea>
</div>
<input name=\"submit\" type=\"submit\" value=\"Send\">
<input name=\"submit\" type=\"submit\"
value=\"Send\">
</form>
</div>
</div>
@ -172,21 +177,25 @@ class Blogpost
return;
}
if (isset($_COOKIE["PHPSESSID"]) && (bool)($_SESSION["current_user"]->permissions & 128)) {
if (isset($_COOKIE["PHPSESSID"]) &&
(bool)($_SESSION["current_user"]->permissions & 128)) {
$topRight = sprintf("<td class=\"blog-publish-date\">
<a href=\"http://www.zdenekborovec-dev.cz/blog/writearticle/
?guid=%s\">Edit</a></td>", $this->blogpost_id);
}
else {
$topRight = sprintf("<td class=\"blog-publish-date\">Published on: %s</td>",
$topRight = sprintf("<td class=\"blog-publish-date\">
Published on: %s</td>",
date("Y-m-d", strtotime($this->date_posted)));
}
// Display the blog title and metadata
printf("<article>");
print_r("<table class=\"noborder-table\" style=\"width: 100%; margin-top: 16px;\">");
printf("<tr><td style=\"padding: 0px;\"><h2 style=\"margin-top: 0px;\">%s</h2></td>%s</tr>
<tr><td class=\"blog-tags\">", $this->title, $topRight);
print_r("<table class=\"noborder-table\" style=\"width: 100%;
margin-top: 16px;\">");
printf("<tr><td style=\"padding: 0px;\"><h2 style=\"margin-top: 0px;\">
%s</h2></td>%s</tr><tr><td class=\"blog-tags\">",
$this->title, $topRight);
// Display tags
for($i = 0; $i < count($this->tags); $i++) {
@ -198,8 +207,8 @@ class Blogpost
}
// Display publish date and end metadata div
printf("</td><td class=\"blog-publish-date\">Last edited on: %s</td></tr></table>",
date("Y-m-d", strtotime($this->date_edited)));
printf("</td><td class=\"blog-publish-date\">Last edited on: %s</td>
</tr></table>", date("Y-m-d", strtotime($this->date_edited)));
// Display hrule, article content and end the article
printf("</article><hr><article>%s</article>", $this->content);
@ -396,15 +405,16 @@ if(isset($_POST["submit"])) {
$blogId = sanitize_input($_POST["blogpost_id"]);
$commentContent = sanitize_input($_POST["comment_entry"]);
$parentId = isset($_POST["comment_id"]) ? $_POST["comment_id"] : "NULL";
$posterId = isset($_SESSION["current_user"]) ? $_SESSION["current_user"]->user_id : "NULL";
$posterId = isset($_SESSION["current_user"]) ?
$_SESSION["current_user"]->user_id : "NULL";
// Try to send the comment
$commentId = send_comment($conn, $blogId, $posterId,
$commentContent, $parentId);
// Redirect to this page with GET
header("Location: http://www.zdenekborovec-dev.cz/blog/article?blogpost_id=".
$blogId."#comment-".$commentId);
header("Location: http://www.zdenekborovec-dev.cz/blog/".
"article?blogpost_id=".$blogId."#comment-".$commentId);
die();
}
@ -459,7 +469,8 @@ printf("
<input type=\"hidden\" name=\"blogpost_id\" value=\"%s\">
<label for=\"comment_entry\">Write a comment (%s):</label>
<div class=\"centered-container\">
<textarea name=\"comment_entry\" class=\"comment-box\" tabindex=\"1\"> </textarea>
<textarea name=\"comment_entry\" class=\"comment-box\"
tabindex=\"1\"> </textarea>
</div>
<input name=\"submit\" type=\"submit\" tabindex=\"2\" value=\"Send\">
</form>