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