r20151116
Signed-off-by: Flashwave <me@flash.moe>
This commit is contained in:
parent
1eb2f04f10
commit
bc36d74bba
12 changed files with 116 additions and 43 deletions
|
@ -78,7 +78,7 @@ class Forum
|
|||
public function getThreads()
|
||||
{
|
||||
// Get all rows with the forum id for this forum
|
||||
$threadRows = Database::fetch('topics', true, ['forum_id' => [$this->id, '=']]);
|
||||
$threadRows = Database::fetch('topics', true, ['forum_id' => [$this->id, '=']], ['topic_last_reply', true]);
|
||||
|
||||
// Create a storage array
|
||||
$threads = [];
|
||||
|
@ -129,4 +129,18 @@ class Forum
|
|||
{
|
||||
return Database::count('posts', ['forum_id' => [$this->id, '=']])[0];
|
||||
}
|
||||
|
||||
// Read status
|
||||
public function unread($user)
|
||||
{
|
||||
// Check each thread
|
||||
foreach ($this->threads as $thread) {
|
||||
if ($thread->unread($user)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Return false if negative
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -266,10 +266,8 @@ class Forums
|
|||
// Switch between modes
|
||||
switch ($mode) {
|
||||
case 1:
|
||||
return Main::bbParse($text);
|
||||
|
||||
case 2:
|
||||
return Main::mdParse($text);
|
||||
return Main::bbParse($text);
|
||||
|
||||
case 0:
|
||||
default:
|
||||
|
@ -340,6 +338,16 @@ class Forums
|
|||
'post_id' => [Database::lastInsertID(), '='],
|
||||
]);
|
||||
|
||||
// Update the topic with the last details
|
||||
Database::update('topics', [
|
||||
[
|
||||
'topic_last_reply' => time(),
|
||||
],
|
||||
[
|
||||
'topic_id' => [$getPost['topic_id'], '='],
|
||||
],
|
||||
]);
|
||||
|
||||
// Return success
|
||||
return [1, 'SUCCESS', $getPost['forum_id'], $getPost['topic_id'], $getPost['post_id']];
|
||||
}
|
||||
|
|
|
@ -53,7 +53,8 @@ class Post
|
|||
}
|
||||
|
||||
// Parse the markup
|
||||
$this->parsed = Forums::parseMarkUp($this->text, $this->parse, $this->emotes);
|
||||
$this->parsed = $this->parse ? Main::bbParse($this->text) : $this->text;
|
||||
$this->parsed = $this->emotes ? Main::parseEmotes($this->parsed) : $this->parsed;
|
||||
}
|
||||
|
||||
// Time elapsed since creation
|
||||
|
|
|
@ -91,4 +91,65 @@ class Thread
|
|||
{
|
||||
return Main::timeElapsed($this->statusChange);
|
||||
}
|
||||
|
||||
// Read status
|
||||
public function unread($user)
|
||||
{
|
||||
// Attempt to get track row from the database
|
||||
$track = Database::fetch('topics_track', false, ['user_id' => [$user, '='], 'topic_id' => [$this->id, '=']]);
|
||||
|
||||
// If nothing was returned it's obvious that the status is unread
|
||||
if (!$track) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the last time the user has been here is less than the creation timestamp of the latest post
|
||||
if ($track['mark_time'] < $this->lastPost->time) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Else just return false meaning everything is read
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update read status
|
||||
public function trackUpdate($user)
|
||||
{
|
||||
// Check if we already have a track record
|
||||
$track = Database::fetch('topics_track', false, ['user_id' => [$user, '='], 'topic_id' => [$this->id, '='], 'forum_id' => [$this->forum, '=']]);
|
||||
|
||||
// If so update it
|
||||
if ($track) {
|
||||
Database::update('topics_track', [
|
||||
[
|
||||
'mark_time' => time(),
|
||||
],
|
||||
[
|
||||
'user_id' => [$user, '='],
|
||||
'topic_id' => [$this->id, '='],
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
// If not create a new record
|
||||
Database::insert('topics_track', [
|
||||
'user_id' => $user,
|
||||
'topic_id' => $this->id,
|
||||
'forum_id' => $this->forum,
|
||||
'mark_time' => time(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// Update views
|
||||
public function viewsUpdate()
|
||||
{
|
||||
Database::update('topics', [
|
||||
[
|
||||
'topic_views' => $this->views + 1,
|
||||
],
|
||||
[
|
||||
'topic_id' => [$this->id, '='],
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Sakura;
|
||||
|
||||
// Define Sakura version
|
||||
define('SAKURA_VERSION', '20151115');
|
||||
define('SAKURA_VERSION', '20151116');
|
||||
define('SAKURA_VLABEL', 'Eminence');
|
||||
define('SAKURA_COLOUR', '#6C3082');
|
||||
define('SAKURA_STABLE', false);
|
||||
|
|
|
@ -2,13 +2,19 @@
|
|||
{% set paginationPage = get.page|default(1) %}
|
||||
|
||||
<div class="pagination{% if paginationClass %} {{ paginationClass }}{% endif %}">
|
||||
{% if paginationPage > 1 %}
|
||||
<a href="{{ paginationUrl }}{{ paginationSeparator }}page={{ paginationPage - 1 }}"><span class="fa fa-step-backward"></span></a>
|
||||
{% endif %}
|
||||
{% for id,page in paginationPages %}
|
||||
<a href="{{ paginationUrl }}{{ paginationSeparator }}page={{ id + 1 }}"{% if id == paginationPage - 1 %} class="current"{% endif %}>{{ id + 1 }}</a>
|
||||
{% endfor %}
|
||||
{% if paginationPage < paginationPages|length %}
|
||||
<a href="{{ paginationUrl }}{{ paginationSeparator }}page={{ paginationPage + 1 }}"><span class="fa fa-step-forward"></span></a>
|
||||
{% 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>
|
||||
{% 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>
|
||||
{% 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>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<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="forumIcon {% if forum.unread(user.id) %}unread {% endif %}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">
|
||||
|
|
|
@ -41,14 +41,9 @@
|
|||
<div>
|
||||
<input type="checkbox" id="enableEmotes" checked="checked" /> <label for="enableEmotes">Parse emoticons</label>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="parseMode">Parsing Mode:</label>
|
||||
<select id="parseMode" name="parseMode">
|
||||
<option value="0">None</option>
|
||||
<option value="1" selected="selected">BBCode</option>
|
||||
<option value="2">Markdown</option>
|
||||
</select>
|
||||
<div>
|
||||
<input type="checkbox" id="enableBBcode" checked="checked" /> <label for="enableBBcode">Parse BBcodes</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<tr>
|
||||
<td class="topicIcon read">
|
||||
<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>
|
||||
<td class="topicTitle">
|
||||
|
|
|
@ -1902,9 +1902,6 @@ textarea.inputStyling {
|
|||
.forum .topicList tbody .topicIcon {
|
||||
width: 40px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.forum .topicList tbody .topicIcon.read {
|
||||
color: #444;
|
||||
text-shadow: 0 0 5px #444;
|
||||
}
|
||||
|
|
|
@ -172,23 +172,8 @@ if ($mode != 'f') {
|
|||
|
||||
// Check if a post is being made
|
||||
if (isset($_POST['post'])) {
|
||||
// Set post mode
|
||||
switch ($_POST['parseMode']) {
|
||||
// BBcode
|
||||
case '1':
|
||||
$parse = '1';
|
||||
break;
|
||||
// Markdown
|
||||
case '2':
|
||||
$parse = '2';
|
||||
break;
|
||||
// Raw
|
||||
default:
|
||||
$parse = '0';
|
||||
}
|
||||
|
||||
// Attempt to make the post
|
||||
$makePost = Forums::createPost($currentUser->id(), $_POST['subject'], $_POST['text'], $forumId, $topicId, $parse, 1, 1);
|
||||
$makePost = Forums::createPost($currentUser->id(), $_POST['subject'], $_POST['text'], $forumId, $topicId, 1, 1, 1);
|
||||
|
||||
// Add page specific things
|
||||
$renderData['page'] = [
|
||||
|
|
|
@ -40,6 +40,12 @@ if (!$thread) {
|
|||
exit;
|
||||
}
|
||||
|
||||
// Update the tracking status
|
||||
$thread->trackUpdate($currentUser->id());
|
||||
|
||||
// Update views
|
||||
$thread->viewsUpdate();
|
||||
|
||||
// Set additional render data
|
||||
$renderData = array_merge($renderData, [
|
||||
'thread' => $thread,
|
||||
|
|
Reference in a new issue