diff options
Diffstat (limited to 'src/application/views/view_topic_start.php')
-rw-r--r-- | src/application/views/view_topic_start.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/application/views/view_topic_start.php b/src/application/views/view_topic_start.php new file mode 100644 index 0000000..5818483 --- /dev/null +++ b/src/application/views/view_topic_start.php @@ -0,0 +1,55 @@ +<?php +use mystic\forum\orm\UserPermissions; + +$canReply = $GLOBALS["currentUser"]?->hasPermission(UserPermissions::CREATE_OWN_POST) ?? false; + +$canDelete = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor->hasPermission(UserPermissions::DELETE_OWN_TOPIC)) + || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::DELETE_OTHER_TOPIC)); +?> +<div role="heading" class="h1"> +<?= htmlentities($topic->title) ?> +<div class="pull-right"> +<?php if ($canReply): ?> +<button id="btn-reply" class="btn btn-default js-only"><span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span> Reply</button> +<?php endif; ?> +<?php if ($canDelete): ?> +<form action="?_action=deletetopic" method="post" class="seamless-inline"> +<input type="hidden" name="topic" value="<?= htmlentities($topic->id) ?>"> +<button type="submit" class="btn btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete topic</button> +</form> +<?php endif; ?> +</div> +</div> +<p> +Started by +<?php if ($topicAuthor !== null): ?> +<a href="?_action=viewuser&user=<?= htmlentities(urlencode($topicAuthor->id)) ?>"><?= htmlentities($topicAuthor->displayName) ?></a> +<?php else: ?> +<em>(deleted)</em> +<?php endif; ?> +on <span class="_time"><?= htmlentities($topic->creationDate->format("c")) ?></span> +</p> +<?php if ($canReply): ?> +<script> +$(function() { + function focusReplyBox() { + var msgInput = $("#i_message"); + msgInput[0].scrollIntoView(); + msgInput.focus(); + } + $("#btn-reply").click(function() { + focusReplyBox(); + }); + $("._reply-post").click(function() { + var text = $(this).attr("data-text"); + var val = $("#i_message").val(); + var lines = text.split("\n"); + for (var i = 0; i < lines.length; ++i) + val += "\n> " + lines[i]; + val += "\n\n"; + $("#i_message").val(val.replace(/^\n+/, "")); + focusReplyBox(); + }); +}); +</script> +<?php endif; ?> |