Posting page
This commit is contained in:
parent
60e6accb2e
commit
990a32d8a1
4 changed files with 107 additions and 14 deletions
30
assets/less/mio/classes/forum/posting.less
Normal file
30
assets/less/mio/classes/forum/posting.less
Normal file
|
@ -0,0 +1,30 @@
|
|||
.forum__posting {
|
||||
|
||||
&__content {
|
||||
margin: 2px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
&__title {
|
||||
margin-bottom: 2px;
|
||||
|
||||
&__input {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&__text {
|
||||
margin-bottom: 2px;
|
||||
|
||||
&__input {
|
||||
min-width: 100%;
|
||||
max-width: 100%;
|
||||
min-height: 200px;
|
||||
}
|
||||
}
|
||||
|
||||
&__buttons {
|
||||
display: flex;
|
||||
}
|
||||
}
|
|
@ -74,4 +74,5 @@ body {
|
|||
@import "classes/forum/actions";
|
||||
@import "classes/forum/listing";
|
||||
@import "classes/forum/post";
|
||||
@import "classes/forum/posting";
|
||||
@import "classes/forum/topics";
|
||||
|
|
|
@ -12,6 +12,7 @@ if (!$app->hasActiveSession()) {
|
|||
$postRequest = $_SERVER['REQUEST_METHOD'] === 'POST';
|
||||
|
||||
$db = Database::connection();
|
||||
$templating = $app->getTemplating();
|
||||
|
||||
// ORDER OF CHECKING
|
||||
// - $postId non-zero: enter quote mode
|
||||
|
@ -43,7 +44,7 @@ if (!empty($postId)) {
|
|||
|
||||
if (!empty($topicId)) {
|
||||
$getTopic = $db->prepare('
|
||||
SELECT `topic_id`, `forum_id`
|
||||
SELECT `topic_id`, `forum_id`, `topic_title`
|
||||
FROM `msz_forum_topics`
|
||||
WHERE `topic_id` = :topic_id
|
||||
');
|
||||
|
@ -57,7 +58,7 @@ if (!empty($topicId)) {
|
|||
|
||||
if (!empty($forumId)) {
|
||||
$getForum = $db->prepare('
|
||||
SELECT `forum_id`
|
||||
SELECT `forum_id`, `forum_name`
|
||||
FROM `msz_forum_categories`
|
||||
WHERE `forum_id` = :forum_id
|
||||
');
|
||||
|
@ -107,21 +108,38 @@ if ($postRequest) {
|
|||
return;
|
||||
}
|
||||
|
||||
echo '<form method="post" action="/forum/posting.php">';
|
||||
$lastParent = $forumId;
|
||||
$breadcrumbs = [];
|
||||
$getBreadcrumb = $db->prepare('
|
||||
SELECT `forum_id`, `forum_name`, `forum_parent`
|
||||
FROM `msz_forum_categories`
|
||||
WHERE `forum_id` = :forum_id
|
||||
');
|
||||
|
||||
if (isset($topic)) {
|
||||
echo "<input type='hidden' name='post[topic]' value='{$topic['topic_id']}'>";
|
||||
} else {
|
||||
echo "<input type='hidden' name='post[forum]' value='{$forum['forum_id']}'>";
|
||||
echo '<input type="text" name="post[title]"><br>';
|
||||
while ($lastParent > 0) {
|
||||
$getBreadcrumb->bindValue('forum_id', $lastParent);
|
||||
$breadcrumb = $getBreadcrumb->execute() ? $getBreadcrumb->fetch() : [];
|
||||
|
||||
if (!$breadcrumb) {
|
||||
break;
|
||||
}
|
||||
|
||||
$breadcrumbs[$breadcrumb['forum_name']] = '/forum/forum.php?f=' . $breadcrumb['forum_id'];
|
||||
$lastParent = $breadcrumb['forum_parent'];
|
||||
}
|
||||
|
||||
echo '<textarea name="post[text]">';
|
||||
$breadcrumbs['Forums'] = '/forum/';
|
||||
$breadcrumbs = array_reverse($breadcrumbs);
|
||||
|
||||
if (isset($post)) {
|
||||
echo '[quote=' . $post['user_id'] . ']' . $post['post_text'] . '[/quote]';
|
||||
if (!empty($topic)) {
|
||||
$templating->var('posting_topic', $topic);
|
||||
}
|
||||
|
||||
echo '</textarea><br>
|
||||
<button>Submit</button>
|
||||
</form>';
|
||||
if (!empty($post)) {
|
||||
$templating->var('posting_quote', $post);
|
||||
}
|
||||
|
||||
echo $templating->render('forum.posting', [
|
||||
'posting_breadcrumbs' => $breadcrumbs,
|
||||
'posting_forum' => $forum,
|
||||
]);
|
||||
|
|
44
views/mio/forum/posting.twig
Normal file
44
views/mio/forum/posting.twig
Normal file
|
@ -0,0 +1,44 @@
|
|||
{% extends '@mio/forum/master.twig' %}
|
||||
{% from '@mio/macros.twig' import navigation %}
|
||||
|
||||
{% set title = 'Posting' %}
|
||||
|
||||
{% block content %}
|
||||
{{ navigation(posting_breadcrumbs, posting_breadcrumbs|last, true, null, 'left') }}
|
||||
|
||||
<form
|
||||
class="container forum__posting"
|
||||
method="post"
|
||||
action="/forum/posting.php">
|
||||
<div class="container__title">
|
||||
{% if posting_quote is defined %}
|
||||
Quoting » {{ posting_topic.topic_title }}
|
||||
{% elseif posting_topic is defined %}
|
||||
Replying » {{ posting_topic.topic_title }}
|
||||
{% else %}
|
||||
Creating Topic » {{ posting_forum.forum_name }}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="container__content forum__posting__content">
|
||||
{% if posting_topic is defined %}
|
||||
<input type="hidden" name="post[topic]" value="{{ posting_topic.topic_id }}">
|
||||
{% else %}
|
||||
<input type="hidden" name="post[forum]" value="{{ posting_forum.forum_id }}">
|
||||
|
||||
<div class="forum__posting__title">
|
||||
<input class="input__text forum__posting__title__input" type="text" name="post[title]" placeholder="Topic title">
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="forum__posting__text">
|
||||
<textarea class="input__textarea forum__posting__text__input" name="post[text]">{% if posting_quote is defined %}[quote={{ posting_quote.post_id }}]{{ posting_quote.post_text }}[/quote]{% endif %}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="forum__posting__buttons">
|
||||
<button class="input__button">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{{ navigation(mio_navigation, '/forum/') }}
|
||||
{% endblock %}
|
Loading…
Add table
Reference in a new issue