summaryrefslogtreecommitdiff
path: root/src/application/views/view_post.php
diff options
context:
space:
mode:
authorJonas Kohl2024-10-17 10:56:01 +0200
committerJonas Kohl2024-10-17 10:56:01 +0200
commitfe0f414dc0211a4014581dc03fcfd514ed7ed02d (patch)
treecd86fc00cd9b7a97eabb9668e0a39e2b4b3e5357 /src/application/views/view_post.php
parente0e89b9fdbf301e0ead944636023947a67aca57d (diff)
Transition templating to Twig
Diffstat (limited to 'src/application/views/view_post.php')
-rw-r--r--src/application/views/view_post.php150
1 files changed, 0 insertions, 150 deletions
diff --git a/src/application/views/view_post.php b/src/application/views/view_post.php
deleted file mode 100644
index e2fcc36..0000000
--- a/src/application/views/view_post.php
+++ /dev/null
@@ -1,150 +0,0 @@
-<?php
-
-use mystic\forum\orm\UserPermissions;
-use mystic\forum\orm\Attachment;
-
-/** @var mystic\forum\orm\Post $post */
-/** @var mystic\forum\orm\User $postAuthor */
-/** @var mystic\forum\orm\Topic $topic */
-
-$isImage = fn(string $m) => str_starts_with($m, "image/") || str_starts_with($m, "video/");
-
-$fileAttachments = array_filter($attachments, fn(Attachment $a) => !$isImage($a->mimeType));
-$imageAttachments = array_filter($attachments, fn(Attachment $a) => $isImage($a->mimeType));
-
-$canReply = !$topic->isLocked && ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::CREATE_OWN_POST) ?? false);
-
-$canEdit = ($GLOBALS["currentUser"]?->id === $postAuthor?->id && $postAuthor?->hasPermission(UserPermissions::EDIT_OWN_POST))
- || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::EDIT_OTHER_POST));
-
-$canEdit = $canEdit && !$topic->isLocked;
-
-$canDelete = ($GLOBALS["currentUser"]?->id === $postAuthor?->id && $postAuthor?->hasPermission(UserPermissions::DELETE_OWN_POST))
- || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::DELETE_OTHER_POST));
-
-$canViewAttachments = $GLOBALS["currentUser"] !== null;
-
-$hide_actions ??= false;
-$hide_pfp ??= false;
-$your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id;
-$is_op = $postAuthor?->id === $topicAuthor?->id && $postAuthor?->id !== null;
-
-?>
-
-<?php if ($post->deleted): ?>
-<div class="media" id="post-<?= htmlentities($post->id) ?>">
-<div class="media-left hidden-sm hidden-xs">
- <div class="media-object" style="width:64px"></div>
-</div>
-<div class="media-body">
- <div class="well icon-well text-warning">
- <span class="fa fa-exclamation-triangle text-warning" aria-hidden="true"></span>
- <em><?= __("This post has been deleted") ?></em>
- </div>
-</div>
-</div>
-<?php else: ?>
-<div class="media" id="post-<?= htmlentities($post->id) ?>" data-text="<?= htmlentities($post->content) ?>" style="overflow: visible;">
-<?php if (!$hide_pfp): ?>
- <div class="media-left hidden-sm hidden-xs">
- <?php if ($postAuthor): ?>
- <?php if ($hide_actions): ?>
- <img class="media-object" alt="<?= __("Profile picture") ?>" src="?_action=profilepicture&amp;user=<?= htmlentities(urlencode($postAuthor->id)) ?>" width="64" height="64">
- <?php else: ?>
- <a href="?_action=viewuser&amp;user=<?= htmlentities(urlencode($postAuthor->id)) ?>">
- <img class="media-object" alt="<?= __("Profile picture") ?>" src="?_action=profilepicture&amp;user=<?= htmlentities(urlencode($postAuthor->id)) ?>" width="64" height="64">
- </a>
- <?php endif; ?>
- <?php else: ?>
- <div class="media-object" style="width:64px;height:64px"></div>
- <?php endif; ?>
- </div>
-<?php endif; ?>
- <div class="media-body" style="overflow: visible;">
- <div class="panel panel-default">
- <div class="panel-heading">
- <div class="panel-title h3">
- <?php if (!$hide_actions): ?>
- <div class="pull-right">
- <a href="#post-<?= htmlentities(urlencode($post->id)) ?>" class="btn btn-default"><span class="fa fa-link" aria-hidden="true"></span><span class="sr-only"><?= __("Permalink") ?></span></a>
- <?php if ($canReply): ?>
- <button data-post-id="<?= htmlentities($post->id) ?>" class="btn btn-default js-only _reply-post"><span class="fa fa-comment" aria-hidden="true"></span><span class="sr-only"><?= __("Reply to post") ?></span></button>
- <?php endif; ?>
- <?php if ($canEdit): ?>
- <button data-post-id="<?= htmlentities($post->id) ?>" class="btn btn-default js-only _edit-post"><span class="fa fa-pencil" aria-hidden="true"></span><span class="sr-only"><?= __("Edit post") ?></span></button>
- <?php endif; ?>
- <?php if ($canDelete): ?>
- <form action="?_action=deletepost" method="post" class="seamless-inline">
- <input type="hidden" name="post" value="<?= htmlentities($post->id) ?>">
- <button type="submit" class="btn btn-danger"><span class="fa fa-trash" aria-hidden="true"></span><span class="sr-only"><?= __("Delete post") ?></span></button>
- </form>
- <?php endif; ?>
- </div>
- <?php endif; ?>
- <?php if ($postAuthor): ?>
- <?php if ($hide_actions): ?>
- <?= htmlentities($postAuthor->displayName) ?>
- <?php else: ?>
- <a href="?_action=viewuser&amp;user=<?= htmlentities(urlencode($postAuthor->id)) ?>"><?= htmlentities($postAuthor->displayName) ?></a>
- <?php if ($is_op): ?>
- <span title="<?= __("Created this topic") ?>" class="text-info fa fa-user-circle"></span>
- <?php endif; ?>
- <?php endif; ?>
- <?php if ($your_are_the_author): ?>
- <span class="text-normal label label-primary"><?= __("You") ?></span>
- <?php endif; ?>
- <?php else: ?>
- <em class="text-muted"><?= __("(deleted)") ?></em>
- <?php endif; ?>
- </div>
- <span class="_time"><?= $post->postDate->format("c"); ?></span>
- <?php if ($post->edited): ?>
- <em class="text-muted"><?= __("(edited)") ?></em>
- <?php endif; ?>
- </div>
- <div class="panel-body">
- <div class="post-content"><?= renderPost($post->content) ?></div>
- <?php if (count($imageAttachments) > 0): ?>
- <div class="post-images clearfix">
- <?php /** @var Attachment $attachment */ foreach ($imageAttachments as $attachment): ?>
- <?php if ($hide_actions): ?>
- <span class="image-attachment" title="<?= htmlentities($attachment->name) ?>">
- <img class="image-attachment-image" src="?_action=thumb&amp;attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="100">
- </span>
- <?php else: ?>
- <a class="image-attachment attachment<?php if (str_starts_with($attachment->mimeType, "video/")): ?> video-attachment<?php endif; ?>" href="?_action=attachment&amp;attachment=<?= htmlentities(urlencode($attachment->id)) ?>" title="<?= htmlentities($attachment->name) ?>" data-attachment-id="<?= htmlentities($attachment->id) ?>">
- <img class="image-attachment-image" src="?_action=thumb&amp;attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="100">
- <?php if (!$canViewAttachments): ?>
- <span class="attachment-lock fa fa-ban" aria-hidden="true"></span>
- <?php elseif (str_starts_with($attachment->mimeType, "video/")): ?>
- <span class="video-player-icon fa fa-play-circle" aria-hidden="true"></span>
- <?php endif; ?>
- </a>
- <?php endif; ?>
- <?php endforeach; ?>
- </div>
- <?php endif; ?>
- </div>
- <?php if (count($fileAttachments) > 0): ?>
- <div class="panel-footer">
- <div class="btn-group">
- <?php /** @var Attachment $attachment */ foreach ($fileAttachments as $attachment): ?>
- <?php if ($hide_actions): ?>
- <button class="btn btn-default"><?= htmlentities($attachment->name) ?></button>
- <?php else: ?>
- <a class="btn btn-default attachment" href="?_action=attachment&amp;attachment=<?= htmlentities(urlencode($attachment->id)) ?>">
- <?php if (!$canViewAttachments): ?>
- <span class="fa fa-ban" aria-hidden="true"></span>
- <?php endif; ?>
- <?= htmlentities($attachment->name) ?>
- </a>
- <?php endif; ?>
- <?php endforeach; ?>
- </div>
- </div>
- <?php endif; ?>
- </div>
- </div>
-</div>
-
-<?php endif; ?>