r20151121

Signed-off-by: Flashwave <me@flash.moe>
This commit is contained in:
Pachira 2015-11-21 16:27:37 +01:00
parent 1dce050db0
commit e5a8c1131c
13 changed files with 107 additions and 22 deletions

View file

@ -80,7 +80,12 @@ class Forum
public function getThreads()
{
// Get all rows with the forum id for this forum
$threadRows = Database::fetch('topics', true, ['forum_id' => [$this->id, '=']], ['topic_last_reply', true]);
$announcements = Database::fetch('topics', true, ['forum_id' => [$this->id, '='], 'topic_type' => ['2', '=']], ['topic_last_reply', true]);
$sticky = Database::fetch('topics', true, ['forum_id' => [$this->id, '='], 'topic_type' => ['1', '=']], ['topic_last_reply', true]);
$regular = Database::fetch('topics', true, ['forum_id' => [$this->id, '='], 'topic_type' => ['0', '=']], ['topic_last_reply', true]);
// Combine them into one array
$threadRows = array_merge($announcements, $sticky, $regular);
// Create a storage array
$threads = [];
@ -135,6 +140,18 @@ class Forum
// Read status
public function unread($user)
{
// Return false if the user id is less than 1
if ($user < 1) {
return false;
}
// Check forums
foreach ($this->forums as $forum) {
if ($forum->unread($user)) {
return true;
}
}
// Check each thread
foreach ($this->threads as $thread) {
if ($thread->unread($user)) {
@ -145,4 +162,20 @@ class Forum
// Return false if negative
return false;
}
// Mark all threads as read
public function trackUpdateAll($user)
{
// Iterate over every forum
foreach ($this->forums as $forum) {
// Update every forum
$forum->trackUpdateAll($user);
}
// Iterate over every thread
foreach ($this->threads as $thread) {
// Update every thread
$thread->trackUpdate($user);
}
}
}

View file

@ -107,6 +107,10 @@ class Urls
'/viewforum.php?f=%u',
'/forum/%u',
],
'FORUM_MARK_READ' => [
'/viewforum.php?f=%u&read=true&session=%s',
'/forum/%u?read=true&session=%s',
],
'FORUM_THREAD' => [
'/viewtopic.php?t=%u',
'/forum/thread/%u',

View file

@ -8,7 +8,7 @@
namespace Sakura;
// Define Sakura version
define('SAKURA_VERSION', '20151120');
define('SAKURA_VERSION', '20151121');
define('SAKURA_VLABEL', 'Eminence');
define('SAKURA_COLOUR', '#6C3082');
define('SAKURA_STABLE', false);

View file

@ -4,17 +4,21 @@
<div class="pagination{% if paginationClass %} {{ paginationClass }}{% endif %}">
{% if paginationPages|length > 1 %}
{% if paginationPage > 1 %}
<a href="{{ paginationUrl }}{{ paginationSeparator }}page=1"><span class="fa fa-fast-backward"></span></a>
<a href="{{ paginationUrl }}{{ paginationSeparator }}page={{ paginationPage - 1 }}"><span class="fa fa-step-backward"></span></a>
{% if paginationPages|length > 2 %}
<a href="{{ paginationUrl }}{{ paginationSeparator }}page=1" title="Jump to first page"><span class="fa fa-fast-backward"></span></a>
{% endif %}
<a href="{{ paginationUrl }}{{ paginationSeparator }}page={{ paginationPage - 1 }}" title="Previous page"><span class="fa fa-step-backward"></span></a>
{% endif %}
{% for id,page in paginationPages %}
{% if (id + 1) > (paginationPage - 3) and (id + 1) < (paginationPage + 3) %}
<a href="{{ paginationUrl }}{{ paginationSeparator }}page={{ id + 1 }}"{% if id == paginationPage - 1 %} class="current"{% endif %}>{{ id + 1 }}</a>
<a href="{{ paginationUrl }}{{ paginationSeparator }}page={{ id + 1 }}"{% if id == paginationPage - 1 %} class="current"{% endif %} title="Page {{ id + 1 }}">{{ id + 1 }}</a>
{% endif %}
{% endfor %}
{% if paginationPage < paginationPages|length %}
<a href="{{ paginationUrl }}{{ paginationSeparator }}page={{ paginationPage + 1 }}"><span class="fa fa-step-forward"></span></a>
<a href="{{ paginationUrl }}{{ paginationSeparator }}page={{ paginationPages|length }}"><span class="fa fa-fast-forward"></span></a>
<a href="{{ paginationUrl }}{{ paginationSeparator }}page={{ paginationPage + 1 }}" title="Next page"><span class="fa fa-step-forward"></span></a>
{% if paginationPages|length > 2 %}
<a href="{{ paginationUrl }}{{ paginationSeparator }}page={{ paginationPages|length }}" title="Jump to last page"><span class="fa fa-fast-forward"></span></a>
{% endif %}
{% endif %}
{% endif %}
</div>

View file

@ -11,6 +11,9 @@
{% if forumNewLink %}
<a href="{{ forumNewLink }}" class="forumbtn"><span class="fa fa-pencil-square-o"></span> New Thread</a>
{% endif %}
{% if forumMarkRead %}
<a href="{{ forumMarkRead }}" class="forumbtn"><span class="fa fa-check-square-o"></span> Mark as Read</a>
{% endif %}
</div>
{% include 'elements/pagination.tpl' %}
<div class="clear"></div>

View file

@ -22,7 +22,7 @@
<div class="forumLastPost">
<div>
{% if forum.lastPost.id %}
<a href="{{ urls.format('FORUM_THREAD', [forum.lastPost.thread]) }}" class="default">{{ forum.lastPost.subject }}</a><br />
<a href="{{ urls.format('FORUM_THREAD', [forum.lastPost.thread]) }}" class="default">{{ forum.lastPost.subject|slice(0, 30) }}{% if forum.lastPost.subject|length > 30 %}...{% endif %}</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 />&nbsp;

View file

@ -4,6 +4,8 @@
{% block title %}{{ title }}{% endblock %}
{% set forumMarkRead %}{{ urls.format('FORUM_MARK_READ', [forum.id, php.sessionid]) }}{% endset %}
{% block content %}
<div class="content homepage forum">
<div class="content-right content-column">
@ -11,6 +13,7 @@
</div>
<div class="content-left content-column">
{% include 'forum/forum.tpl' %}
{% include 'forum/forumBtns.tpl' %}
</div>
<div class="clear"></div>
</div>

View file

@ -1,22 +1,22 @@
<tr>
<td class="topicIcon{% if thread.unread(user.id) %} unread{% endif %}">
<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 class="topicIcon{% if thread.unread(user.id) %} unread{% endif %}{% if thread.type == 2 %} topicAnnouncement{% endif %}">
<div class="fa fa-2x fa-{% if thread.type == 1 %}thumb-tack{% elseif thread.type == 2 %}exclamation{% elseif thread.status == 1 %}lock{% else %}navicon{% endif %}"></div>
</td>
<td class="topicTitle">
<td class="topicTitle{% if thread.type == 2 %} topicAnnouncement{% endif %}">
<a href="{{ urls.format('FORUM_THREAD', [thread.id]) }}" class="default">{{ thread.title }}</a>
</td>
<td class="topicAuthor">
<td class="topicAuthor{% if thread.type == 2 %} topicAnnouncement{% endif %}">
{% 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">
<td class="topicCounts{% if thread.type == 2 %} topicAnnouncement{% endif %}">
<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">
<td class="topicLast{% if thread.type == 2 %} topicAnnouncement{% endif %}">
{% 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 %}

View file

@ -4,6 +4,7 @@
{% set forumBackLink %}{{ urls.format('FORUM_INDEX') }}{% endset %}
{% set forumNewLink %}{{ urls.format('FORUM_NEW_THREAD', [forum.id]) }}{% endset %}
{% set forumMarkRead %}{{ urls.format('FORUM_MARK_READ', [forum.id, php.sessionid]) }}{% endset %}
{% block title %}{{ title }}{% endblock %}

View file

@ -6,7 +6,7 @@
{% include 'elements/indexPanel.tpl' %}
</div>
<div class="content-left content-column">
<div class="head">News <a href="{{ urls.format('SITE_NEWS_RSS') }}" class="fa fa-rss news-rss default"></a></div>
<div class="head">News <div class="links"><a href="{{ urls.format('SITE_NEWS_RSS') }}" class="fa fa-rss news-rss default"></a></div></div>
{% for post in news.posts|batch(newsCount)[0] %}
{% include 'elements/newsPost.tpl' %}
{% endfor %}

View file

@ -27,7 +27,7 @@
{% block content %}
<div class="content">
<div class="content-column news">
<div class="head">{{ title }}{% if not (viewPost and postExists) %}<a href="{{ urls.format('SITE_NEWS_RSS') }}" class="fa fa-rss news-rss default"></a>{% endif %}</div>
<div class="head">{{ title }}{% if not (viewPost and postExists) %}<div class="links"><a href="{{ urls.format('SITE_NEWS_RSS') }}" class="fa fa-rss news-rss default"></a></div>{% endif %}</div>
{% if (viewPost ? postExists : newsPosts|length) %}
{% for post in newsPosts %}
{% include 'elements/newsPost.tpl' %}

View file

@ -267,6 +267,7 @@ a.default:active {
color: #306;
background: linear-gradient(90deg, rgba(148, 117, 178, .7), rgba(148, 117, 178, 0)) #C2AFFE;
border-radius: 2px;
word-wrap: break-word;
}
.content-right .head,
@ -278,6 +279,11 @@ a.default:active {
color: #306;
background: linear-gradient(270deg, rgba(148, 117, 178, .7), rgba(148, 117, 178, 0)) #C2AFFE;
border-radius: 2px;
word-wrap: break-word;
}
.head > .links {
float: right;
}
.standalone {
@ -1170,10 +1176,6 @@ a.default:active {
text-decoration: none;
}
.news-rss {
float: right;
}
.news-body {
font-size: 10pt;
padding: 2px 0 0 3px;
@ -1887,6 +1889,7 @@ textarea.inputStyling {
width: 100%;
border-spacing: 0;
margin-top: 2px;
word-break: break-all;
}
.forum .topicList thead,
@ -1897,6 +1900,11 @@ textarea.inputStyling {
.forum .topicList tbody td {
height: 40px;
word-wrap: break-word;
}
.forum .topicList tbody .topicAnnouncement {
background: #C2AFFE;
}
.forum .topicList tbody .topicIcon {
@ -1940,10 +1948,13 @@ textarea.inputStyling {
.forum.viewtopic .posts {
width: 100%;
border-spacing: 0;
table-layout: fixed;
word-break: break-all;
}
.forum.viewtopic .posts td {
vertical-align: top;
word-wrap: break-word;
}
.forum.viewtopic .posts tr:not(:last-child) td {

View file

@ -19,11 +19,11 @@ $template = new Template();
$template->setTemplate($templateName);
// Check if the forum exists
if (!$forum) {
if ($forum->id < 0) {
// Set render data
$renderData['page'] = [
'title' => 'Information',
'message' => 'The subforum you tried to access does not exist.',
'message' => 'The forum you tried to access does not exist.',
];
// Set parse variables
@ -51,6 +51,32 @@ if ($forum->type === 2) {
exit;
}
// Check if we're marking as read
if (isset($_GET['read']) && $_GET['read'] && isset($_GET['session']) && $_GET['session'] == session_id()) {
// Run the function
$forum->trackUpdateAll($currentUser->id());
// Set render data
$renderData['page'] = [
'title' => 'Information',
'message' => 'All threads have been marked as read.',
'redirect' => $urls->format('FORUM_SUB', [$forum->id]),
];
// Set parse variables
$template->setVariables($renderData);
// Print page contents
echo $template->render('global/information.tpl');
exit;
}
// Redirect forum id 0 to the main page
if ($forum->id === 0) {
header('Location: ' . $urls->format('FORUM_INDEX'));
exit;
}
$renderData['forum'] = $forum;
// Set parse variables