Skip to content

Commit 65c6c1a

Browse files
committed
Refactor comment section design
1 parent 4177fba commit 65c6c1a

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

src/templates/Comment/Section.inc.phtml

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ $active_user_id = ($active_user ? $active_user->getId() : null);
99
$c_edit_visible_admin = ($active_user && ($active_user->getOptionsBitmask() & User::OPTION_ACL_COMMENT_MODIFY));
1010
$c_delete_visible_admin = ($active_user && ($active_user->getOptionsBitmask() & User::OPTION_ACL_COMMENT_DELETE));
1111
?>
12-
<div class="row mt-3">
13-
<div class="col">
14-
<h2><a name="comments">Comments</a></h2>
12+
<div class="row mt-3 justify-content-center">
13+
<div class="col-md-9">
14+
<h2><a href="#comments" name="comments">Comments</a></h2>
1515
<? if (!$comments) { ?>
1616
<div class="border border-secondary m-auto rounded-pill p-2" style="max-width:400px;"><p class="text-center mb-0"><em>no one has commented yet.</em></p></div>
17-
<? } else { ?>
18-
<table class="table table-striped text-white-50"><tbody>
19-
<? foreach ($comments as $c) {
17+
<? } else {
18+
foreach ($comments as $c) {
2019
$c_created_dt = $c->getCreatedDateTime();
2120
$c_id = rawurlencode($c->getId());
2221
$c_parent_url = $c->getParentUrl();
@@ -27,33 +26,29 @@ $c_delete_visible_admin = ($active_user && ($active_user->getOptionsBitmask() &
2726
$c_user_name = ($c_user ? filter_var($c_user->getName(), FILTER_SANITIZE_FULL_SPECIAL_CHARS) : 'Anonymous');
2827

2928
$c_user_string = ($c_user ? sprintf('<a href="%s"><img class="rounded" src="%s"/> %s</a>', $c_user_url, $c_user_avatar, $c_user_name) : $c_user_name);
29+
$c_time_string = sprintf('<time class="small text-muted" datetime="%s">%s</time>', $c_created_dt->format('c'), $c_created_dt->format('D M j, Y g:ia T'));
3030

3131
$c_edit_visible = ($c_user_id == $active_user_id || $c_edit_visible_admin);
32-
$c_delete_visible = ($c_user_id == $active_user_id || $c_delete_visible_admin); ?>
33-
<tr><td>
34-
<?=$c_user_string?><br/>
35-
<time datetime="<?=$c_created_dt->format('c')?>"><?=$c_created_dt->format('D M j, Y g:ia T')?></time>
36-
</td><td>
37-
<? if ($c_delete_visible) { ?>
38-
<a class="btn btn-sm btn-danger float-right m-1" href="<?=Common::relativeUrlToAbsolute('/comment/delete?id=' . $c_id)?>" title="Delete">❌</a>
39-
<? } if ($c_edit_visible) { ?>
40-
<a class="btn btn-sm btn-secondary float-right m-1" href="<?=Common::relativeUrlToAbsolute('/comment/edit?id=' . $c_id)?>" title="Edit">📝</a>
41-
<? } ?>
42-
<?=$c->getContent(true)?>
43-
</td></tr>
44-
<? } ?>
45-
</tbody></table>
46-
<? } ?>
32+
$c_delete_visible = ($c_user_id == $active_user_id || $c_delete_visible_admin);
33+
34+
$c_content = (
35+
($c_delete_visible ? '<a class="btn btn-sm btn-danger float-right m-1" href="' . Common::relativeUrlToAbsolute('/comment/delete?id=' . $c_id) . '" title="Delete">❌</a>' : '') .
36+
($c_edit_visible ? '<a class="btn btn-sm btn-secondary float-right m-1" href="' . Common::relativeUrlToAbsolute('/comment/edit?id=' . $c_id) . '" title="Edit">📝</a>' : '') .
37+
$c->getContent(true)
38+
);
39+
40+
printf('<div class="row bg-primary border border-dark mt-2 py-3 rounded"><div class="col-3">%s<br/>%s</div><div class="col-9">%s</div></div>', $c_user_string, $c_time_string, $c_content);
41+
}} ?>
4742
</div>
4843
</div>
4944
<? if ($active_user) { ?>
5045
<div class="row my-3 justify-content-center">
51-
<div class="col-8">
46+
<div class="col-md-8">
5247
<form method="POST" action="<?=Common::relativeUrlToAbsolute('/comment/create')?>">
5348
<input type="hidden" name="parent_type" value="<?=$comment_parent_type?>"/>
5449
<input type="hidden" name="parent_id" value="<?=$comment_parent_id?>"/>
5550
<div class="form-group">
56-
<span class="float-right text-muted small">(Markdown supported)</span>
51+
<span class="float-right small">(Markdown supported)</span>
5752
<label for="comment-content" class="font-weight-bold">Make a Comment:</label>
5853
<textarea id="comment-content" class="border border-secondary form-control bg-dark text-light" name="content"></textarea>
5954
</div>

0 commit comments

Comments
 (0)