r20151115.1

part 2 as promised

Signed-off-by: Flashwave <me@flash.moe>
This commit is contained in:
flash 2015-11-15 22:43:39 +01:00
parent e49dcf84c8
commit 1eb2f04f10
23 changed files with 187 additions and 216 deletions

View file

@ -82,6 +82,50 @@ 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)
{

View file

@ -11,7 +11,7 @@ namespace Sakura;
*/
class News
{
private $posts = []; // Posts array
public $posts = []; // Posts array
private $posters = []; // Posters array (so we don't create a new user object every time)
// Initialise the news object
@ -54,29 +54,4 @@ class News
{
return array_key_exists($pid, $this->posts) ? $pid : 0;
}
// Get a single post
public function getPost($pid)
{
return array_key_exists($pid, $this->posts) ? $this->posts[$pid] : 0;
}
// Getting posts
public function getPosts($start = null, $end = null)
{
// Get posts
$posts = $this->posts;
// Only return requested posts
if ($start !== null && $end !== null) {
// Slice the array
$posts = array_slice($posts, $start, $end, true);
} elseif ($start !== null) {
// Devide the array in parts (pages)
$posts = array_chunk($posts, $start, true);
}
return $posts;
}
}

View file

@ -23,10 +23,6 @@ class Urls
'/news.php',
'/news',
],
'SITE_NEWS_PAGE' => [
'/news.php?page=%u',
'/news/p%u',
],
'SITE_NEWS_POST' => [
'/news.php?id=%u',
'/news/%u',
@ -47,10 +43,6 @@ class Urls
'/support.php?tracker=true',
'/support/tracker',
],
'SITE_DONATE_TRACK_PAGE' => [
'/support.php?tracker=true&page=%u',
'/support/tracker/%u',
],
'SITE_FAQ' => [
'/faq.php',
'/faq',
@ -99,23 +91,11 @@ class Urls
],
'MEMBERLIST_PAGE' => [
'/members.php?page=%u',
'/members/p%u',
],
'MEMBERLIST_SORT_RANK' => [
'/members.php?sort=%s&rank=%u',
'/members/%s/%u',
],
'MEMBERLIST_RANK_PAGE' => [
'/members.php?rank=%u&page=%u',
'/members/%u/p%u',
],
'MEMBERLIST_SORT_PAGE' => [
'/members.php?sort=%s&page=%u',
'/members/%s/p%u',
'/members?page=%u',
],
'MEMBERLIST_ALL' => [
'/members.php?sort=%s&rank=%u&page=%u',
'/members/%s/%u/p%u',
'/members.php?sort=%s&rank=%u',
'/members/%s/%u',
],
// Forums
@ -221,10 +201,6 @@ class Urls
'/settings.php?cat=%s&mode=%s',
'/settings/%s/%s',
],
'SETTING_PAGE' => [
'/settings.php?cat=%s&mode=%s&page=%u',
'/settings/%s/%s/p%u',
],
'REQUEST_NOTIFICATIONS' => [
'/settings.php?request-notifications=true',
'/notifications',

View file

@ -1,11 +1,14 @@
<div class="pagination">
{% if pagination.page > 0 %}
<a href="{{ urls.format(pagination.urlPattern, [pagination.page]) }}"><span class="fa fa-step-backward"></span></a>
{% set paginationSeparator %}{% if '?' in pagination.page %}&amp;{% else %}?{% endif %}{% endset %}
{% 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 pagination.pages %}
<a href="{{ urls.format(pagination.urlPattern, [(id + 1)]) }}"{% if id == pagination.page %} class="current"{% endif %}>{{ id + 1 }}</a>
{% for id,page in paginationPages %}
<a href="{{ paginationUrl }}{{ paginationSeparator }}page={{ id + 1 }}"{% if id == paginationPage - 1 %} class="current"{% endif %}>{{ id + 1 }}</a>
{% endfor %}
{% if pagination.page + 1 < pagination.pages|length %}
<a href="{{ urls.format(pagination.urlPattern, [(pagination.page + 2)]) }}"><span class="fa fa-step-forward"></span></a>
{% if paginationPage < paginationPages|length %}
<a href="{{ paginationUrl }}{{ paginationSeparator }}page={{ paginationPage + 1 }}"><span class="fa fa-step-forward"></span></a>
{% endif %}
</div>

View file

@ -16,8 +16,13 @@
{% endfor %}
</div>
{% if not forum.type and forum.id > 0 %}
{% set threads = forum.threads|batch(25) %}
{% set paginationPages = threads %}
{% set paginationUrl %}{{ urls.format('FORUM_SUB', [forum.id]) }}{% endset %}
{% include 'forum/forumBtns.tpl' %}
{% if board.threads|length %}
{% if forum.threads %}
<table class="topicList">
<thead>
<tr>
@ -38,7 +43,7 @@
</tr>
</tfoot>
<tbody>
{% for thread in board.threads[currentPage] %}
{% for thread in threads[get.page|default(1) - 1] %}
{% include 'forum/topicEntry.tpl' %}
{% endfor %}
</tbody>

View file

@ -1,21 +1,17 @@
{% set paginationClass = 'rightSide' %}
<div class="buttonRow pagination">
<div class="leftSide">
<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>
{% if forumBackLink %}
<a href="{{ forumBackLink }}" class="forumbtn"><span class="fa fa-backward"></span> Back</a>
{% endif %}
{% 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>
{% if forumReplyLink %}
<a href="{{ forumReplyLink }}" class="forumbtn"><span class="fa fa-reply-all"></span> Reply</a>
{% endif %}
{% if forumNewLink %}
<a href="{{ forumNewLink }}" class="forumbtn"><span class="fa fa-pencil-square-o"></span> New Thread</a>
{% endif %}
</div>
<div class="rightSide">
<a href="#" class="forumbtn"><span class="fa fa-step-backward"></span></a>
<a href="#" class="forumbtn">1</a>
<a href="#" class="forumbtn">2</a>
<a href="#" class="forumbtn">3</a>
...
<a href="#" class="forumbtn">10</a>
<a href="#" class="forumbtn"><span class="fa fa-step-forward"></span></a>
</div>
{% include 'elements/pagination.tpl' %}
<div class="clear"></div>
</div>

View file

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

View file

@ -2,6 +2,9 @@
{% set title %}Forums / {{ forum.name }}{% endset %}
{% set forumBackLink %}{{ urls.format('FORUM_INDEX') }}{% endset %}
{% set forumNewLink %}{{ urls.format('FORUM_NEW_THREAD', [forum.id]) }}{% endset %}
{% block title %}{{ title }}{% endblock %}
{% block content %}

View file

@ -1,5 +1,13 @@
{% extends 'global/master.tpl' %}
{% set forumBackLink %}{{ urls.format('FORUM_SUB', [forum.id]) }}{% endset %}
{% set forumReplyLink %}{{ urls.format('FORUM_REPLY', [thread.id]) }}{% endset %}
{% set posts = thread.posts|batch(10) %}
{% set paginationPages = posts %}
{% set paginationUrl %}{{ urls.format('FORUM_THREAD', [thread.id]) }}{% endset %}
{% block title %}{{ thread.title }}{% endblock %}
{% block content %}
@ -8,7 +16,7 @@
<div class="head">{{ forum.name }} / {{ thread.title }}</div>
{% include 'forum/forumBtns.tpl' %}
<table class="posts">
{% for post in posts[currentPage] %}
{% for post in posts[get.page|default(1) - 1] %}
<tr class="post" id="p{{ post.id }}">
<td class="userpanel">
{% 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>

View file

@ -7,7 +7,7 @@
</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>
{% for post in news.getPosts(0, newsCount) %}
{% for post in news.posts|batch(newsCount)[0] %}
{% include 'elements/newsPost.tpl' %}
{% endfor %}
</div>

View file

@ -8,6 +8,13 @@
{% if page.notfound %}The requested rank could not be found!{% else %}{% if not page.active %}The entire user list.{% else %}{{ page.ranks[page.active].description }}{% endif %}{% endif %}
{% endset %}
{% set users = users|batch(membersPerPage) %}
{% set currPage = get.page|default(1) - 1 %}
{% set paginationPages = users %}
{% set paginationUrl %}{% if page.sort and page.active %}{{ urls.format('MEMBERLIST_ALL', [page.sort, page.active]) }}{% elseif page.sort %}{{ urls.format('MEMBERLIST_SORT', [page.sort]) }}{% elseif page.active %}{{ urls.format('MEMBERLIST_RANK', [page.active]) }}{% else %}{{ urls.format('MEMBERLIST_INDEX') }}{% endif %}{% endset %}
{% block title %}{{ rankTitle }}{% endblock %}
{% block content %}
@ -19,21 +26,21 @@
<div class="dropDown" style="margin: 0 auto; font-size: 1.5em; line-height: 1.5em; height: 30px;">
<div class="dropDownInner" style="float: left; color: #FFF;">
<a class="dropDownDesc">Rank:</a>
<a href="{% if page.page and page.sort %}{{ urls.format('MEMBERLIST_SORT_PAGE', [page.sort, (page.page + 1)]) }}{% elseif page.sort %}{{ urls.format('MEMBERLIST_SORT', [page.sort]) }}{% elseif page.page %}{{ urls.format('MEMBERLIST_PAGE', [(page.page + 1)]) }}{% else %}{{ urls.format('MEMBERLIST_INDEX') }}{% endif %}"{% if not page.active %} class="dropDownSelected"{% endif %}>All members</a>
<a href="{% if page.sort %}{{ urls.format('MEMBERLIST_SORT', [page.sort]) }}{% else %}{{ urls.format('MEMBERLIST_INDEX') }}{% endif %}"{% if not page.active %} class="dropDownSelected"{% endif %}>All members</a>
{% for rank in page.ranks %}
{% if not rank.hidden or (rank.hidden and page.active == rank.id) %}
<a href="{% if page.sort %}{{ urls.format('MEMBERLIST_SORT_RANK', [page.sort, rank.id]) }}{% else %}{{ urls.format('MEMBERLIST_RANK', [rank.id]) }}{% endif %}" style="color: {{ rank.colour }};"{% if page.active == rank.id %} class="dropDownSelected"{% endif %}>{{ rank.name(true) }}</a>
<a href="{% if page.sort %}{{ urls.format('MEMBERLIST_ALL', [page.sort, rank.id]) }}{% else %}{{ urls.format('MEMBERLIST_RANK', [rank.id]) }}{% endif %}" style="color: {{ rank.colour }};"{% if page.active == rank.id %} class="dropDownSelected"{% endif %}>{{ rank.name(true) }}</a>
{% endif %}
{% endfor %}
</div>
<div class="dropDownInner" style="float: left;">
<a class="dropDownDesc">View:</a>
{% for sort in page.sorts %}
<a href="{% if page.active and page.page %}{{ urls.format('MEMBERLIST_ALL', [sort, page.active, (page.page + 1)]) }}{% elseif page.active %}{{ urls.format('MEMBERLIST_SORT_RANK', [sort, page.active]) }}{% elseif page.page %}{{ urls.format('MEMBERLIST_SORT_PAGE', [sort, (page.page + 1)]) }}{% else %}{{ urls.format('MEMBERLIST_SORT', [sort]) }}{% endif %}"{% if page.sort == sort %} class="dropDownSelected"{% endif %}>{{ sort|capitalize }}</a>
<a href="{% if page.active %}{{ urls.format('MEMBERLIST_ALL', [sort, page.active]) }}{% else %}{{ urls.format('MEMBERLIST_SORT', [sort]) }}{% endif %}"{% if page.sort == sort %} class="dropDownSelected"{% endif %}>{{ sort|capitalize }}</a>
{% endfor %}
</div>
</div>
{% if not page.users|length %}
{% if not users|length %}
<h1 class="stylised" style="margin: 2em 0;">This rank has no members!</h1>
{% elseif not page.notfound %}
<div class="membersPageList {{ page.sort }}">
@ -59,7 +66,7 @@
<th>Country</th>
</tr>
</tfoot>
{% for count,user in page.users[page.page] %}
{% for count,user in users[currPage] %}
<tbody>
<tr>
<td>
@ -85,7 +92,7 @@
{% endfor %}
</table>
{% else %}
{% for user in page.users[page.page] %}
{% for user in users[currPage] %}
<a href="{{ urls.format('USER_PROFILE', [user.id]) }}">{# These comment tags are here to prevent the link extending too far
#}<div class="userBox" id="u{{ user.id }}">{#
#}<img src="{{ sakura.contentPath }}/pixel.png" alt="{{ user.username }}" style="background: url('{{ urls.format('IMAGE_AVATAR', [user.id]) }}') no-repeat center / contain;" />{#
@ -98,18 +105,8 @@
{% endif %}
</div>
{% endif %}
{% if page.users|length > 1 %}
<div class="pagination">
{% if page.page > 0 %}
<a href="{% if page.sort and page.active %}{{ urls.format('MEMBERLIST_ALL', [page.sort, page.active, page.page]) }}{% elseif page.sort %}{{ urls.format('MEMBERLIST_SORT_PAGE', [page.sort, page.page]) }}{% elseif page.active %}{{ urls.format('MEMBERLIST_RANK_PAGE', [page.active, page.page]) }}{% else %}{{ urls.format('MEMBERLIST_PAGE', [page.page]) }}{% endif %}"><span class="fa fa-step-backward"></span></a>
{% endif %}
{% for count,navpage in page.users %}
<a href="{% if page.sort and page.active %}{{ urls.format('MEMBERLIST_ALL', [page.sort, page.active, (count + 1)]) }}{% elseif page.sort %}{{ urls.format('MEMBERLIST_SORT_PAGE', [page.sort, (count + 1)]) }}{% elseif page.active %}{{ urls.format('MEMBERLIST_RANK_PAGE', [page.active, (count + 1)]) }}{% else %}{{ urls.format('MEMBERLIST_PAGE', [(count + 1)]) }}{% endif %}"{% if count == page.page %} class="current"{% endif %}>{{ count + 1 }}</a>
{% endfor %}
{% if page.page + 1 < page.users|length %}
<a href="{% if page.sort and page.active %}{{ urls.format('MEMBERLIST_ALL', [page.sort, page.active, (page.page + 2)]) }}{% elseif page.sort %}{{ urls.format('MEMBERLIST_SORT_PAGE', [page.sort, (page.page + 2)]) }}{% elseif page.active %}{{ urls.format('MEMBERLIST_RANK_PAGE', [page.active, (page.page + 2)]) }}{% else %}{{ urls.format('MEMBERLIST_PAGE', [(page.page + 2)]) }}{% endif %}"><span class="fa fa-step-forward"></span></a>
{% endif %}
</div>
{% if users|length > 1 %}
{% include 'elements/pagination.tpl' %}
{% endif %}
</div>
{% endblock %}

View file

@ -1,12 +1,13 @@
{% extends 'global/master.tpl' %}
{% set newsPosts = viewPost and postExists ? [news.getPost(postExists)] : news.getPosts(postsPerPage)[currentPage] %}
{% set pagination = {'page': currentPage, 'pages': news.getPosts(postsPerPage), 'urlPattern': 'SITE_NEWS_PAGE'} %}
{% set newsPosts = viewPost and postExists ? [news.posts[postExists]] : news.posts|batch(postsPerPage)[get.page|default(1) - 1] %}
{% if viewPost and postExists %}
{% set commentsCategory = 'news-' ~ newsPosts[0].news_category ~ '-' ~ newsPosts[0].news_id %}
{% set comments = newsPosts[0].news_comments.comments %}
{% set commentsCategory = 'news-' ~ newsPosts[0].news_category ~ '-' ~ newsPosts[0].news_id %}
{% set comments = newsPosts[0].news_comments.comments %}
{% else %}
{% set paginationPages = news.posts|batch(postsPerPage) %}
{% set paginationUrl %}{{ urls.format('SITE_NEWS') }}{% endset %}
{% endif %}
{% set title %}
@ -34,7 +35,7 @@
{% include 'elements/comments.tpl' %}
{% endif %}
{% endfor %}
{% if not (viewPost and postExists) and news.getPosts(postsPerPage)|length > 1 %}
{% if not (viewPost and postExists) and news.posts|batch(postsPerPage)|length > 1 %}
<div>
{% include 'elements/pagination.tpl' %}
<div class="clear"></div>

View file

@ -2,45 +2,44 @@
{% block title %}Donation Tracker{% endblock %}
{% set paginationPages = tracker.table|batch(20) %}
{% set paginationUrl %}{{ urls.format('SITE_DONATE_TRACK') }}{% endset %}
{% block css %}
<style type="text/css">
.pagination {
float: right;
}
</style>
{% endblock %}
{% block content %}
<div class="content support">
<div class="head">Donation Tracker</div>
<h1 class="stylised" style="margin: 1em auto; text-align: center;">Our current overall balance is &#8364;{{ page.premiumData.balance|number_format(2) }}</h1>
<h1 class="stylised" style="margin: 1em auto; text-align: center;">Our current overall balance is &#8364;{{ tracker.balance|number_format(2) }}</h1>
<div class="sectionHeader">
Donation Log
</div>
<table>
<thead>
<tr>
<th>
Supporter
</th>
<th>
Amount
</th>
<th>
Action
</th>
<th>Supporter</th>
<th>Amount</th>
<th>Action</th>
</tr>
</thead>
<tfoot>
<tr>
<th>
Supporter
</th>
<th>
Amount
</th>
<th>
Action
</th>
<th>Supporter</th>
<th>Amount</th>
<th>Action</th>
</tr>
</tfoot>
<tbody>
{% for supporter in page.premiumTable[page.currentPage] %}
{% for supporter in tracker.table|batch(20)[get.page|default(1) - 1] %}
<tr>
<td>
<a href="{{ urls.format('USER_PROFILE', [page.premiumData.users[supporter.user_id].id]) }}" class="default" style="color: {{ page.premiumData.users[supporter.user_id].colour }}; text-shadow: 0 0 7px {% if page.premiumData.users[supporter.user_id].colour != 'inherit' %}{{ page.premiumData.users[supporter.user_id].colour }}{% else %}#222{% endif %};">{{ page.premiumData.users[supporter.user_id].username }}</a>
<a href="{{ urls.format('USER_PROFILE', [tracker.users[supporter.user_id].id]) }}" class="default" style="color: {{ tracker.users[supporter.user_id].colour }}; text-shadow: 0 0 7px {% if tracker.users[supporter.user_id].colour != 'inherit' %}{{ tracker.users[supporter.user_id].colour }}{% else %}#222{% endif %};">{{ tracker.users[supporter.user_id].username }}</a>
</td>
<td style="color: {% if supporter.transaction_amount > 0 %}#0A0{% else %}#A00{% endif %};">
&#8364;{{ supporter.transaction_amount|number_format(2) }}
@ -52,19 +51,11 @@
{% endfor %}
</tbody>
</table>
{% if page.premiumTable|length > 1 %}
<div class="pagination" style="float: right;">
{% if page.currentPage > 0 %}
<a href="{{ urls.format('SITE_DONATE_TRACK_PAGE', [page.currentPage]) }}"><span class="fa fa-step-backward"></span></a>
{% endif %}
{% for count,navpage in page.premiumTable %}
<a href="{{ urls.format('SITE_DONATE_TRACK_PAGE', [(count + 1)]) }}"{% if count == page.currentPage %} class="current"{% endif %}>{{ count + 1 }}</a>
{% endfor %}
{% if page.currentPage + 1 < page.premiumTable|length %}
<a href="{{ urls.format('SITE_DONATE_TRACK_PAGE', [(page.currentPage + 2)]) }}"><span class="fa fa-step-forward"></span></a>
{% endif %}
{% if tracker.table|batch(20)|length > 1 %}
<div>
{% include 'elements/pagination.tpl' %}
<div class="clear"></div>
</div>
<div class="clear"></div>
{% endif %}
</div>
{% endblock %}

View file

@ -1,3 +1,8 @@
{% set friends = user.friends(1)|batch(12) %}
{% set paginationPages = friends %}
{% set paginationUrl %}{{ urls.format('SETTING_MODE', ['friends', 'listing']) }}{% endset %}
{% block js %}
<script type="text/javascript">
window.addEventListener("load", function() {
@ -10,9 +15,17 @@ window.addEventListener("load", function() {
</script>
{% endblock %}
{% block css %}
<style type="text/css">
.pagination {
float: right;
}
</style>
{% endblock %}
{% if friends|length %}
<div class="friends-list">
{% for friend in friends[page.currentPage] %}
{% for friend in friends[get.page|default(1) - 1] %}
<div class="friend-container" id="friendslist-friend-{{ friend.id }}">
<a class="friends-list-data clean" href="/u/{{ friend.id }}">
<img src="/a/{{ friend.id }}" alt="{{ friend.username }}" class="friends-list-avatar default-avatar-setting" style="width: 150px; height: 150px;" />
@ -28,18 +41,7 @@ window.addEventListener("load", function() {
</div>
{% if friends|length > 1 %}
<div>
<div class="pagination" style="float: right;">
{% if page.currentPage > 0 %}
<a href="{{ urls.format('SETTING_PAGE', ['friends', 'listing', page.currentPage]) }}"><span class="fa fa-step-backward"></span></a>
{% endif %}
{% for id,npage in friends %}
<a href="{{ urls.format('SETTING_PAGE', ['friends', 'listing', id + 1]) }}"{% if id == page.currentPage %} class="current"{% endif %}>{{ id + 1 }}</a>
{% endfor %}
{% if page.currentPage + 1 < friends|length %}
<a href="{{ urls.format('SETTING_PAGE', ['friends', 'listing', page.currentPage + 2]) }}"><span class="fa fa-step-forward"></span></a>
{% endif %}
</div>
<div class="clear"></div>
{% include 'elements/pagination.tpl' %}
</div>
{% endif %}
{% else %}

View file

@ -1,3 +1,8 @@
{% set friends = user.friends(-1)|batch(12) %}
{% set paginationPages = friends %}
{% set paginationUrl %}{{ urls.format('SETTING_MODE', ['friends', 'requests']) }}{% endset %}
{% block js %}
<script type="text/javascript">
window.addEventListener("load", function() {
@ -10,9 +15,17 @@ window.addEventListener("load", function() {
</script>
{% endblock %}
{% block css %}
<style type="text/css">
.pagination {
float: right;
}
</style>
{% endblock %}
{% if friends|length %}
<div class="friends-list">
{% for friend in friends[page.currentPage] %}
{% for friend in friends[get.page|default(1) - 1] %}
<div class="friend-container" id="friend-{{ friend.id }}">
<a class="friends-list-data clean" href="/u/{{ friend.id }}">
<img src="/a/{{ friend.id }}" alt="{{ friend.username }}" class="friends-list-avatar default-avatar-setting" style="width: 150px; height: 150px;" />
@ -29,18 +42,7 @@ window.addEventListener("load", function() {
</div>
{% if friends|length > 1 %}
<div>
<div class="pagination" style="float: right;">
{% if page.currentPage > 0 %}
<a href="{{ urls.format('SETTING_PAGE', ['friends', 'requests', page.currentPage]) }}"><span class="fa fa-step-backward"></span></a>
{% endif %}
{% for id,npage in friends %}
<a href="{{ urls.format('SETTING_PAGE', ['friends', 'requests', id + 1]) }}"{% if id == page.currentPage %} class="current"{% endif %}>{{ id + 1 }}</a>
{% endfor %}
{% if page.currentPage + 1 < friends|length %}
<a href="{{ urls.format('SETTING_PAGE', ['friends', 'requests', page.currentPage + 2]) }}"><span class="fa fa-step-forward"></span></a>
{% endif %}
</div>
<div class="clear"></div>
{% include 'elements/pagination.tpl' %}
</div>
{% endif %}
{% else %}

View file

@ -1,6 +1,19 @@
{% set alerts = alerts|batch(10) %}
{% set paginationPages = alerts %}
{% set paginationUrl %}{{ urls.format('SETTING_MODE', ['notifications', 'history']) }}{% endset %}
{% block css %}
<style type="text/css">
.pagination {
float: right;
}
</style>
{% endblock %}
{% if alerts %}
<div class="notification-history">
{% for alert in alerts[page.currentPage] %}
{% for alert in alerts[get.page|default(1) - 1] %}
<a id="notif-hist-{{ alert.id }}" class="clean {% if alert.alert_read %}read{% endif %}"{% if alert.alert_link %} href="{{ alert.alert_link }}"{% endif %}>
<div class="notif-hist-icon">
{% if 'FONT:' in alert.alert_img %}
@ -28,18 +41,7 @@
</div>
{% if alerts|length > 1 %}
<div>
<div class="pagination" style="float: right;">
{% if page.currentPage > 0 %}
<a href="{{ urls.format('SETTING_PAGE', ['notifications', 'history', page.currentPage]) }}"><span class="fa fa-step-backward"></span></a>
{% endif %}
{% for id,npage in alerts %}
<a href="{{ urls.format('SETTING_PAGE', ['notifications', 'history', id + 1]) }}"{% if id == page.currentPage %} class="current"{% endif %}>{{ id + 1 }}</a>
{% endfor %}
{% if page.currentPage + 1 < alerts|length %}
<a href="{{ urls.format('SETTING_PAGE', ['notifications', 'history', page.currentPage + 2]) }}"><span class="fa fa-step-forward"></span></a>
{% endif %}
</div>
<div class="clear"></div>
{% include 'elements/pagination.tpl' %}
</div>
{% endif %}
{% else %}

View file

@ -12,7 +12,6 @@ Options +FollowSymLinks -Indexes
RewriteRule ^login/?$|^logout/?$|^activate/?$|^register/?$|^forgotpassword/?|^authenticate/?$ authenticate.php [L,QSA]
RewriteRule ^support/?$ support.php [L,QSA]
RewriteRule ^support/tracker/?$ support.php?tracker=true [L,QSA]
RewriteRule ^support/tracker/([0-9]+)/?$ support.php?tracker=true&page=$1 [L,QSA]
RewriteRule ^faq/?$ faq.php [L,QSA]
RewriteRule ^search/?$ search.php [L,QSA]
@ -21,10 +20,8 @@ RewriteRule ^p/([a-z]+)/?$ index.php?p=$1 [L,QSA]
# News
RewriteRule ^news/?$ news.php [L,QSA]
RewriteRule ^news/p([0-9]+)/?$ news.php?page=$1 [L,QSA]
RewriteRule ^news/([0-9]+)/?$ news.php?id=$1 [L,QSA]
RewriteRule ^news/([a-z\-]+)/?$ news.php?cat=$1 [L,QSA]
RewriteRule ^news/([a-z\-]+)/p([0-9]+)/?$ news.php?cat=$1&page=$2 [L,QSA]
RewriteRule ^news/([a-z\-]+)/([0-9]+)/?$ news.php?cat=$1&id=$2 [L,QSA]
RewriteRule ^news.xml$ news.php?xml [L,QSA]
@ -32,7 +29,6 @@ RewriteRule ^news.xml$ news.php?xml [L,QSA]
RewriteRule ^settings/?$ settings.php [L,QSA]
RewriteRule ^settings/([a-z]+)/?$ settings.php?cat=$1 [L,QSA]
RewriteRule ^settings/([a-z]+)/([a-z]+)/?$ settings.php?cat=$1&mode=$2 [L,QSA]
RewriteRule ^settings/([a-z]+)/([a-z]+)/p([0-9]+)/?$ settings.php?cat=$1&mode=$2&page=$3 [L,QSA]
RewriteRule ^friends/?$ settings.php?friend-action=true [L,QSA]
RewriteRule ^notifications/?$ settings.php?request-notifications=true [L,QSA]
RewriteRule ^comments/?$ settings.php?comment-action=true [L,QSA]
@ -41,11 +37,8 @@ RewriteRule ^comments/?$ settings.php?comment-action=true [L,QSA]
RewriteRule ^members/?$ members.php [L,QSA]
RewriteRule ^members/([a-z]+)/?$ members.php?sort=$1 [L,QSA]
RewriteRule ^members/([0-9]+)/?$ members.php?rank=$1 [L,QSA]
RewriteRule ^members/p([0-9]+)/?$ members.php?page=$1 [L,QSA]
RewriteRule ^members/([a-z]+)/([0-9]+)/?$ members.php?sort=$1&rank=$2 [L,QSA]
RewriteRule ^members/([0-9]+)/p([0-9]+)/?$ members.php?rank=$1&page=$2 [L,QSA]
RewriteRule ^members/([a-z]+)/p([0-9]+)/?$ members.php?sort=$1&page=$2 [L,QSA]
RewriteRule ^members/([a-z]+)/([0-9]+)/p([0-9]+)/?$ members.php?sort=$1&rank=$2&page=$3 [L,QSA]
# Profiles
RewriteRule ^u/?$ profile.php [L,QSA]

View file

@ -34,13 +34,13 @@ if (Users::checkLogin()) {
'sort' => isset($_GET['sort']) && $_GET['sort'] && in_array($_GET['sort'], $_MEMBERLIST_SORTS) ?
$_GET['sort'] :
$_MEMBERLIST_SORTS[0],
'page' => isset($_GET['page']) && ($_GET['page'] - 1) >= 0 ? $_GET['page'] - 1 : 0,
'users' => array_chunk($_MEMBERLIST_ACTIVE && !$_MEMBERLIST_NFOUND ?
Users::getUsersInRank($_MEMBERLIST_ACTIVE, null, true) :
Users::getAllUsers(), Config::getConfig('members_per_page'), true),
];
$renderData['users'] = ($_MEMBERLIST_ACTIVE && !$_MEMBERLIST_NFOUND ? Users::getUsersInRank($_MEMBERLIST_ACTIVE) : Users::getAllUsers());
$renderData['membersPerPage'] = Config::getConfig('members_per_page');
// Set parse variables
$template->setVariables($renderData);

View file

@ -18,7 +18,7 @@ $news = new News(isset($_GET['cat']) ? $_GET['cat'] : Config::getConfig('site_ne
// News XML feed
if (isset($_GET['xml'])) {
// Get the news posts
$posts = $news->getPosts();
$posts = $news->posts;
// Meta data attributes
$metaData = [
@ -123,7 +123,6 @@ $renderData = array_merge($renderData, [
'postsPerPage' => Config::getConfig('news_posts_per_page'),
'viewPost' => isset($_GET['id']),
'postExists' => $news->postExists(isset($_GET['id']) ? $_GET['id'] : 0),
'currentPage' => isset($_GET['page']) && ($_GET['page'] - 1) >= 0 ? $_GET['page'] - 1 : 0,
]);
// Initialise templating engine

View file

@ -1456,12 +1456,9 @@ if (Users::checkLogin()) {
// Page data
$renderData['page'] = [
'category' => $pages[$category]['title'],
'mode' => $pages[$category]['modes'][$mode]['title'],
'currentPage' => isset($_GET['page']) && ($_GET['page'] - 1) >= 0 ? $_GET['page'] - 1 : 0,
'description' => $pages[$category]['modes'][$mode]['description'],
];
// Section specific
@ -1494,16 +1491,6 @@ if (Users::checkLogin()) {
];
break;
// Friends
case 'friends.listing':
$renderData['friends'] = array_chunk(array_reverse($currentUser->friends(1)), 12, true);
break;
// Pending Friend Requests
case 'friends.requests':
$renderData['friends'] = array_chunk(array_reverse($currentUser->friends(-1)), 12, true);
break;
// PM inbox
case 'messages.inbox':
$renderData['messages'] = [];
@ -1511,7 +1498,7 @@ if (Users::checkLogin()) {
// Notification history
case 'notifications.history':
$renderData['alerts'] = array_chunk(array_reverse(Users::getNotifications(null, 0, false, true)), 10, true);
$renderData['alerts'] = array_reverse(Users::getNotifications(null, 0, false, true));
break;
// Avatar and background sizes

View file

@ -142,13 +142,7 @@ if (isset($_REQUEST['mode'])
// Premium tracker
if (isset($_GET['tracker'])) {
$renderData['page'] = [
'currentPage' => isset($_GET['page']) && ($_GET['page'] - 1) >= 0 ? $_GET['page'] - 1 : 0,
'premiumData' => ($_PREMIUM = Main::getPremiumTrackerData()),
'premiumTable' => array_chunk($_PREMIUM['table'], 20, true),
];
$renderData['tracker'] = Main::getPremiumTrackerData();
// Set parse variables
$template->setVariables($renderData);

View file

@ -53,11 +53,6 @@ if ($forum->type === 2) {
$renderData['forum'] = $forum;
$renderData['board'] = [
'threads' => array_chunk($forum->threads, 25, true),
];
$renderData['currentPage'] = isset($_GET['page']) && ($_GET['page'] - 1) >= 0 ? $_GET['page'] - 1 : 0;
// Set parse variables
$template->setVariables($renderData);

View file

@ -44,8 +44,6 @@ if (!$thread) {
$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,
]);
// Set parse variables