r20151115
Possibly part 1 Signed-off-by: Flashwave <me@flash.moe>
This commit is contained in:
parent
d1ef9d924a
commit
e49dcf84c8
19 changed files with 297 additions and 276 deletions
|
@ -19,17 +19,19 @@ class Forum
|
|||
public $category = 0;
|
||||
public $type = 0;
|
||||
public $icon = "";
|
||||
public $firstReply = [];
|
||||
public $lastReply = [];
|
||||
public $firstPost = null;
|
||||
public $lastPost = null;
|
||||
public $forums = [];
|
||||
public $threads = [];
|
||||
|
||||
// Constructor
|
||||
public function __construct($forumId)
|
||||
public function __construct($forumId = 0)
|
||||
{
|
||||
// Get the row from the database
|
||||
$forumRow = Database::fetch('forums', false, ['forum_id' => [$forumId, '=']]);
|
||||
|
||||
// Populate the variables
|
||||
if (!$forumRow) {
|
||||
if ($forumRow) {
|
||||
$this->id = $forumRow['forum_id'];
|
||||
$this->name = $forumRow['forum_name'];
|
||||
$this->description = $forumRow['forum_desc'];
|
||||
|
@ -37,19 +39,30 @@ class Forum
|
|||
$this->category = $forumRow['forum_category'];
|
||||
$this->type = $forumRow['forum_type'];
|
||||
$this->icon = $forumRow['forum_icon'];
|
||||
} else {
|
||||
// Else just set the ID to $forumId and imitate an blank forum
|
||||
$this->id = $forumId;
|
||||
} elseif ($forumId != 0) {
|
||||
$this->id = -1;
|
||||
}
|
||||
|
||||
// Populate the forums array
|
||||
$this->forums = $this->getForums();
|
||||
|
||||
// and the threads array
|
||||
$this->threads = $this->getThreads();
|
||||
|
||||
// and the first post
|
||||
$this->firstPost = $this->getFirstPost();
|
||||
|
||||
// and finally the last post
|
||||
$this->lastPost = $this->getLastPost();
|
||||
}
|
||||
|
||||
// Subforums
|
||||
public function forums()
|
||||
public function getForums()
|
||||
{
|
||||
// Get all rows with the category id set to the forum id
|
||||
$forumRows = Database::fetch('forums', true, ['forum_category' => [$this->id, '=']]);
|
||||
|
||||
// Get a storage array
|
||||
// Create a storage array
|
||||
$forums = [];
|
||||
|
||||
// Create new objects for each forum
|
||||
|
@ -61,23 +74,59 @@ class Forum
|
|||
return $forums;
|
||||
}
|
||||
|
||||
// Last post
|
||||
public function lastPost()
|
||||
// Threads
|
||||
public function getThreads()
|
||||
{
|
||||
// Return a post
|
||||
$postRow = Database::fetch('posts', false, ['forum_id' => [$this->id, '=']], ['post_id', true]);
|
||||
// Get all rows with the forum id for this forum
|
||||
$threadRows = Database::fetch('topics', true, ['forum_id' => [$this->id, '=']]);
|
||||
|
||||
// Create a storage array
|
||||
$threads = [];
|
||||
|
||||
// Create new objects for each thread
|
||||
foreach ($threadRows as $thread) {
|
||||
$threads[$thread['topic_id']] = new Thread($thread['topic_id']);
|
||||
}
|
||||
|
||||
// Return the thread objects
|
||||
return $threads;
|
||||
}
|
||||
|
||||
// First post
|
||||
public function getFirstPost()
|
||||
{
|
||||
// Get the row
|
||||
$firstPost = Database::fetch('posts', false, ['forum_id' => [$this->id, '=']], ['post_id'], [1]);
|
||||
|
||||
// Create the post object
|
||||
$post = new Post(empty($firstPost) ? 0 : $firstPost['post_id']);
|
||||
|
||||
// Return the post object
|
||||
return $post;
|
||||
}
|
||||
|
||||
// Last post
|
||||
public function getLastPost()
|
||||
{
|
||||
// Get the row
|
||||
$lastPost = Database::fetch('posts', false, ['forum_id' => [$this->id, '=']], ['post_id', true], [1]);
|
||||
|
||||
// Create the post object
|
||||
$post = new Post(empty($lastPost) ? 0 : $lastPost['post_id']);
|
||||
|
||||
// Return the post object
|
||||
return $post;
|
||||
}
|
||||
|
||||
// Thread count
|
||||
public function threadCount()
|
||||
{
|
||||
return Database::count('topics', ['forum_id', [$this->id, '=']])[0];
|
||||
return Database::count('topics', ['forum_id' => [$this->id, '=']])[0];
|
||||
}
|
||||
|
||||
// Post count
|
||||
public function postCount()
|
||||
{
|
||||
return Database::count('posts', ['forum_id', [$this->id, '=']])[0];
|
||||
return Database::count('posts', ['forum_id' => [$this->id, '=']])[0];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,62 +23,6 @@ class Forums
|
|||
'forum_topics' => 0,
|
||||
];
|
||||
|
||||
// Getting the forum list
|
||||
public static function getForumList()
|
||||
{
|
||||
|
||||
// Get the content from the database
|
||||
$forums = Database::fetch('forums');
|
||||
|
||||
// Create return array
|
||||
$return = [
|
||||
0 => [
|
||||
'forum' => self::$emptyForum,
|
||||
'forums' => [],
|
||||
],
|
||||
];
|
||||
|
||||
// Resort the forums
|
||||
foreach ($forums as $forum) {
|
||||
// If the forum type is a category create a new one
|
||||
if ($forum['forum_type'] == 1) {
|
||||
$return[$forum['forum_id']]['forum'] = $forum;
|
||||
} else {
|
||||
// For link and reg. forum add it to the category
|
||||
$return[$forum['forum_category']]['forums'][$forum['forum_id']] = $forum;
|
||||
|
||||
// Get the topic count
|
||||
$return[$forum['forum_category']]['forums'][$forum['forum_id']]['topic_count'] =
|
||||
Database::count('topics', [
|
||||
'forum_id' => [$forum['forum_id'], '='],
|
||||
])[0];
|
||||
|
||||
// Get the post count
|
||||
$return[$forum['forum_category']]['forums'][$forum['forum_id']]['post_count'] =
|
||||
Database::count('posts', [
|
||||
'forum_id' => [$forum['forum_id'], '='],
|
||||
])[0];
|
||||
|
||||
// Get last post in forum
|
||||
$lastPost = Database::fetch('posts', false, [
|
||||
'forum_id' => [$forum['forum_id'], '='],
|
||||
], ['post_id', true]);
|
||||
|
||||
// Add last poster data and the details about the post as well
|
||||
$return[$forum['forum_category']]['forums'][$forum['forum_id']]['last_poster'] = new User($lastPost['poster_id']);
|
||||
|
||||
// Add last poster data and the details about the post as well
|
||||
$return[$forum['forum_category']]['forums'][$forum['forum_id']]['last_post'] = array_merge(
|
||||
empty($lastPost) ? [] : $lastPost,
|
||||
['elapsed' => Main::timeElapsed($lastPost['post_time'])]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Return the resorted data
|
||||
return $return;
|
||||
}
|
||||
|
||||
// Get a forum or category
|
||||
public static function getForum($id)
|
||||
{
|
||||
|
@ -138,50 +82,6 @@ class Forums
|
|||
return $forum;
|
||||
}
|
||||
|
||||
// Getting all topics from a forum
|
||||
public static function getTopics($id)
|
||||
{
|
||||
|
||||
// Get the topics from the database
|
||||
$topics = Database::fetch('topics', true, [
|
||||
'forum_id' => [$id, '='],
|
||||
]);
|
||||
|
||||
// Get the userdata related to last posts
|
||||
foreach ($topics as $key => $topic) {
|
||||
// Get the reply count
|
||||
$topics[$key]['reply_count'] = Database::count('posts', [
|
||||
'topic_id' => [$topic['topic_id'], '='],
|
||||
])[0];
|
||||
|
||||
// Get first post in topics
|
||||
$firstPost = Database::fetch('posts', false, [
|
||||
'topic_id' => [$topic['topic_id'], '='],
|
||||
]);
|
||||
|
||||
$topics[$key]['first_poster'] = new User($firstPost['poster_id']);
|
||||
|
||||
$topics[$key]['first_post'] = array_merge(
|
||||
empty($firstPost) ? [] : $firstPost,
|
||||
['elapsed' => Main::timeElapsed($firstPost['post_time'])]
|
||||
);
|
||||
|
||||
// Get last post in topics
|
||||
$lastPost = Database::fetch('posts', false, [
|
||||
'topic_id' => [$topic['topic_id'], '='],
|
||||
], ['post_id', true]);
|
||||
|
||||
$topics[$key]['last_poster'] = new User($lastPost['poster_id']);
|
||||
|
||||
$topics[$key]['last_post'] = array_merge(
|
||||
empty($lastPost) ? [] : $lastPost,
|
||||
['elapsed' => Main::timeElapsed($lastPost['post_time'])]
|
||||
);
|
||||
}
|
||||
|
||||
return $topics;
|
||||
}
|
||||
|
||||
// Get posts of a thread
|
||||
public static function getTopic($id, $ignoreView = false)
|
||||
{
|
||||
|
|
|
@ -690,7 +690,7 @@ class Main
|
|||
}
|
||||
|
||||
// Time elapsed
|
||||
public static function timeElapsed($timestamp, $append = ' ago', $none = 'Just now', $floor = false)
|
||||
public static function timeElapsed($timestamp, $append = ' ago', $none = 'Just now')
|
||||
{
|
||||
|
||||
// Subtract the entered timestamp from the current timestamp
|
||||
|
|
|
@ -23,6 +23,7 @@ class Post
|
|||
public $emotes = 0;
|
||||
public $subject = "";
|
||||
public $text = "";
|
||||
public $parsed = "";
|
||||
public $editTime = 0;
|
||||
public $editReason = "";
|
||||
public $editUser = [];
|
||||
|
@ -50,5 +51,20 @@ class Post
|
|||
$this->editReason = $postRow['post_edit_reason'];
|
||||
$this->editUser = new User($postRow['post_edit_user']);
|
||||
}
|
||||
|
||||
// Parse the markup
|
||||
$this->parsed = Forums::parseMarkUp($this->text, $this->parse, $this->emotes);
|
||||
}
|
||||
|
||||
// Time elapsed since creation
|
||||
public function timeElapsed()
|
||||
{
|
||||
return Main::timeElapsed($this->time);
|
||||
}
|
||||
|
||||
// Time elapsed since last edit
|
||||
public function editTimeElapsed()
|
||||
{
|
||||
return Main::timeElapsed($this->editTime);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@ class Thread
|
|||
public $status = 0;
|
||||
public $statusChange = 0;
|
||||
public $type = 0;
|
||||
public $firstPost = null;
|
||||
public $lastPost = null;
|
||||
public $posts = [];
|
||||
|
||||
// Constructor
|
||||
public function __construct($threadId)
|
||||
|
@ -42,11 +45,50 @@ class Thread
|
|||
$this->statusChange = $threadRow['topic_status_change'];
|
||||
$this->type = $threadRow['topic_type'];
|
||||
}
|
||||
|
||||
// Populate the posts array
|
||||
$this->posts = $this->getPosts();
|
||||
|
||||
// Get first post
|
||||
$this->firstPost = $this->posts ? array_values($this->posts)[0] : (new Thread(0));
|
||||
|
||||
// And the last post
|
||||
$this->lastPost = $this->posts ? end($this->posts) : (new Thread(0));
|
||||
}
|
||||
|
||||
// Posts
|
||||
public function getPosts()
|
||||
{
|
||||
// Get all rows with the thread id
|
||||
$postRows = Database::fetch('posts', true, ['topic_id' => [$this->id, '=']]);
|
||||
|
||||
// Create a storage array
|
||||
$posts = [];
|
||||
|
||||
// Create new post objects for each post
|
||||
foreach ($postRows as $post) {
|
||||
$posts[$post['post_id']] = new Post($post['post_id']);
|
||||
}
|
||||
|
||||
// Return the post objects
|
||||
return $posts;
|
||||
}
|
||||
|
||||
// Reply count
|
||||
public function replyCount()
|
||||
{
|
||||
return Database::count('posts', ['topic_id', [$this->id, '=']])[0];
|
||||
return Database::count('posts', ['topic_id' => [$this->id, '=']])[0];
|
||||
}
|
||||
|
||||
// Time elapsed since creation
|
||||
public function timeElapsed()
|
||||
{
|
||||
return Main::timeElapsed($this->time);
|
||||
}
|
||||
|
||||
// Time elapsed since status change
|
||||
public function statusChangeElapsed()
|
||||
{
|
||||
return Main::timeElapsed($this->statusChange);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Sakura;
|
||||
|
||||
// Define Sakura version
|
||||
define('SAKURA_VERSION', '20151113');
|
||||
define('SAKURA_VERSION', '20151115');
|
||||
define('SAKURA_VLABEL', 'Eminence');
|
||||
define('SAKURA_COLOUR', '#6C3082');
|
||||
define('SAKURA_STABLE', false);
|
||||
|
@ -152,6 +152,9 @@ if (!defined('SAKURA_NO_TPL')) {
|
|||
|
||||
'user' => $currentUser,
|
||||
'urls' => $urls,
|
||||
|
||||
'get' => $_GET,
|
||||
'post' => $_POST,
|
||||
];
|
||||
|
||||
// Site closing
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div id="indexPanel">
|
||||
{% if session.checkLogin %}
|
||||
<div class="head">Hi, {{ user.username }}!</div>
|
||||
<a href="{{ urls.format('SETTING_MODE', ['appearance', 'avatar']) }}"><img src="{{ urls.format('IMAGE_AVATAR', [user.id]) }}" class="default-avatar-setting homepage-menu-avatar" /></a>
|
||||
<a href="{{ urls.format('SETTING_MODE', ['appearance', 'avatar']) }}"><img src="{{ urls.format('IMAGE_AVATAR', [user.id]) }}" alt="{{ user.username }}" class="default-avatar-setting homepage-menu-avatar" /></a>
|
||||
<ul class="panelQuickLinks">
|
||||
<li><a href="{{ urls.format('SETTING_MODE', ['friends', 'requests']) }}" title="Pending friend requests"><span class="fa fa-user-plus"></span><span class="count">{{ user.friends(-1, true)|length }}</span></a></li>
|
||||
<li><a href="{{ urls.format('MESSAGES_INDEX') }}" title="View private messages"><span class="fa fa-envelope"></span><span class="count">0</span></a></li>
|
||||
|
|
|
@ -1,14 +1,23 @@
|
|||
<div class="head">Forums{% if board.viewforum %} / {{ board.forums[0].forum.forum_name }}{% endif %}</div>
|
||||
<table class="forumList">
|
||||
<tbody>
|
||||
{% for category in board.forums %}
|
||||
<div class="head">{{ title }}</div>
|
||||
<div class="forumList">
|
||||
{% for forum in forum.forums %}
|
||||
{% if forum.type == 1 %}
|
||||
{% if forum.forums|length %}
|
||||
<div class="forumCategory">
|
||||
{% if forum.type != 1 %}Subforums{% else %}<a href="{{ urls.format('FORUM_SUB', [forum.id]) }}" class="clean">{{ forum.name }}</a>{% endif %}
|
||||
</div>
|
||||
{% for forum in forum.forums %}
|
||||
{% include 'forum/forumEntry.tpl' %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% if board.viewforum and not board.forums[0].forum.forum_type %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% include 'forum/forumEntry.tpl' %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if not forum.type and forum.id > 0 %}
|
||||
{% include 'forum/forumBtns.tpl' %}
|
||||
{% if board.topics|length %}
|
||||
{% if board.threads|length %}
|
||||
<table class="topicList">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -29,7 +38,7 @@
|
|||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
{% for topic in board.topics[currentPage] %}
|
||||
{% for thread in board.threads[currentPage] %}
|
||||
{% include 'forum/topicEntry.tpl' %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<div class="buttonRow pagination">
|
||||
<div class="leftSide">
|
||||
<a href="{% if board.viewtopic %}{{ urls.format('FORUM_SUB', [topic.forum_id]) }}{% else %}{{ urls.format('FORUM_INDEX') }}{% endif %}" class="forumbtn"><span class="fa fa-backward"></span> Back</a>
|
||||
{% if board.viewtopic %}
|
||||
<a href="{{ urls.format('FORUM_REPLY', [topic.topic_id]) }}" class="forumbtn"><span class="fa fa-reply-all"></span> Reply</a>
|
||||
<a href="{% if thread %}{{ urls.format('FORUM_SUB', [forum.id]) }}{% else %}{{ urls.format('FORUM_INDEX') }}{% endif %}" class="forumbtn"><span class="fa fa-backward"></span> Back</a>
|
||||
{% if thread.id %}
|
||||
<a href="{{ urls.format('FORUM_REPLY', [thread.id]) }}" class="forumbtn"><span class="fa fa-reply-all"></span> Reply</a>
|
||||
{% endif %}
|
||||
{% if board.viewforum %}
|
||||
<a href="{{ urls.format('FORUM_NEW_THREAD', [board.forums[0].forum.forum_id]) }}" class="forumbtn"><span class="fa fa-pencil-square-o"></span> New Thread</a>
|
||||
{% if forum.id and not thread %}
|
||||
<a href="{{ urls.format('FORUM_NEW_THREAD', [forum.id]) }}" class="forumbtn"><span class="fa fa-pencil-square-o"></span> New Thread</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="rightSide">
|
||||
|
|
|
@ -1,42 +1,34 @@
|
|||
{% if category.forums|length and category.forum|length %}
|
||||
<tr class="forumCategory">
|
||||
<td class="forumCategoryTitleColumn" colspan="4">{% if category.forum.forum_type != 1 %}Subforums{% else %}<a href="{{ urls.format('FORUM_SUB', [category.forum.forum_id]) }}" class="clean">{{ category.forum.forum_name }}</a>{% endif %}</td>
|
||||
</tr>
|
||||
{% for forum in category.forums %}
|
||||
<tr class="forumForum">
|
||||
<td class="forumIconColumn">
|
||||
<div class="forumIcon read fa fa-3x {% if forum.forum_icon %}{{ forum.forum_icon }}{% else %}{% if forum.forum_type == 2 %}fa-chevron-circle-right{% elseif forum.forum_type == 1 %}fa-folder{% else %}fa-comments{% endif %}{% endif %}"></div>
|
||||
</td>
|
||||
<td class="forumTitleColumn"{% if forum.forum_type == 2 %} colspan="3"{% endif %}>
|
||||
<div class="name"><a href="{% if forum.forum_type == 2 %}{{ forum.forum_link }}{% else %}{{ urls.format('FORUM_SUB', [forum.forum_id]) }}{% endif %}" class="default">{{ forum.forum_name }}</a></div>
|
||||
<div class="forumForum">
|
||||
<div class="forumIcon read fa fa-3x {% if forum.icon %}{{ forum.icon }}{% else %}{% if forum.type == 2 %}fa-chevron-circle-right{% elseif forum.type == 1 %}fa-folder{% else %}fa-comments{% endif %}{% endif %}"></div>
|
||||
<div class="forumTitle">
|
||||
<div class="name"><a href="{% if forum.type == 2 %}{{ forum.link }}{% else %}{{ urls.format('FORUM_SUB', [forum.id]) }}{% endif %}" class="default">{{ forum.name }}</a></div>
|
||||
<div class="desc">
|
||||
{{ forum.forum_desc }}
|
||||
{% if board.forums[forum.forum_id]|length %}
|
||||
<div class="subforums" style="margin-top: 3px; margin-left: -5px; font-weight: bold;">
|
||||
{{ forum.description }}
|
||||
{% if forum.forums|length %}
|
||||
<div class="subforums">
|
||||
Subforums:
|
||||
{% for forum in board.forums[forum.forum_id].forums %}
|
||||
<a href="{% if forum.forum_type == 2 %}{{ forum.forum_link }}{% else %}{{ urls.format('FORUM_SUB', [forum.forum_id]) }}{% endif %}" class="default">{{ forum.forum_name }}</a>
|
||||
{% for forum in forum.forums %}
|
||||
<a href="{% if forum.type == 2 %}{{ forum.link }}{% else %}{{ urls.format('FORUM_SUB', [forum.id]) }}{% endif %}" class="default">{{ forum.name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
{% if forum.forum_type != 2 %}
|
||||
<td class="forumCountColumn">
|
||||
<div class="topics" title="Amount of topics in this forum.">{{ forum.topic_count }}</div>
|
||||
<div class="posts" title="Amount of posts in this forum.">{{ forum.post_count }}</div>
|
||||
</td>
|
||||
<td class="forumLastColumn">
|
||||
</div>
|
||||
{% if forum.type != 2 %}
|
||||
<div class="forumCount">
|
||||
<div class="topics" title="Amount of threads in this forum.">{{ forum.threadCount }}</div>
|
||||
<div class="posts" title="Amount of posts in this forum.">{{ forum.postCount }}</div>
|
||||
</div>
|
||||
<div class="forumLastPost">
|
||||
<div>
|
||||
{% if forum.last_post.post_id %}
|
||||
<a href="{{ urls.format('FORUM_THREAD', [forum.last_post.topic_id]) }}" class="default">{{ forum.last_post.post_subject }}</a><br />
|
||||
<span title="{{ forum.last_post.post_time|date(sakura.dateFormat) }}">{{ forum.last_post.elapsed }}</span> by {% if forum.last_poster.id %}<a href="{{ urls.format('USER_PROFILE', [forum.last_poster.id]) }}" class="default" style="color: {{ forum.last_poster.colour }}; text-shadow: 0 0 5px {% if forum.last_poster.colour != 'inherit' %}{{ forum.last_poster.colour }}{% else %}#222{% endif %};">{{ forum.last_poster.username }}</a>{% else %}[deleted user]{% endif %} <a href="{{ urls.format('FORUM_POST', [forum.last_post.post_id]) }}#p{{ forum.last_post.post_id }}" class="default fa fa-tag"></a>
|
||||
{% if forum.lastPost.id %}
|
||||
<a href="{{ urls.format('FORUM_THREAD', [forum.lastPost.id]) }}" class="default">{{ forum.lastPost.subject }}</a><br />
|
||||
<span title="{{ forum.lastPost.time|date(sakura.dateFormat) }}">{{ forum.lastPost.timeElapsed }}</span> by {% if forum.lastPost.poster.id %}<a href="{{ urls.format('USER_PROFILE', [forum.lastPost.poster.id]) }}" class="default" style="color: {{ forum.lastPost.poster.colour }}; text-shadow: 0 0 5px {% if forumlastPost.poster.colour != 'inherit' %}{{ forum.lastPost.poster.colour }}{% else %}#222{% endif %};">{{ forum.lastPost.poster.username }}</a>{% else %}[deleted user]{% endif %} <a href="{{ urls.format('FORUM_POST', [forum.lastPost.id]) }}#p{{ forum.lastPost.id }}" class="default fa fa-tag"></a>
|
||||
{% else %}
|
||||
There are no posts in this forum.<br />
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
{% extends 'global/master.tpl' %}
|
||||
|
||||
{% block title %}Forum Listing{% endblock %}
|
||||
{% set title = 'Forums' %}
|
||||
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="content homepage forum">
|
||||
|
@ -12,5 +14,8 @@
|
|||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script type="text/javascript" src="{{ sakura.resources }}/js/ybabstat.js"></script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
<tr>
|
||||
<td class="topicIcon read">
|
||||
<div class="fa fa-2x fa-{% if topic.topic_status == 1 %}lock{% elseif topic.topic_type == 2 %}exclamation{% elseif topic.topic_type == 1 %}thumb-tack{% else %}navicon{% endif %}"></div>
|
||||
<div class="fa fa-2x fa-{% if thread.status == 1 %}lock{% elseif thread.type == 2 %}exclamation{% elseif thread.type == 1 %}thumb-tack{% else %}navicon{% endif %}"></div>
|
||||
</td>
|
||||
<td class="topicTitle">
|
||||
<a href="{{ urls.format('FORUM_THREAD', [topic.topic_id]) }}" class="default">{{ topic.topic_title }}</a>
|
||||
<a href="{{ urls.format('FORUM_THREAD', [thread.id]) }}" class="default">{{ thread.title }}</a>
|
||||
</td>
|
||||
<td class="topicAuthor">
|
||||
{% if topic.first_poster.id %}
|
||||
<a href="{{ urls.format('USER_PROFILE', [topic.first_poster.id]) }}" class="default" style="color: {{ topic.first_poster.colour }}; text-shadow: 0 0 5px {% if topic.first_poster.colour != 'inherit' %}{{ topic.first_poster.colour }}{% else %}#222{% endif %};">{{ topic.first_poster.username }}</a>
|
||||
{% if thread.firstPost.poster.id %}
|
||||
<a href="{{ urls.format('USER_PROFILE', [thread.firstPost.poster.id]) }}" class="default" style="color: {{ thread.firstPost.poster.colour }}; text-shadow: 0 0 5px {% if thread.firstPost.poster.colour != 'inherit' %}{{ thread.firstPost.poster.colour }}{% else %}#222{% endif %};">{{ thread.firstPost.poster.username }}</a>
|
||||
{% else %}
|
||||
[deleted user]
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="topicCounts">
|
||||
<div class="replies" title="Amount of replies to this topic.">{{ topic.reply_count }}</div>
|
||||
<div class="views" title="Amount of times this topic has been viewed.">{{ topic.topic_views }}</div>
|
||||
<div class="replies" title="Amount of replies to this thread.">{{ thread.replyCount }}</div>
|
||||
<div class="views" title="Amount of times this thread has been viewed.">{{ thread.views }}</div>
|
||||
</td>
|
||||
<td class="topicLast">
|
||||
{% if topic.last_poster.id %}
|
||||
<a href="{{ urls.format('USER_PROFILE', [topic.last_poster.id]) }}" class="default" style="color: {{ topic.last_poster.colour }}; text-shadow: 0 0 5px {% if topic.last_poster.colour != 'inherit' %}{{ topic.last_poster.colour }}{% else %}#222{% endif %};">{{ topic.last_poster.username }}</a>
|
||||
{% if thread.lastPost.poster.id %}
|
||||
<a href="{{ urls.format('USER_PROFILE', [thread.lastPost.poster.id]) }}" class="default" style="color: {{ thread.lastPost.poster.colour }}; text-shadow: 0 0 5px {% if thread.lastPost.poster.colour != 'inherit' %}{{ thread.lastPost.poster.colour }}{% else %}#222{% endif %};">{{ thread.lastPost.poster.username }}</a>
|
||||
{% else %}
|
||||
[deleted user]
|
||||
{% endif %} <a href="{{ urls.format('FORUM_POST', [topic.last_post.post_id]) }}#p{{ topic.last_post.post_id }}" class="default fa fa-tag"></a><br />
|
||||
<span title="{{ topic.last_post.post.post_time|date(sakura.dateFormat) }}">{{ topic.last_post.elapsed }}</span>
|
||||
{% endif %} <a href="{{ urls.format('FORUM_POST', [thread.lastPost.id]) }}#p{{ thread.lastPost.id }}" class="default fa fa-tag"></a><br />
|
||||
<span title="{{ thread.lastPost.time|date(sakura.dateFormat) }}">{{ thread.lastPost.timeElapsed }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
{% extends 'global/master.tpl' %}
|
||||
|
||||
{% block title %}Forums / {{ board.forums[0].forum.forum_name }}{% endblock %}
|
||||
{% set title %}Forums / {{ forum.name }}{% endset %}
|
||||
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="content homepage forum viewforum">
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
{% extends 'global/master.tpl' %}
|
||||
|
||||
{% block title %}{{ topic.topic_title }}{% endblock %}
|
||||
{% block title %}{{ thread.title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="content homepage forum viewtopic">
|
||||
<div class="content-column">
|
||||
<div class="head">{{ forum.forum.forum_name }} / {{ topic.topic_title }}</div>
|
||||
<div class="head">{{ forum.name }} / {{ thread.title }}</div>
|
||||
{% include 'forum/forumBtns.tpl' %}
|
||||
<table class="posts">
|
||||
{% for post in posts[currentPage] %}
|
||||
<tr class="post" id="p{{ post.post_id }}">
|
||||
<tr class="post" id="p{{ post.id }}">
|
||||
<td class="userpanel">
|
||||
{% if not post.user.checkPermission('SITE', 'DEACTIVATED') or post.user.checkPermission('SITE', 'RESTRICTED') %}<a href="{{ urls.format('USER_PROFILE', [post.user.id]) }}" class="default username" style="color: {{ post.user.colour }}; text-shadow: 0 0 5px {% if post.user.colour != 'inherit' %}{{ post.user.colour }}{% else %}#222{% endif %};" title="Go to {{ post.user.username }}'s profile">{{ post.user.username }}</a>
|
||||
<img src="{{ urls.format('IMAGE_AVATAR', [post.user.id]) }}" alt="{{ post.user.username }}" class="avatar" style="box-shadow: 0 3px 7px #{% if post.user.checkOnline %}484{% else %}844{% endif %};" />
|
||||
{% if not post.poster.checkPermission('SITE', 'DEACTIVATED') or post.poster.checkPermission('SITE', 'RESTRICTED') %}<a href="{{ urls.format('USER_PROFILE', [post.poster.id]) }}" class="default username" style="color: {{ post.poster.colour }}; text-shadow: 0 0 5px {% if post.poster.colour != 'inherit' %}{{ post.poster.colour }}{% else %}#222{% endif %};" title="Go to {{ post.poster.username }}'s profile">{{ post.poster.username }}</a>
|
||||
<img src="{{ urls.format('IMAGE_AVATAR', [post.poster.id]) }}" alt="{{ post.poster.username }}" class="avatar" style="box-shadow: 0 3px 7px #{% if post.poster.isOnline %}484{% else %}844{% endif %};" />
|
||||
{% else %}
|
||||
<a class="username">[deleted user]</a>
|
||||
{% endif %}
|
||||
<div class="userdata">
|
||||
<div class="usertitle">{% if not post.user.userTitle %}{{ post.rank.title }}{% else %}{{ post.user.userTitle }}{% endif %}</div>
|
||||
<img src="{{ sakura.contentPath }}/images/tenshi.png" alt="Tenshi"{% if not post.user.isPremium[0] %} style="opacity: 0;"{% endif %} /> <img src="{{ sakura.contentPath }}/images/flags/{{ post.user.country.short|lower }}.png" alt="{{ post.user.country.long }}" />
|
||||
<div class="usertitle">{{ post.poster.userTitle }}</div>
|
||||
<img src="{{ sakura.contentPath }}/images/tenshi.png" alt="Tenshi"{% if not post.poster.isPremium[0] %} style="opacity: 0;"{% endif %} /> <img src="{{ sakura.contentPath }}/images/flags/{{ post.poster.country.short|lower }}.png" alt="{{ post.poster.country.long }}" />
|
||||
{% if session.checkLogin %}
|
||||
<div class="actions">
|
||||
{% if user.id == post.user.id %}
|
||||
<a class="fa fa-pencil-square-o" title="Edit this post" href="{{ urls.format('FORUM_EDIT_POST', [post.post_id]) }}"></a>
|
||||
<a class="fa fa-trash" title="Delete this post" href="{{ urls.format('FORUM_DELETE_POST', [post.post_id]) }}"></a>
|
||||
{% elseif not post.user.checkPermission('SITE', 'DEACTIVATED') or post.user.checkPermission('SITE', 'RESTRICTED') %}
|
||||
{% if user.isFriends(post.user.id) != 0 %}
|
||||
<a class="fa fa-{% if user.isFriends(post.user.id) == 2 %}heart{% else %}star{% endif %}" title="You are friends"></a>
|
||||
{% if user.id == post.poster.id %}
|
||||
<a class="fa fa-pencil-square-o" title="Edit this post" href="{{ urls.format('FORUM_EDIT_POST', [post.id]) }}"></a>
|
||||
<a class="fa fa-trash" title="Delete this post" href="{{ urls.format('FORUM_DELETE_POST', [post.id]) }}"></a>
|
||||
{% elseif not post.poster.checkPermission('SITE', 'DEACTIVATED') or post.poster.checkPermission('SITE', 'RESTRICTED') %}
|
||||
{% if user.isFriends(post.poster.id) != 0 %}
|
||||
<a class="fa fa-{% if user.isFriends(post.poster.id) == 2 %}heart{% else %}star{% endif %}" title="You are friends"></a>
|
||||
{% endif %}
|
||||
<a class="fa fa-user-{% if user.isFriends(post.user.id) == 0 %}plus{% else %}times{% endif %} forum-friend-toggle" title="{% if user.isFriends(post.user.id) == 0 %}Add {{ post.user.username }} as a friend{% else %}Remove friend{% endif %}" href="{% if user.isFriends(post.user.id) == 0 %}{{ urls.format('FRIEND_ADD', [post.user.id, php.sessionid, php.time, sakura.currentPage]) }}{% else %}{{ urls.format('FRIEND_REMOVE', [post.user.id, php.sessionid, php.time, sakura.currentPage]) }}{% endif %}"></a>
|
||||
<a class="fa fa-flag" title="Report {{ post.user.username }}" href="{{ urls.format('USER_REPORT', [post.user.id]) }}"></a>
|
||||
<a class="fa fa-user-{% if user.isFriends(post.poster.id) == 0 %}plus{% else %}times{% endif %} forum-friend-toggle" title="{% if user.isFriends(post.poster.id) == 0 %}Add {{ post.poster.username }} as a friend{% else %}Remove friend{% endif %}" href="{% if user.isFriends(post.poster.id) == 0 %}{{ urls.format('FRIEND_ADD', [post.poster.id, php.sessionid, php.time, sakura.currentPage]) }}{% else %}{{ urls.format('FRIEND_REMOVE', [post.poster.id, php.sessionid, php.time, sakura.currentPage]) }}{% endif %}"></a>
|
||||
<a class="fa fa-flag" title="Report {{ post.poster.username }}" href="{{ urls.format('USER_REPORT', [post.poster.id]) }}"></a>
|
||||
{% endif %}
|
||||
<a class="fa fa-reply" title="Quote this post" href="{{ urls.format('FORUM_QUOTE_POST', [post.post_id]) }}"></a>
|
||||
<a class="fa fa-reply" title="Quote this post" href="{{ urls.format('FORUM_QUOTE_POST', [post.id]) }}"></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@ -39,20 +39,20 @@
|
|||
<td class="post-content">
|
||||
<div class="details">
|
||||
<div class="subject">
|
||||
<a href="#p{{ post.post_id }}" class="clean">{{ post.post_subject }}</a>
|
||||
<a href="#p{{ post.id }}" class="clean">{{ post.subject }}</a>
|
||||
</div>
|
||||
<div class="date">
|
||||
<a href="{{ urls.format('FORUM_POST', [post.post_id]) }}#p{{ post.post_id }}" class="clean" title="{{ post.post_time|date(sakura.dateFormat) }}">{{ post.elapsed }}</a>
|
||||
<a href="{{ urls.format('FORUM_POST', [post.id]) }}#p{{ post.id }}" class="clean" title="{{ post.time|date(sakura.dateFormat) }}">{{ post.timeElapsed }}</a>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="post-text markdown">
|
||||
{{ post.parsed_post|raw }}
|
||||
{{ post.parsed|raw }}
|
||||
</div>
|
||||
{% if post.user.signature and post.post_signature %}
|
||||
{% if post.poster.signature and post.signature %}
|
||||
<div class="clear"></div>
|
||||
<div class="signature">
|
||||
{{ post.user.signature|raw|nl2br }}
|
||||
{{ post.poster.signature|raw|nl2br }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* Sakura Yuuno Stylesheet
|
||||
* By Flashwave <http://flash.moe>
|
||||
*/
|
||||
|
@ -1795,81 +1795,90 @@ textarea.inputStyling {
|
|||
* Forum Styling
|
||||
*/
|
||||
.forum .forumList {
|
||||
width: 100%;
|
||||
border-spacing: 0;
|
||||
margin-top: 2px;
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
}
|
||||
|
||||
.forum .forumList .forumCategory {
|
||||
background: #C2AFFE;
|
||||
font-weight: 700;
|
||||
font-size: 17px;
|
||||
padding: 4px;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.forum .forumList .forumCategory .forumCategoryTitleColumn {
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.forum .forumList .forumForum {
|
||||
height: 50px;
|
||||
display: inline-flex;
|
||||
min-height: 50px;
|
||||
}
|
||||
|
||||
.forum .forumList .forumForum .forumIconColumn {
|
||||
.forum .forumList .forumForum > div {
|
||||
display: inline-flex;
|
||||
flex-flow: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.forum .forumList .forumForum .forumIcon {
|
||||
text-align: center;
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
.forum .forumList .forumForum .forumIconColumn .forumIcon.read {
|
||||
line-height: 50px;
|
||||
flex-shrink: 0;
|
||||
color: #444;
|
||||
text-shadow: 0 0 5px #444;
|
||||
}
|
||||
|
||||
.forum .forumList .forumForum .forumIconColumn .forumIcon.unread {
|
||||
.forum .forumList .forumForum .forumIcon.unread {
|
||||
color: #6C5D7B;
|
||||
text-shadow: 0 0 5px #9475B2;
|
||||
}
|
||||
|
||||
.forum .forumList .forumForum .forumTitleColumn .name {
|
||||
.forum .forumList .forumForum .forumTitle {
|
||||
flex-grow: 1;
|
||||
flex-shrink: 1;
|
||||
}
|
||||
|
||||
.forum .forumList .forumForum .forumTitle .name {
|
||||
font-size: 1.2em;
|
||||
line-height: 1.7em;
|
||||
}
|
||||
|
||||
.forum .forumList .forumForum .forumTitleColumn .desc {
|
||||
.forum .forumList .forumForum .forumTitle .desc {
|
||||
font-size: .8em;
|
||||
line-height: 1em;
|
||||
}
|
||||
|
||||
.forum .forumList .forumForum .forumCountColumn {
|
||||
width: 70px;
|
||||
text-align: center;
|
||||
.forum .forumList .forumForum .forumTitle .desc .subforums {
|
||||
font-weight: bold;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
.forum .forumList .forumForum .forumCountColumn .topics {
|
||||
.forum .forumList .forumForum .forumCount {
|
||||
width: 70px;
|
||||
text-align: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.forum .forumList .forumForum .forumCount .topics {
|
||||
font-size: 1.5em;
|
||||
color: #111;
|
||||
}
|
||||
|
||||
.forum .forumList .forumForum .forumCountColumn .posts {
|
||||
.forum .forumList .forumForum .forumCount .posts {
|
||||
font-size: .8em;
|
||||
line-height: 1.2em;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.forum .forumList .forumForum .forumLastColumn {
|
||||
.forum .forumList .forumForum .forumLastPost {
|
||||
width: 250px;
|
||||
font-size: .9em;
|
||||
line-height: 1.4em;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.forum .forumList .forumForum .forumLastColumn div,
|
||||
.forum .forumList .forumForum .forumTitleColumn div {
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
@media (max-width: 512px) {
|
||||
.forum .forumList .forumForum .forumLastColumn {
|
||||
@media (max-width: 768px) {
|
||||
.forum .forumList .forumForum .forumLastPost {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,11 +50,7 @@ $renderData['news'] = ($forumMode ? null : (new News(Config::getConfig('site_new
|
|||
|
||||
$renderData['newsCount'] = Config::getConfig('front_page_news_posts');
|
||||
|
||||
$renderData['board'] = [
|
||||
'forums' => ($forumMode ? Forums::getForumList() : null),
|
||||
'viewforum' => false,
|
||||
'viewtopic' => false,
|
||||
];
|
||||
$renderData['forum'] = ($forumMode ? (new Forum()) : null);
|
||||
|
||||
$renderData['stats'] = [
|
||||
'userCount' => Database::count('users', ['password_algo' => ['nologin', '!='], 'rank_main' => ['1', '!=']])[0],
|
||||
|
|
|
@ -39,10 +39,10 @@ $posting = [
|
|||
// Check if we're in reply mode
|
||||
if ($mode != 'f') {
|
||||
// Attempt to get the topic
|
||||
$topic = Forums::getTopic($topicId, true);
|
||||
$thread = Forums::getTopic($topicId, true);
|
||||
|
||||
// Prompt an error if the topic doesn't exist
|
||||
if (!$topic) {
|
||||
if (!$thread) {
|
||||
// Add page specific things
|
||||
$renderData['page'] = [
|
||||
'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $urls->format('FORUM_INDEX')),
|
||||
|
@ -58,17 +58,17 @@ if ($mode != 'f') {
|
|||
}
|
||||
|
||||
// Check if we're in quote mode
|
||||
if ($mode == 'p' && isset($_GET['quote']) && $_GET['quote'] == $_GET['p'] && array_key_exists($_GET['p'], $topic['posts'])) {
|
||||
if ($mode == 'p' && isset($_GET['quote']) && $_GET['quote'] == $_GET['p'] && array_key_exists($_GET['p'], $thread['posts'])) {
|
||||
// Reassign post for ease
|
||||
$post = $topic['posts'][$_GET['p']];
|
||||
$post = $thread['posts'][$_GET['p']];
|
||||
|
||||
// Add subject to render data
|
||||
$posting['text'] = '[quote]' . $post['post_text'] . '[/quote]';
|
||||
|
||||
// Post editing
|
||||
} elseif ($mode == 'p' && isset($_GET['edit']) && $_GET['edit'] == $_GET['p'] && array_key_exists($_GET['p'], $topic['posts'])) {
|
||||
} elseif ($mode == 'p' && isset($_GET['edit']) && $_GET['edit'] == $_GET['p'] && array_key_exists($_GET['p'], $thread['posts'])) {
|
||||
// Checks
|
||||
if ($topic['posts'][$_GET['p']]['poster_id'] != $currentUser->id()) {
|
||||
if ($thread['posts'][$_GET['p']]['poster_id'] != $currentUser->id()) {
|
||||
// Add page specific things
|
||||
$renderData['page'] = [
|
||||
'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $urls->format('FORUM_INDEX')),
|
||||
|
@ -84,7 +84,7 @@ if ($mode != 'f') {
|
|||
}
|
||||
|
||||
// Reassign post for ease
|
||||
$post = $topic['posts'][$_GET['p']];
|
||||
$post = $thread['posts'][$_GET['p']];
|
||||
|
||||
// Set variables
|
||||
$posting = array_merge($posting, [
|
||||
|
@ -93,9 +93,9 @@ if ($mode != 'f') {
|
|||
'id' => $post['post_id'],
|
||||
]);
|
||||
// Post deletion
|
||||
} elseif ($mode == 'p' && isset($_GET['delete']) && $_GET['delete'] == $_GET['p'] && array_key_exists($_GET['p'], $topic['posts'])) {
|
||||
} elseif ($mode == 'p' && isset($_GET['delete']) && $_GET['delete'] == $_GET['p'] && array_key_exists($_GET['p'], $thread['posts'])) {
|
||||
// Checks
|
||||
if ($topic['posts'][$_GET['p']]['poster_id'] != $currentUser->id()) {
|
||||
if ($thread['posts'][$_GET['p']]['poster_id'] != $currentUser->id()) {
|
||||
// Add page specific things
|
||||
$renderData['page'] = [
|
||||
'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $urls->format('FORUM_INDEX')),
|
||||
|
@ -120,18 +120,18 @@ if ($mode != 'f') {
|
|||
]);
|
||||
|
||||
// Reload the topic
|
||||
$topic = Forums::getTopic($topicId, true);
|
||||
$thread = Forums::getTopic($topicId, true);
|
||||
|
||||
// If there's no more posts left in the topic delete it as well
|
||||
if (!count($topic['posts'])) {
|
||||
if (!count($thread['posts'])) {
|
||||
Database::delete('topics', [
|
||||
'topic_id' => [$topic['topic']['topic_id'], '='],
|
||||
'topic_id' => [$thread['topic']['topic_id'], '='],
|
||||
]);
|
||||
}
|
||||
|
||||
// Add page specific things
|
||||
$renderData['page'] = [
|
||||
'redirect' => (count($topic['posts']) ? $urls->format('FORUM_THREAD', [$topic['topic']['topic_id']]) : $urls->format('FORUM_INDEX')),
|
||||
'redirect' => (count($thread['posts']) ? $urls->format('FORUM_THREAD', [$thread['topic']['topic_id']]) : $urls->format('FORUM_INDEX')),
|
||||
'message' => 'Your post has been deleted!',
|
||||
];
|
||||
|
||||
|
@ -150,9 +150,9 @@ if ($mode != 'f') {
|
|||
|
||||
// Form mode
|
||||
$renderData = array_merge($renderData, [
|
||||
'message' => 'Are you sure you want to delete your reply to ' . $topic['topic']['topic_title'] . '?',
|
||||
'message' => 'Are you sure you want to delete your reply to ' . $thread['topic']['topic_title'] . '?',
|
||||
'conditions' => [
|
||||
'post_id' => $topic['posts'][$_GET['p']]['post_id'],
|
||||
'post_id' => $thread['posts'][$_GET['p']]['post_id'],
|
||||
],
|
||||
]);
|
||||
|
||||
|
@ -166,7 +166,7 @@ if ($mode != 'f') {
|
|||
|
||||
// Add subject to render data
|
||||
if (!isset($posting['subject'])) {
|
||||
$posting['subject'] = 'Re: ' . $topic['topic']['topic_title'];
|
||||
$posting['subject'] = 'Re: ' . $thread['topic']['topic_title'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Sakura;
|
|||
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . '_sakura/sakura.php';
|
||||
|
||||
// Get the forum's data
|
||||
$forum = Forums::getForum(isset($_GET['f']) ? $_GET['f'] : 0);
|
||||
$forum = new Forum(isset($_GET['f']) ? $_GET['f'] : -1);
|
||||
|
||||
// Initialise templating engine
|
||||
$template = new Template();
|
||||
|
@ -35,12 +35,12 @@ if (!$forum) {
|
|||
}
|
||||
|
||||
// Check if the forum isn't a link
|
||||
if ($forum['forum']['forum_type'] === 2) {
|
||||
if ($forum->type === 2) {
|
||||
// Set render data
|
||||
$renderData['page'] = [
|
||||
'title' => 'Information',
|
||||
'message' => 'The forum you tried to access is a link. You\'re being redirected.',
|
||||
'redirect' => $forum['forum']['forum_link'],
|
||||
'redirect' => $forum->link,
|
||||
];
|
||||
|
||||
// Set parse variables
|
||||
|
@ -51,13 +51,10 @@ if ($forum['forum']['forum_type'] === 2) {
|
|||
exit;
|
||||
}
|
||||
|
||||
$renderData['forum'] = $forum;
|
||||
|
||||
$renderData['board'] = [
|
||||
'forums' => [
|
||||
$forum,
|
||||
],
|
||||
'topics' => array_chunk($forum['topics'], 25, true),
|
||||
'viewforum' => true,
|
||||
'viewtopic' => false,
|
||||
'threads' => array_chunk($forum->threads, 25, true),
|
||||
];
|
||||
$renderData['currentPage'] = isset($_GET['page']) && ($_GET['page'] - 1) >= 0 ? $_GET['page'] - 1 : 0;
|
||||
|
||||
|
|
|
@ -9,13 +9,16 @@ namespace Sakura;
|
|||
// Include components
|
||||
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . '_sakura/sakura.php';
|
||||
|
||||
// Attempt to get a topic
|
||||
$topic = Forums::getTopic(
|
||||
// Attempt to get the thread
|
||||
$thread = new Thread(
|
||||
isset($_GET['p'])
|
||||
? Forums::getTopicIdFromPostId($_GET['p'])
|
||||
: (isset($_GET['t']) ? $_GET['t'] : 0)
|
||||
);
|
||||
|
||||
// And attempt to get the forum
|
||||
$forum = new Forum($thread->forum);
|
||||
|
||||
// Initialise templating engine
|
||||
$template = new Template();
|
||||
|
||||
|
@ -23,7 +26,7 @@ $template = new Template();
|
|||
$template->setTemplate($templateName);
|
||||
|
||||
// Check if the forum exists
|
||||
if (!$topic) {
|
||||
if (!$thread) {
|
||||
// Set render data
|
||||
$renderData['page'] = [
|
||||
'message' => 'The topic you tried to access does not exist.',
|
||||
|
@ -38,12 +41,10 @@ if (!$topic) {
|
|||
}
|
||||
|
||||
// Set additional render data
|
||||
$renderData = array_merge($renderData, $topic, [
|
||||
'board' => [
|
||||
'viewforum' => false,
|
||||
'viewtopic' => true,
|
||||
],
|
||||
'posts' => array_chunk($topic['posts'], 10, true),
|
||||
$renderData = array_merge($renderData, [
|
||||
'thread' => $thread,
|
||||
'forum' => $forum,
|
||||
'posts' => array_chunk($thread->posts, 10, true),
|
||||
'currentPage' => isset($_GET['page']) && ($_GET['page'] - 1) >= 0 ? $_GET['page'] - 1 : 0,
|
||||
]);
|
||||
|
||||
|
|
Reference in a new issue