diff options
author | Jonas Kohl | 2024-10-17 10:56:01 +0200 |
---|---|---|
committer | Jonas Kohl | 2024-10-17 10:56:01 +0200 |
commit | fe0f414dc0211a4014581dc03fcfd514ed7ed02d (patch) | |
tree | cd86fc00cd9b7a97eabb9668e0a39e2b4b3e5357 /src/application/views/view_topic_start.php | |
parent | e0e89b9fdbf301e0ead944636023947a67aca57d (diff) |
Transition templating to Twig
Diffstat (limited to 'src/application/views/view_topic_start.php')
-rw-r--r-- | src/application/views/view_topic_start.php | 254 |
1 files changed, 0 insertions, 254 deletions
diff --git a/src/application/views/view_topic_start.php b/src/application/views/view_topic_start.php deleted file mode 100644 index 7f62986..0000000 --- a/src/application/views/view_topic_start.php +++ /dev/null @@ -1,254 +0,0 @@ -<?php -use mystic\forum\orm\UserPermissions; -use mystic\forum\utils\RequestUtils; - -$canReply = !$topic->isLocked && ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::CREATE_OWN_POST) ?? false); - -$canEdit = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor->hasPermission(UserPermissions::EDIT_OWN_TOPIC)) - || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::EDIT_OTHER_TOPIC)); - -$canDelete = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor->hasPermission(UserPermissions::DELETE_OWN_TOPIC)) - || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::DELETE_OTHER_TOPIC)); -?> -<?php if ($canEdit): ?> - <div class="modal fade" tabindex="-1" role="dialog" id="diag-edit-post"> - <form class="modal-dialog" role="document" action="?_action=updatepost" method="post"> - <input type="hidden" id="i_edit_post" name="post"> - <div class="modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> - <h4 class="modal-title"><?= __("Edit post") ?></h4> - </div> - <div class="modal-body"> - <label class="sr-only" for="i_edit_message"><?= __("Message:") ?></label> - <div class="panel panel-default"> - <div class="panel-heading" style="padding:4px"> - <div class="btn-toolbar" role="toolbar"> - <div class="btn-group" role="group"> - <button data-area="#i_edit_message" title="<?= __("Bold") ?>" data-editor-command="bold" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-bold"></i></button> - <button data-area="#i_edit_message" title="<?= __("Italic") ?>" data-editor-command="italic" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-italic"></i></button> - <button data-area="#i_edit_message" title="<?= __("Underlined") ?>" data-editor-command="underline" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-underline"></i></button> - <button data-area="#i_edit_message" title="<?= __("Strikethrough") ?>" data-editor-command="strikethrough" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-strikethrough"></i></button> - </div> - <div class="btn-group" role="group"> - <button data-area="#i_edit_message" title="<?= __("Superscript") ?>" data-editor-command="sup" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-superscript"></i></button> - <button data-area="#i_edit_message" title="<?= __("Subscript") ?>" data-editor-command="sub" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-subscript"></i></button> - </div> - <div class="btn-group" role="group"> - <button data-area="#i_edit_message" title="<?= __("Quote") ?>" data-editor-command="quote" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-quote-left"></i></button> - <button data-area="#i_edit_message" title="<?= __("Spoiler") ?>" data-editor-command="spoiler" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-eye"></i></button> - </div> - </div> - </div> - <div class="panel-body" style="padding:0"> - <textarea class="form-control" id="i_edit_message" name="message" required rows="12" cols="60" style="resize:vertical;max-height:500px;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;margin:-1px;width:calc(100% + 2px)"></textarea> - </div> - </div> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-remove" aria-hidden="true"></span> <?= __("Cancel") ?></button> - <button type="submit" class="btn btn-success"><span class="fa fa-save" aria-hidden="true"></span> <?= __("Save changes") ?></button> - </div> - </div> - </form> - </div> -<?php endif; ?> -<?php if ($GLOBALS["currentUser"] === null): ?> - <div class="modal fade" tabindex="-1" role="dialog" id="diag-cant-view-attachment"> - <div class="modal-dialog modal-danger" role="document"> - <div class="modal-content panel-danger"> - <div class="modal-header panel-heading"> - <h4 class="modal-title"><span class="fa fa-exclamation-circle" aria-hidden="true"></span> <?= __("Permission denied") ?></h4> - </div> - <div class="modal-body"> - <?= __("You must be logged in to view attachments") ?> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-close" aria-hidden="true"></span> <?= __("Close") ?></button> - <a href="?_action=auth&next=<?= htmlentities(urlencode($_SERVER["REQUEST_URI"])) ?>" class="btn btn-success"><span class="fa fa-user" aria-hidden="true"></span> <?= __("Log in") ?></a> - </div> - </div> - </div> - </div> - <script> - $(function() { - $(".attachment").click(function(e) { - e.preventDefault(); - $("#diag-cant-view-attachment").modal(); - }); - }); - </script> -<?php else: ?> - <div class="modal fade" tabindex="-1" role="dialog" id="diag-image-attachment"> - <div class="modal-dialog" role="document"> - <div class="modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> - <h4 class="modal-title"><?= __("Attachment") ?></h4> - </div> - <div class="modal-body"> - <img class="image-attachment-view attachment-view" id="image-attachment-view" alt=""> - </div> - <div class="modal-footer"> - <a href="" download id="image-attachment-dl-btn" class="btn btn-default"><span class="fa fa-download" aria-hidden="true"></span> <?= __("Download") ?></a> - </div> - </div> - </div> - </div> - <div class="modal fade" tabindex="-1" role="dialog" id="diag-video-attachment"> - <div class="modal-dialog" role="document"> - <div class="modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> - <h4 class="modal-title"><?= __("Attachment") ?></h4> - </div> - <div class="modal-body"> - <video class="video-attachment-view attachment-view" id="video-attachment-view" controls></video> - </div> - <div class="modal-footer"> - <a href="" download id="video-attachment-dl-btn" class="btn btn-default"><span class="fa fa-download" aria-hidden="true"></span> <?= __("Download") ?></a> - </div> - </div> - </div> - </div> - <script> - $(function() { - $(".image-attachment:not(.video-attachment)").click(function(e) { - e.preventDefault(); - var attUrl = "?_action=attachment&attachment=" + encodeURIComponent($(this).attr("data-attachment-id")); - $("#image-attachment-view").attr("src", attUrl); - $("#image-attachment-dl-btn").attr("href", attUrl); - $("#diag-image-attachment").modal(); - }); - $(".image-attachment.video-attachment").click(function(e) { - e.preventDefault(); - var attUrl = "?_action=attachment&attachment=" + encodeURIComponent($(this).attr("data-attachment-id")); - $("#video-attachment-view").attr("src", attUrl); - $("#video-attachment-dl-btn").attr("href", attUrl); - $("#diag-video-attachment").modal(); - }); - $("#diag-video-attachment").on("hide.bs.modal", function() { - $("#video-attachment-view")[0].pause(); - }); - }); - </script> -<?php endif; ?> - -<?php -if (($_formError = RequestUtils::getAndClearFormError("updatetopic")) !== null) { - _view("alert_error", ["message" => $_formError]); -} - -if (($_formError = RequestUtils::getAndClearFormError("locktopic")) !== null) { - _view("alert_error", ["message" => $_formError]); -} -?> - -<div class="page-header margin-top-0 clearfix"> - <div id="displayHeading"> - <div role="heading" class="h1 seamless-inline"> - <?php if ($topic->isLocked): ?> - <span class="fa fa-lock text-muted" aria-hidden="true"></span> - <?php endif; ?> - <?= htmlentities($topic->title) ?> - <div class="pull-right text-normal"> - <?php if ($canEdit && !$topic->isLocked): ?> - <button id="btn-edit-title" class="btn btn-default js-only"><span class="fa fa-pencil" aria-hidden="true"></span> <?= __("Edit title") ?></button> - <?php endif; ?> - <?php if ($canReply): ?> - <button id="btn-reply" class="btn btn-default js-only"><span class="fa fa-comment" aria-hidden="true"></span> <?= __("Reply") ?></button> - <?php endif; ?> - <?php if ($canEdit): ?> - <?php if ($topic->isLocked): ?> - <form action="?_action=locktopic" method="post" class="seamless-inline"> - <input type="hidden" name="topic" value="<?= htmlentities($topic->id) ?>"> - <input type="hidden" name="locked" value="false"> - <button type="submit" class="btn btn-success"><span class="fa fa-unlock" aria-hidden="true"></span> <?= __("Unlock topic") ?></button> - </form> - <?php else: ?> - <form action="?_action=locktopic" method="post" class="seamless-inline"> - <input type="hidden" name="topic" value="<?= htmlentities($topic->id) ?>"> - <input type="hidden" name="locked" value="true"> - <button type="submit" class="btn btn-warning"><span class="fa fa-lock" aria-hidden="true"></span> <?= __("Lock topic") ?></button> - </form> - <?php endif; ?> - <?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="fa fa-trash" aria-hidden="true"></span> <?= __("Delete topic") ?></button> - </form> - <?php endif; ?> - </div> - </div><br> - <?= __("Started by %user% on %date%", [ - "user" => ($topicAuthor !== null) ? ('<a href="?_action=viewuser&user=' . htmlentities(urlencode($topicAuthor->id)) . '">' . htmlentities($topicAuthor->displayName) . '</a>') : __("(deleted)"), - "date" => '<span class="_time">' . htmlentities($topic->creationDate->format("c")) . '</span>', - ]); ?> - </div> - <?php if ($canEdit): ?> - <form action="?_action=updatetopic" method="post" id="editHeading" style="display: none;" class="form-inline seamless-inline"> - <input type="hidden" name="topic" value="<?= htmlentities(urlencode($topic->id)) ?>"> - <div class="row"> - <div class="col-md-8"> - <input type="text" class="form-control" name="title" id="i_edit_title" data-original-value="<?= htmlentities($topic->title) ?>" value="<?= htmlentities($topic->title) ?>" style="box-sizing: border-box; width: 100%; font-size: 36px; height: 56px"> - </div> - <div class="col-md-4 text-right"> - <button type="button" id="topicTitleEditCancel" class="btn btn-default"><span class="fa fa-close" aria-hidden="true"></span> <?= __("Cancel") ?></button> - <button type="submit" class="btn btn-success"><span class="fa fa-save" aria-hidden="true"></span> <?= __("Save changes") ?></button> - </div> - </div> - </form> - <?php endif; ?> -</div> -<script> -<?php if ($canEdit): ?> -$(function() { - $("#btn-edit-title").click(function() { - $("#displayHeading").hide(); - $("#editHeading").show(); - $("#i_edit_title").val($("#i_edit_title").attr("data-original-value")).focus(); - }); - $("#topicTitleEditCancel").click(function() { - $("#displayHeading").show(); - $("#editHeading").hide(); - }); -}); -<?php endif; ?> -<?php if ($canReply): ?> -$(function() { - function focusReplyBox() { - var msgInput = $("#i_message"); - msgInput[0].scrollIntoView(); - msgInput.focus(); - } - $("#btn-reply").click(function() { - focusReplyBox(); - }); - $("._reply-post").click(function() { - var text = $("#post-" + $(this).attr("data-post-id")).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(); - }); -}); -<?php endif; ?> -<?php if ($canEdit): ?> -$(function() { - $("._edit-post").click(function() { - var $post = $("#post-" + $(this).attr("data-post-id")); - var $postContent = $post.find(".post-content"); - $("#i_edit_message").css("height", "").val($post.attr("data-text")); - $("#i_edit_post").val($(this).attr("data-post-id")); - $("#diag-edit-post").modal(); - }); - $("#diag-edit-post").on("shown.bs.modal", function() { - $("#i_edit_message").focus(); - }); -}); -<?php endif; ?> -</script> |