summaryrefslogtreecommitdiff
path: root/src/application/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/application/views')
-rw-r--r--src/application/views/alert_error.php3
-rw-r--r--src/application/views/form_addpost.php27
-rw-r--r--src/application/views/form_delete_post_confirm.php25
-rw-r--r--src/application/views/form_login.php40
-rw-r--r--src/application/views/form_newtopic.php24
-rw-r--r--src/application/views/form_register.php55
-rw-r--r--src/application/views/nav_guest.php6
-rw-r--r--src/application/views/nav_logged_in.php14
-rw-r--r--src/application/views/template_end.php22
-rw-r--r--src/application/views/template_navigation.php6
-rw-r--r--src/application/views/template_navigation_end.php4
-rw-r--r--src/application/views/template_navigation_start.php12
-rw-r--r--src/application/views/template_start.php22
-rw-r--r--src/application/views/view_post.php86
-rw-r--r--src/application/views/view_topic_end.php0
-rw-r--r--src/application/views/view_topic_start.php55
-rw-r--r--src/application/views/view_topics.php19
-rw-r--r--src/application/views/view_user.php1
18 files changed, 421 insertions, 0 deletions
diff --git a/src/application/views/alert_error.php b/src/application/views/alert_error.php
new file mode 100644
index 0000000..c18546b
--- /dev/null
+++ b/src/application/views/alert_error.php
@@ -0,0 +1,3 @@
+<div class="alert alert-danger" role="alert">
+<?= htmlentities($message); ?>
+</div>
diff --git a/src/application/views/form_addpost.php b/src/application/views/form_addpost.php
new file mode 100644
index 0000000..b3cd6ca
--- /dev/null
+++ b/src/application/views/form_addpost.php
@@ -0,0 +1,27 @@
+<?php
+
+use mystic\forum\utils\RequestUtils;
+
+$lastFormUri = "";
+$lastForm = RequestUtils::getLastForm($lastFormUri) ?? [];
+if ($lastFormUri !== $_SERVER["REQUEST_URI"]) $lastForm = [];
+RequestUtils::clearLastForm();
+
+?>
+<h3 id="form">Reply to this topic</h3>
+<?php
+if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
+ _view("alert_error", ["message" => $_formError]);
+}
+?>
+<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>#form" method="post" enctype="multipart/form-data">
+<div class="form-group">
+ <label for="i_message">Message:</label>
+ <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>
+ <input type="file" name="files[]" id="i_files" multiple accept="*/*">
+</div>
+<button type="submit" class="btn btn-success">Post reply</button>
+</form>
diff --git a/src/application/views/form_delete_post_confirm.php b/src/application/views/form_delete_post_confirm.php
new file mode 100644
index 0000000..9d04095
--- /dev/null
+++ b/src/application/views/form_delete_post_confirm.php
@@ -0,0 +1,25 @@
+<div class="panel panel-danger">
+ <div class="panel-heading">
+ <h3 class="panel-title">Do you want to delete your post?</h3>
+ </div>
+ <div class="panel-body">
+ Are you sure you want to delete the following post:
+ <div class="well">
+ <?= renderPost($post->content); ?>
+ </div>
+ </div>
+ <div class="panel-footer">
+ <div class="text-right">
+ <form action="." 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>
+ </form>
+ <form action="?_action=deletepost" method="post" class="seamless-inline">
+ <input type="hidden" name="post" value="<?= htmlentities($post->id) ?>">
+ <input type="hidden" name="confirm" value="<?= htmlentities(base64_encode(hash("sha256", "confirm" . $post->id, true))); ?>">
+ <button class="btn btn-danger">Delete my post</button>
+ </form>
+ </div>
+ </div>
+</div>
diff --git a/src/application/views/form_login.php b/src/application/views/form_login.php
new file mode 100644
index 0000000..0e98a24
--- /dev/null
+++ b/src/application/views/form_login.php
@@ -0,0 +1,40 @@
+<?php
+
+use mystic\forum\Messaging;
+use mystic\forum\utils\RequestUtils;
+
+$lastFormUri = "";
+$lastForm = RequestUtils::getLastForm($lastFormUri) ?? [];
+if ($lastFormUri !== $_SERVER["REQUEST_URI"]) $lastForm = [];
+RequestUtils::clearLastForm();
+
+?>
+<h1>Log in</h1>
+<div class="col-md-4"></div>
+<div class="well col-md-4">
+<?php
+if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
+ _view("alert_error", ["message" => $_formError]);
+}
+?>
+<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>
+</div>
+
+<div class="form-group">
+ <label for="i_password">Password:</label>
+ <input class="form-control" type="password" id="i_password" name="password" required>
+</div>
+
+<div class="form-group">
+ <button class="btn btn-default" type="submit">Log in</button>
+</div>
+
+<div class="form-group">
+ Don't have an account? <a href="?_action=register">Register now</a>
+</div>
+</form>
+</div>
+<div class="col-md-4"></div>
diff --git a/src/application/views/form_newtopic.php b/src/application/views/form_newtopic.php
new file mode 100644
index 0000000..d5cbfbd
--- /dev/null
+++ b/src/application/views/form_newtopic.php
@@ -0,0 +1,24 @@
+<?php
+
+use mystic\forum\Messaging;
+use mystic\forum\utils\RequestUtils;
+
+if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
+ Messaging::error($_formError);
+}
+
+$lastFormUri = "";
+$lastForm = RequestUtils::getLastForm($lastFormUri) ?? [];
+if ($lastFormUri !== $_SERVER["REQUEST_URI"]) $lastForm = [];
+RequestUtils::clearLastForm();
+
+?>
+<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>" method="post">
+<strong>Topic title:</strong><br>
+<input type="text" name="title" value="<?= htmlentities($lastForm["title"] ?? "") ?>" required><br>
+
+<strong>Message:</strong><br>
+<textarea name="message" rows="12" cols="60" required></textarea><br>
+
+<button type="submit">Create topic</button>
+</form>
diff --git a/src/application/views/form_register.php b/src/application/views/form_register.php
new file mode 100644
index 0000000..221f37d
--- /dev/null
+++ b/src/application/views/form_register.php
@@ -0,0 +1,55 @@
+<?php
+
+use mystic\forum\Messaging;
+use mystic\forum\utils\RequestUtils;
+
+$lastFormUri = "";
+$lastForm = RequestUtils::getLastForm($lastFormUri) ?? [];
+if ($lastFormUri !== $_SERVER["REQUEST_URI"]) $lastForm = [];
+RequestUtils::clearLastForm();
+
+?>
+<h1>Register</h1>
+<div class="col-md-4"></div>
+<div class="well col-md-4">
+<?php
+if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
+ _view("alert_error", ["message" => $_formError]);
+}
+?>
+<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>" method="post">
+<div class="form-group">
+ <label for="i_username">Username:</label>
+ <input class="form-control" id="i_username" type="text" name="username" value="<?= htmlentities($lastForm["username"] ?? "") ?>" required>
+</div>
+
+<div class="form-group">
+ <label for="i_display_name">Display name:</label>
+ <input class="form-control" id="i_display_name" type="text" name="display_name" value="<?= htmlentities($lastForm["display_name"] ?? "") ?>" required>
+</div>
+
+<div class="form-group">
+ <label for="i_password">Choose password:</label>
+ <input class="form-control" id="i_password" type="password" name="password" required>
+</div>
+
+<div class="form-group">
+ <label for="i_password_retype">Repeat password:</label>
+ <input class="form-control" id="i_password_retype" type="password" name="password_retype" required>
+</div>
+
+<div class="form-group">
+ <label for="i_email">Email address:</label>
+ <input class="form-control" id="i_email" type="email" name="email" value="<?= htmlentities($lastForm["email"] ?? "") ?>" required>
+</div>
+
+<div class="form-group">
+ <button class="btn btn-default" type="submit">Register now</button>
+</div>
+
+<div class="form-group">
+ Already have an account? <a href="?_action=auth">Sign in now</a>
+</div>
+</form>
+</div>
+<div class="col-md-4"></div>
diff --git a/src/application/views/nav_guest.php b/src/application/views/nav_guest.php
new file mode 100644
index 0000000..433c487
--- /dev/null
+++ b/src/application/views/nav_guest.php
@@ -0,0 +1,6 @@
+<ul class="nav navbar-nav navbar-right">
+<li<?= $GLOBALS["action"] === "auth" ? ' class="active"' : '' ?>><a href="?_action=auth">Log in</a></li>
+<?php if (REGISTRATION_ENABLED): ?>
+<li<?= $GLOBALS["action"] === "register" ? ' class="active"' : '' ?>><a href="?_action=register">Register</a></li>
+<?php endif; ?>
+</ul> \ No newline at end of file
diff --git a/src/application/views/nav_logged_in.php b/src/application/views/nav_logged_in.php
new file mode 100644
index 0000000..fd46d6e
--- /dev/null
+++ b/src/application/views/nav_logged_in.php
@@ -0,0 +1,14 @@
+<?php
+use mystic\forum\orm\User;
+?>
+<ul class="nav navbar-nav navbar-right">
+<li><p class="navbar-text">Welcome,
+<?php if ($user->id === User::SUPERUSER_ID): ?>
+<strong class="text-danger"><?= htmlentities($user->displayName) ?></strong>!
+<?php else: ?>
+<strong><?= htmlentities($user->displayName) ?></strong>!
+<?php endif; ?>
+</p></li>
+<li><a href="?_action=viewuser&amp;user=<?= htmlentities(urlencode($user->id)) ?>"><span class="glyphicon glyphicon-user" aria-hidden="true"><span class="sr-only">View profile</span></a></li>
+<li><a href="?_action=logout"><span class="glyphicon glyphicon-log-out" aria-hidden="true"><span class="sr-only">Log out</span></a></li>
+</ul>
diff --git a/src/application/views/template_end.php b/src/application/views/template_end.php
new file mode 100644
index 0000000..f7f70a9
--- /dev/null
+++ b/src/application/views/template_end.php
@@ -0,0 +1,22 @@
+</div>
+<footer class="footer">
+<div class="container">
+<div class="panel panel-default">
+<div class="panel-body">
+ &copy; <?= date("Y") ?>
+</div>
+</div>
+</div>
+</footer>
+
+<script>
+$(function() {
+ $("._time").each(function(i, e) {
+ var date = new Date($(e).text());
+ $(e).text(date.toLocaleString());
+ });
+});
+</script>
+
+</body>
+</html>
diff --git a/src/application/views/template_navigation.php b/src/application/views/template_navigation.php
new file mode 100644
index 0000000..d39c1ea
--- /dev/null
+++ b/src/application/views/template_navigation.php
@@ -0,0 +1,6 @@
+<?php
+if ($user) {
+ _view("nav_logged_in", ["user" => $user]);
+} else {
+ _view("nav_guest");
+}
diff --git a/src/application/views/template_navigation_end.php b/src/application/views/template_navigation_end.php
new file mode 100644
index 0000000..a43919c
--- /dev/null
+++ b/src/application/views/template_navigation_end.php
@@ -0,0 +1,4 @@
+</div>
+</div>
+</nav>
+<div class="container">
diff --git a/src/application/views/template_navigation_start.php b/src/application/views/template_navigation_start.php
new file mode 100644
index 0000000..48cdb9a
--- /dev/null
+++ b/src/application/views/template_navigation_start.php
@@ -0,0 +1,12 @@
+<nav class="navbar navbar-default navbar-static-top">
+ <div class="container">
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#nav-collapse" aria-expanded="false">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href=".">Forum</a>
+ </div>
+ <div class="collapse navbar-collapse" id="nav-collapse">
diff --git a/src/application/views/template_start.php b/src/application/views/template_start.php
new file mode 100644
index 0000000..e011f74
--- /dev/null
+++ b/src/application/views/template_start.php
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<!--[if lt IE 7]> <html lang="de" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
+<!--[if IE 7]> <html lang="de" class="no-js lt-ie9 lt-ie8"> <![endif]-->
+<!--[if IE 8]> <html lang="de" class="no-js lt-ie9"> <![endif]-->
+<!--[if gt IE 8]><!--> <html lang="de" class="no-js"> <!--<![endif]-->
+<head>
+ <meta charset="utf-8">
+ <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">
+ <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>
+ <!--[if lt IE 9]>
+ <script src="/ui/html5shiv.min.js"></script>
+ <script src="/ui/respond.min.js"></script>
+ <![endif]-->
+</head>
+<body>
diff --git a/src/application/views/view_post.php b/src/application/views/view_post.php
new file mode 100644
index 0000000..0776fb5
--- /dev/null
+++ b/src/application/views/view_post.php
@@ -0,0 +1,86 @@
+<?php
+
+use mystic\forum\orm\UserPermissions;
+use mystic\forum\orm\Attachment;
+
+$fileAttachments = array_filter($attachments, fn(Attachment $a) => !str_starts_with($a->mimeType, "image/"));
+$imageAttachments = array_filter($attachments, fn(Attachment $a) => str_starts_with($a->mimeType, "image/"));
+
+$canReply = $GLOBALS["currentUser"]?->hasPermission(UserPermissions::CREATE_OWN_POST) ?? false;
+
+$canDelete = ($GLOBALS["currentUser"]?->id === $postAuthor?->id && $postAuthor?->hasPermission(UserPermissions::DELETE_OWN_POST))
+ || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::DELETE_OTHER_POST));
+
+?>
+
+<?php if ($post->deleted): ?>
+<div class="media">
+<div class="media-left hidden-sm hidden-xs">
+ <div class="media-object" style="width:64px"></div>
+</div>
+<div class="media-body">
+ <div class="well">
+ <em>This post has been deleted</em>
+ </div>
+</div>
+</div>
+<?php else: ?>
+<div class="media">
+ <div class="media-left hidden-sm hidden-xs">
+ <?php if ($postAuthor): ?>
+ <a href="?_action=viewuser&amp;user=<?= htmlentities(urlencode($postAuthor->id)) ?>">
+ <img class="media-object" src="/ui/placeholder.svg" alt="" width="64" height="64">
+ </a>
+ <?php else: ?>
+ <div class="media-object" style="width:64px;height:64px"></div>
+ <?php endif; ?>
+ </div>
+ <div class="media-body">
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <h3 class="panel-title">
+ <div class="pull-right">
+ <?php if ($canReply): ?>
+ <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): ?>
+ <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="glyphicon glyphicon-trash" aria-hidden="true"></span><span class="sr-only">Delete post</span></button>
+ </form>
+ <?php endif; ?>
+ </div>
+ <?php if ($postAuthor): ?>
+ <a href="?_action=viewuser&amp;user=<?= htmlentities(urlencode($postAuthor->id)) ?>"><?= htmlentities($postAuthor->displayName) ?></a>
+ <?php else: ?>
+ <em class="text-muted">(deleted)</em>
+ <?php endif; ?>
+ </h3>
+ <span class="_time"><?= $post->postDate->format("c"); ?></span>
+ </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): ?>
+ <a class="image-attachment" href="?_action=attachment&amp;attachment=<?= htmlentities(urlencode($attachment->id)) ?>" title="<?= htmlentities($attachment->name) ?>">
+ <img class="image-attachment-image" src="?_action=thumb&amp;attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="110">
+ </a>
+ <?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): ?>
+ <a class="btn btn-default" href="?_action=attachment&amp;attachment=<?= htmlentities(urlencode($attachment->id)) ?>"><?= htmlentities($attachment->name) ?></a>
+ <?php endforeach; ?>
+ </div>
+ </div>
+ <?php endif; ?>
+ </div>
+ </div>
+</div>
+
+<?php endif; ?>
diff --git a/src/application/views/view_topic_end.php b/src/application/views/view_topic_end.php
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/application/views/view_topic_end.php
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&amp;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; ?>
diff --git a/src/application/views/view_topics.php b/src/application/views/view_topics.php
new file mode 100644
index 0000000..cb871cb
--- /dev/null
+++ b/src/application/views/view_topics.php
@@ -0,0 +1,19 @@
+<?php
+
+use mystic\forum\orm\User;
+use mystic\forum\orm\UserPermissions;
+
+if ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::CREATE_OWN_TOPIC)):
+?>
+<p class="text-right">
+<a href="?_action=newtopic" class="btn btn-success"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span>&nbsp;New topic</a>
+</p>
+<?php endif; ?>
+<div class="list-group">
+<?php /** @var Topic $topic */ foreach ($topics as $topic): ?>
+<a class="list-group-item" href="?_action=viewtopic&amp;topic=<?= htmlentities(urlencode($topic->id)) ?>">
+ <h4 class="list-group-item-heading"><?= htmlentities($topic->title) ?></h4>
+ <p class="list-group-item-text _time"><?= htmlentities($topic->creationDate->format("c")) ?></p>
+</a>
+<?php endforeach; ?>
+</div>
diff --git a/src/application/views/view_user.php b/src/application/views/view_user.php
new file mode 100644
index 0000000..334928b
--- /dev/null
+++ b/src/application/views/view_user.php
@@ -0,0 +1 @@
+<h1><?= htmlentities($user->displayName) ?></h1>