From e5a8c1131c1db107e9ad31962ead0491ac8c8205 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sat, 21 Nov 2015 16:27:37 +0100 Subject: [PATCH] r20151121 Signed-off-by: Flashwave --- _sakura/components/Forum.php | 35 ++++++++++++++++++- _sakura/components/Urls.php | 4 +++ _sakura/sakura.php | 2 +- .../templates/yuuno/elements/pagination.tpl | 14 +++++--- _sakura/templates/yuuno/forum/forumBtns.tpl | 3 ++ _sakura/templates/yuuno/forum/forumEntry.tpl | 2 +- _sakura/templates/yuuno/forum/index.tpl | 3 ++ _sakura/templates/yuuno/forum/topicEntry.tpl | 12 +++---- _sakura/templates/yuuno/forum/viewforum.tpl | 1 + _sakura/templates/yuuno/main/index.tpl | 2 +- _sakura/templates/yuuno/main/news.tpl | 2 +- public/content/data/yuuno/css/yuuno.css | 19 +++++++--- public/viewforum.php | 30 ++++++++++++++-- 13 files changed, 107 insertions(+), 22 deletions(-) diff --git a/_sakura/components/Forum.php b/_sakura/components/Forum.php index 2163551..7546f8a 100644 --- a/_sakura/components/Forum.php +++ b/_sakura/components/Forum.php @@ -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); + } + } } diff --git a/_sakura/components/Urls.php b/_sakura/components/Urls.php index fc118e1..07be2c1 100755 --- a/_sakura/components/Urls.php +++ b/_sakura/components/Urls.php @@ -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', diff --git a/_sakura/sakura.php b/_sakura/sakura.php index 355ae31..7eaf446 100755 --- a/_sakura/sakura.php +++ b/_sakura/sakura.php @@ -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); diff --git a/_sakura/templates/yuuno/elements/pagination.tpl b/_sakura/templates/yuuno/elements/pagination.tpl index 54a3ba8..54fbf66 100755 --- a/_sakura/templates/yuuno/elements/pagination.tpl +++ b/_sakura/templates/yuuno/elements/pagination.tpl @@ -4,17 +4,21 @@
{% if paginationPages|length > 1 %} {% if paginationPage > 1 %} - - + {% if paginationPages|length > 2 %} + + {% endif %} + {% endif %} {% for id,page in paginationPages %} {% if (id + 1) > (paginationPage - 3) and (id + 1) < (paginationPage + 3) %} - {{ id + 1 }} + {{ id + 1 }} {% endif %} {% endfor %} {% if paginationPage < paginationPages|length %} - - + + {% if paginationPages|length > 2 %} + + {% endif %} {% endif %} {% endif %}
diff --git a/_sakura/templates/yuuno/forum/forumBtns.tpl b/_sakura/templates/yuuno/forum/forumBtns.tpl index 631e057..252afa7 100755 --- a/_sakura/templates/yuuno/forum/forumBtns.tpl +++ b/_sakura/templates/yuuno/forum/forumBtns.tpl @@ -11,6 +11,9 @@ {% if forumNewLink %} New Thread {% endif %} + {% if forumMarkRead %} + Mark as Read + {% endif %} {% include 'elements/pagination.tpl' %}
diff --git a/_sakura/templates/yuuno/forum/forumEntry.tpl b/_sakura/templates/yuuno/forum/forumEntry.tpl index 1f6356b..e9bf5f8 100755 --- a/_sakura/templates/yuuno/forum/forumEntry.tpl +++ b/_sakura/templates/yuuno/forum/forumEntry.tpl @@ -22,7 +22,7 @@
{% if forum.lastPost.id %} - {{ forum.lastPost.subject }}
+ {{ forum.lastPost.subject|slice(0, 30) }}{% if forum.lastPost.subject|length > 30 %}...{% endif %}
{{ forum.lastPost.timeElapsed }} by {% if forum.lastPost.poster.id %}{{ forum.lastPost.poster.username }}{% else %}[deleted user]{% endif %} {% else %} There are no posts in this forum.
  diff --git a/_sakura/templates/yuuno/forum/index.tpl b/_sakura/templates/yuuno/forum/index.tpl index c6b77a7..4f89f41 100755 --- a/_sakura/templates/yuuno/forum/index.tpl +++ b/_sakura/templates/yuuno/forum/index.tpl @@ -4,6 +4,8 @@ {% block title %}{{ title }}{% endblock %} +{% set forumMarkRead %}{{ urls.format('FORUM_MARK_READ', [forum.id, php.sessionid]) }}{% endset %} + {% block content %}
@@ -11,6 +13,7 @@
{% include 'forum/forum.tpl' %} + {% include 'forum/forumBtns.tpl' %}
diff --git a/_sakura/templates/yuuno/forum/topicEntry.tpl b/_sakura/templates/yuuno/forum/topicEntry.tpl index 6fc8f21..bb6bfa2 100755 --- a/_sakura/templates/yuuno/forum/topicEntry.tpl +++ b/_sakura/templates/yuuno/forum/topicEntry.tpl @@ -1,22 +1,22 @@ - -
+ +
- + {{ thread.title }} - + {% if thread.firstPost.poster.id %} {{ thread.firstPost.poster.username }} {% else %} [deleted user] {% endif %} - +
{{ thread.replyCount }}
{{ thread.views }}
- + {% if thread.lastPost.poster.id %} {{ thread.lastPost.poster.username }} {% else %} diff --git a/_sakura/templates/yuuno/forum/viewforum.tpl b/_sakura/templates/yuuno/forum/viewforum.tpl index 33adaca..33ec749 100755 --- a/_sakura/templates/yuuno/forum/viewforum.tpl +++ b/_sakura/templates/yuuno/forum/viewforum.tpl @@ -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 %} diff --git a/_sakura/templates/yuuno/main/index.tpl b/_sakura/templates/yuuno/main/index.tpl index 5821829..501cd37 100755 --- a/_sakura/templates/yuuno/main/index.tpl +++ b/_sakura/templates/yuuno/main/index.tpl @@ -6,7 +6,7 @@ {% include 'elements/indexPanel.tpl' %}
-
News
+
News
{% for post in news.posts|batch(newsCount)[0] %} {% include 'elements/newsPost.tpl' %} {% endfor %} diff --git a/_sakura/templates/yuuno/main/news.tpl b/_sakura/templates/yuuno/main/news.tpl index 77b07dc..5379520 100755 --- a/_sakura/templates/yuuno/main/news.tpl +++ b/_sakura/templates/yuuno/main/news.tpl @@ -27,7 +27,7 @@ {% block content %}
-
{{ title }}{% if not (viewPost and postExists) %}{% endif %}
+
{{ title }}{% if not (viewPost and postExists) %}{% endif %}
{% if (viewPost ? postExists : newsPosts|length) %} {% for post in newsPosts %} {% include 'elements/newsPost.tpl' %} diff --git a/public/content/data/yuuno/css/yuuno.css b/public/content/data/yuuno/css/yuuno.css index 579a0bd..f8bb43e 100755 --- a/public/content/data/yuuno/css/yuuno.css +++ b/public/content/data/yuuno/css/yuuno.css @@ -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 { diff --git a/public/viewforum.php b/public/viewforum.php index c96ca83..296521f 100755 --- a/public/viewforum.php +++ b/public/viewforum.php @@ -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