diff options
author | Jonas Kohl | 2024-09-13 19:57:43 +0200 |
---|---|---|
committer | Jonas Kohl | 2024-09-13 19:57:43 +0200 |
commit | 93817fef3ead7cfd4fcde25ea2bcec02d01310a4 (patch) | |
tree | 60f6ab69bbf2360d7cc518023090b8bf61bfd5b1 /src/application/views | |
parent | 086e2d2668784469ec114f6e6fd2b3dace3d7c3b (diff) |
A lot of changes again
Diffstat (limited to 'src/application/views')
-rw-r--r-- | src/application/views/form_addpost.php | 2 | ||||
-rw-r--r-- | src/application/views/form_delete_post_confirm.php | 17 | ||||
-rw-r--r-- | src/application/views/form_login.php | 2 | ||||
-rw-r--r-- | src/application/views/template_end.php | 8 | ||||
-rw-r--r-- | src/application/views/template_start.php | 4 | ||||
-rw-r--r-- | src/application/views/view_post.php | 53 | ||||
-rw-r--r-- | src/application/views/view_topic_start.php | 28 | ||||
-rw-r--r-- | src/application/views/view_user.php | 154 |
8 files changed, 232 insertions, 36 deletions
diff --git a/src/application/views/form_addpost.php b/src/application/views/form_addpost.php index b3cd6ca..88eda27 100644 --- a/src/application/views/form_addpost.php +++ b/src/application/views/form_addpost.php @@ -20,7 +20,7 @@ if (($_formError = RequestUtils::getAndClearFormError()) !== null) { <textarea class="form-control" id="i_message" name="message" required rows="12" cols="60" style="resize:vertical;max-height:499px"></textarea> </div> <div class="form-group"> - <label for="i_files">Attachments:</label> + <label for="i_files">Attachments: <small>(max. 4 files, max. 2 MiB each)</small></label> <input type="file" name="files[]" id="i_files" multiple accept="*/*"> </div> <button type="submit" class="btn btn-success">Post reply</button> diff --git a/src/application/views/form_delete_post_confirm.php b/src/application/views/form_delete_post_confirm.php index 9d04095..2dc417d 100644 --- a/src/application/views/form_delete_post_confirm.php +++ b/src/application/views/form_delete_post_confirm.php @@ -1,16 +1,21 @@ <div class="panel panel-danger"> <div class="panel-heading"> - <h3 class="panel-title">Do you want to delete your post?</h3> + <?php if ($postAuthor->id === $GLOBALS["currentUser"]->id): ?> + <h3 class="panel-title">Do you want to delete your post?</h3> + <?php else: ?> + <h3 class="panel-title">Do you want to delete <?= htmlentities($postAuthor->displayName) ?>'s post?</h3> + <?php endif; ?> </div> <div class="panel-body"> - Are you sure you want to delete the following post: - <div class="well"> - <?= renderPost($post->content); ?> - </div> + Are you sure you want to delete the following post:<br> + <?php _view("view_post", [ + ...$___PARAMS, + "hide_actions" => true + ]) ?> </div> <div class="panel-footer"> <div class="text-right"> - <form action="." method="get" class="seamless-inline"> + <form action=".#post-<?= htmlentities(urlencode($post->id)) ?>" method="get" class="seamless-inline"> <input type="hidden" name="_action" value="viewtopic"> <input type="hidden" name="topic" value="<?= htmlentities($post->topicId) ?>"> <button class="btn btn-default">Keep my post</button> diff --git a/src/application/views/form_login.php b/src/application/views/form_login.php index 0e98a24..8ddb22e 100644 --- a/src/application/views/form_login.php +++ b/src/application/views/form_login.php @@ -20,7 +20,7 @@ if (($_formError = RequestUtils::getAndClearFormError()) !== null) { <form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>" method="post"> <div class="form-group"> <label for="i_username">Username:</label> - <input class="form-control" type="text" id="i_username" name="username" value="<?= htmlentities($lastForm["username"] ?? "") ?>" required> + <input class="form-control" type="text" id="i_username" name="username" value="<?= htmlentities($lastForm["username"] ?? "") ?>" required autofocus> </div> <div class="form-group"> diff --git a/src/application/views/template_end.php b/src/application/views/template_end.php index f7f70a9..27fc3ba 100644 --- a/src/application/views/template_end.php +++ b/src/application/views/template_end.php @@ -15,6 +15,14 @@ $(function() { var date = new Date($(e).text()); $(e).text(date.toLocaleString()); }); + $("._date").each(function(i, e) { + var date = new Date($(e).text()); + $(e).text(date.toLocaleDateString()); + }); + $("._time-only").each(function(i, e) { + var date = new Date($(e).text()); + $(e).text(date.toLocaleTimeString()); + }); }); </script> diff --git a/src/application/views/template_start.php b/src/application/views/template_start.php index e011f74..4cfdb74 100644 --- a/src/application/views/template_start.php +++ b/src/application/views/template_start.php @@ -8,9 +8,7 @@ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width,initial-scale=1"> <title><?= htmlentities($_title ?? "") ?></title> - <link rel="stylesheet" href="/ui/dist/css/bootstrap.min.css"> - <link rel="stylesheet" href="/ui/dist/css/bootstrap-theme.min.css"> - <link rel="stylesheet" href="/ui/site.css"> + <link rel="stylesheet" href="/ui/theme-default.css"> <script src="/ui/jquery-1.12.4.min.js"></script> <script src="/ui/dist/js/bootstrap.min.js"></script> <script src="/ui/modernizr-2.6.2.min.js"></script> diff --git a/src/application/views/view_post.php b/src/application/views/view_post.php index 0776fb5..5022d4a 100644 --- a/src/application/views/view_post.php +++ b/src/application/views/view_post.php @@ -11,36 +11,49 @@ $canReply = $GLOBALS["currentUser"]?->hasPermission(UserPermissions::CREATE_OWN_ $canDelete = ($GLOBALS["currentUser"]?->id === $postAuthor?->id && $postAuthor?->hasPermission(UserPermissions::DELETE_OWN_POST)) || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::DELETE_OTHER_POST)); +$hide_actions ??= false; +$hide_pfp ??= false; +$your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id; + ?> <?php if ($post->deleted): ?> -<div class="media"> +<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"> + <div class="well icon-well text-warning"> + <span class="glyphicon glyphicon-exclamation-sign color-warning" aria-hidden="true"></span> <em>This post has been deleted</em> </div> </div> </div> <?php else: ?> -<div class="media"> +<div class="media" id="post-<?= htmlentities($post->id) ?>"> +<?php if (!$hide_pfp): ?> <div class="media-left hidden-sm hidden-xs"> <?php if ($postAuthor): ?> - <a href="?_action=viewuser&user=<?= htmlentities(urlencode($postAuthor->id)) ?>"> - <img class="media-object" src="/ui/placeholder.svg" alt="" width="64" height="64"> - </a> + <?php if ($hide_actions): ?> + <img class="media-object" alt="Profile picture" src="?_action=profilepicture&user=<?= htmlentities(urlencode($postAuthor->id)) ?>" alt="" width="64" height="64"> + <?php else: ?> + <a href="?_action=viewuser&user=<?= htmlentities(urlencode($postAuthor->id)) ?>"> + <img class="media-object" alt="Profile picture" src="?_action=profilepicture&user=<?= htmlentities(urlencode($postAuthor->id)) ?>" alt="" 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"> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title"> + <?php if (!$hide_actions): ?> <div class="pull-right"> <?php if ($canReply): ?> + <a href="#post-<?= htmlentities(urlencode($post->id)) ?>" class="btn btn-default"><span class="glyphicon glyphicon-link" aria-hidden="true"></span><span class="sr-only">Permalink</span></a> <button data-text="<?= htmlentities($post->content) ?>" class="btn btn-default js-only _reply-post"><span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span><span class="sr-only">Reply to post</span></button> <?php endif; ?> <?php if ($canDelete): ?> @@ -50,8 +63,16 @@ $canDelete = ($GLOBALS["currentUser"]?->id === $postAuthor?->id && $postAuthor?- </form> <?php endif; ?> </div> + <?php endif; ?> <?php if ($postAuthor): ?> - <a href="?_action=viewuser&user=<?= htmlentities(urlencode($postAuthor->id)) ?>"><?= htmlentities($postAuthor->displayName) ?></a> + <?php if ($hide_actions): ?> + <?= htmlentities($postAuthor->displayName) ?> + <?php else: ?> + <a href="?_action=viewuser&user=<?= htmlentities(urlencode($postAuthor->id)) ?>"><?= htmlentities($postAuthor->displayName) ?></a> + <?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; ?> @@ -63,9 +84,15 @@ $canDelete = ($GLOBALS["currentUser"]?->id === $postAuthor?->id && $postAuthor?- <?php if (count($imageAttachments) > 0): ?> <div class="post-images clearfix"> <?php /** @var Attachment $attachment */ foreach ($imageAttachments as $attachment): ?> - <a class="image-attachment" href="?_action=attachment&attachment=<?= htmlentities(urlencode($attachment->id)) ?>" title="<?= htmlentities($attachment->name) ?>"> - <img class="image-attachment-image" src="?_action=thumb&attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="110"> - </a> + <?php if ($hide_actions): ?> + <span class="image-attachment" title="<?= htmlentities($attachment->name) ?>"> + <img class="image-attachment-image" src="?_action=thumb&attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="110"> + </span> + <?php else: ?> + <a class="image-attachment" href="?_action=attachment&attachment=<?= htmlentities(urlencode($attachment->id)) ?>" title="<?= htmlentities($attachment->name) ?>"> + <img class="image-attachment-image" src="?_action=thumb&attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="110"> + </a> + <?php endif; ?> <?php endforeach; ?> </div> <?php endif; ?> @@ -74,7 +101,11 @@ $canDelete = ($GLOBALS["currentUser"]?->id === $postAuthor?->id && $postAuthor?- <div class="panel-footer"> <div class="btn-group"> <?php /** @var Attachment $attachment */ foreach ($fileAttachments as $attachment): ?> - <a class="btn btn-default" href="?_action=attachment&attachment=<?= htmlentities(urlencode($attachment->id)) ?>"><?= htmlentities($attachment->name) ?></a> + <?php if ($hide_actions): ?> + <button class="btn btn-default"><?= htmlentities($attachment->name) ?></button> + <?php else: ?> + <a class="btn btn-default" href="?_action=attachment&attachment=<?= htmlentities(urlencode($attachment->id)) ?>"><?= htmlentities($attachment->name) ?></a> + <?php endif; ?> <?php endforeach; ?> </div> </div> diff --git a/src/application/views/view_topic_start.php b/src/application/views/view_topic_start.php index 5818483..84a29de 100644 --- a/src/application/views/view_topic_start.php +++ b/src/application/views/view_topic_start.php @@ -6,19 +6,21 @@ $canReply = $GLOBALS["currentUser"]?->hasPermission(UserPermissions::CREATE_OWN_ $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 class="page-header margin-top-0"> + <div role="heading" class="h1 margin-top-0"> + <?= 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> </div> <p> Started by diff --git a/src/application/views/view_user.php b/src/application/views/view_user.php index 334928b..23d2b71 100644 --- a/src/application/views/view_user.php +++ b/src/application/views/view_user.php @@ -1 +1,153 @@ -<h1><?= htmlentities($user->displayName) ?></h1> +<?php + +use mystic\forum\orm\UserPermissions; +use mystic\forum\utils\RequestUtils; +use mystic\forum\utils\StringUtils; + +/** @var mystic\forum\orm\User $user */ +/** @var bool $lastNameChangeTooRecent */ + +$canEdit = ($user->id === $GLOBALS["currentUser"]?->id && $user->hasPermission(UserPermissions::EDIT_OWN_USER)) + || $GLOBALS["currentUser"]?->hasPermission(UserPermissions::EDIT_OTHER_USER); + +$isOwnProfile = $user->id === $GLOBALS["currentUser"]?->id; + +$sIsOwn_your = ""; +if ($isOwnProfile) + $sIsOwn_your = " your"; + +$sUserPossessive = ""; +if ($isOwnProfile) + $sUserPossessive = "Your"; +else + $sUserPossessive = $user->displayName . "'s"; + +$dateJoined = DateTime::createFromImmutable($user->created); +$dateJoined->setTime(0, 0, 0, 0); +?> + +<div class="clearfix"> + <img class="pull-left margin-right" src="?_action=profilepicture&user=<?= htmlentities(urlencode($user->id)) ?>"> + <span class="h1"><?= htmlentities($user->displayName) ?></span> + <?php if ($isOwnProfile): ?> + <span class="label label-primary">You</span> + <?php endif; ?><br> + @<?= htmlentities($user->name) ?> • <span class="text-muted">Member since <span class="_date"><?= htmlentities($dateJoined->format("c")); ?></span> +</div> + +<?php if ($canEdit): ?> +<div class="row"> +<div class="col-md-9"> +<?php endif; ?> + +<h3><?= $sUserPossessive ?> posts</h3> + +<?php if (count($posts) > 0): ?> + <div class="post-container"> + <div class="post-container-posts"> + <div class="list-group margin-top"> + <?php foreach ($posts as $post): if ($post->deleted) continue; ?> + <a href="?_action=viewtopic&topic=<?= htmlentities(urlencode($post->topicId)) ?>#post-<?= htmlentities(urlencode($post->id)) ?>" class="list-group-item"> + <?= htmlentities(StringUtils::truncate(strip_tags(renderPost($post->content)), 100)) ?><br> + <span class="text-muted">posted on <span class="_time"><?= htmlentities($post->postDate->format("c")) ?></span> in <em><?= htmlentities($topics[$post->topicId]?->title ?? "unknown") ?></em></span> + </a> + <?php endforeach; ?> + </div> + </div> + <div class="post-container-controls"> + <button class="btn btn-default">Show all posts</button> + </div> + </div> +<?php else: ?> + <div class="well icon-well text-info margin-top margin-bottom"> + <span class="glyphicon glyphicon-info-sign color-info" aria-hidden="true"></span> + <em>This user has not posted anything yet</em> + </div> +<?php endif; ?> + +<?php if ($canEdit): ?> +</div> + +<div class="col-md-3"> +<h3>Edit<?= $sIsOwn_your ?> profile</h3> +<?php +if (($_formError = RequestUtils::getAndClearFormError()) !== null) { + _view("alert_error", ["message" => $_formError]); +} +?> +<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>" method="post" enctype="multipart/form-data"> + <div class="form-group"> + <label for="i_display_name">Display name:</label> + <input required class="form-control" type="text" name="display_name" id="i_display_name" value="<?= htmlentities($user->displayName) ?>"> + </div> + <div class="form-group"> + <label for="i_name">Login name:</label> + <?php if ($lastNameChangeTooRecent): ?> + <input required class="form-control" type="text" id="i_name" value="<?= htmlentities($user->name) ?>" disabled> + <small class="text-danger"><strong>You can only change your username every 30 days!</strong></small> + <?php else: ?> + <input required class="form-control" type="text" name="name" id="i_name" value="<?= htmlentities($user->name) ?>"> + <?php endif; ?> + </div> + <div class="form-group"> + <label for="i_email">Email address:</label> + <input required class="form-control" type="email" id="i_email" value="<?= htmlentities($user->email) ?>" disabled> + </div> + <div class="form-group"> + <label>Profile picture:</label> +<?php +$_checkbox_disabled = empty($user->profilePicture); +$_checkbox_disabled_class = $_checkbox_disabled ? " disabled" : ""; +?> + <div class="radio margin-top-0 <?= $_checkbox_disabled_class ?>"> + <label> + <input type="radio" name="pfp_action" id="pfp_action_1" value="keep"<?= !empty($user->profilePicture) ? ' checked' : ' disabled' ?>> + Existing profile picture + </label> + </div> + <div class="radio"> + <label> + <input type="radio" name="pfp_action" id="pfp_action_2" value="remove"<?= empty($user->profilePicture) ? ' checked' : '' ?>> + No profile picture + </label> + </div> + <div class="radio"> + <label> + <input type="radio" name="pfp_action" value="replace" id="pfp_action_3"> + Upload new profile picture + </label> + </div> + <input type="file" name="pfp" id="i_pfp" accept="image/png,image/jpeg" class="margin-left-3x"> + </div> + <div class="form-group"> + <button type="submit" class="btn btn-success">Save changes</button> + </div> +</form> +</div> + +</div> +<?php endif; ?> + +<script> +$(function() { + $(".post-container").each(function(i, e) { + if ($(e).height() > 900) { // more than 800 so it doesn't collapse just a few pixels + $(e).addClass("collapsed"); + } + $(e).find(".post-container-controls button").click(function() { + $(e).removeClass("collapsed"); + }); + }); +}); +<?php if ($canEdit): ?> +$(function() { + $("#i_pfp").hide().prop("disabled", true).prop("required", false); + $("[name='pfp_action']").on("change input check click", function() { + if ($("#pfp_action_3").is(":checked")) + $("#i_pfp").show().prop("disabled", false).prop("required", true); + else + $("#i_pfp").hide().prop("disabled", true).prop("required", false); + }) +}); +<?php endif; ?> +</script> |