r20150911 and r20150912
Signed-off-by: Flashwave <me@flash.moe>
This commit is contained in:
parent
88d4308845
commit
b3554ea11a
16 changed files with 214 additions and 154 deletions
|
@ -2634,6 +2634,68 @@
|
|||
"user": "Flashwave"
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
"20150911": [
|
||||
|
||||
"eminence",
|
||||
{
|
||||
"type": "UPD",
|
||||
"change": "Migrate more user object references to the new API.",
|
||||
"user": "Flashwave"
|
||||
},
|
||||
{
|
||||
"type": "ADD",
|
||||
"change": "Add missing $data = null to the count database method.",
|
||||
"user": "Flashwave"
|
||||
},
|
||||
{
|
||||
"type": "UPD",
|
||||
"change": "Directly count index statistics from the database as opposed to retrieving an array and counting that.",
|
||||
"user": "Flashwave"
|
||||
},
|
||||
{
|
||||
"type": "UPD",
|
||||
"change": "Make the legacy getUser function reference the new API.",
|
||||
"user": "Flashwave"
|
||||
},
|
||||
{
|
||||
"type": "UPD",
|
||||
"change": "Moved index news posts over to the new API.",
|
||||
"user": "Flashwave"
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
"20150912": [
|
||||
|
||||
"eminence",
|
||||
{
|
||||
"type": "UPD",
|
||||
"change": "Moved pagination to self-contained template file.",
|
||||
"user": "Flashwave"
|
||||
},,
|
||||
{
|
||||
"type": "UPD",
|
||||
"change": "Moved news section over to new API.",
|
||||
"user": "Flashwave"
|
||||
},
|
||||
{
|
||||
"type": "REM",
|
||||
"change": "Removed old news function.",
|
||||
"user": "Flashwave"
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"change": "Fixed sorting in the changelog.",
|
||||
"user": "Flashwave"
|
||||
},
|
||||
{
|
||||
"type": "REM",
|
||||
"change": "Removed getjson method from changelog.",
|
||||
"user": "Flashwave"
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class Database {
|
|||
}
|
||||
|
||||
// Count from database
|
||||
public static function count($table, $data, $prefix = null) {
|
||||
public static function count($table, $data = null, $prefix = null) {
|
||||
|
||||
return self::$_DATABASE->count($table, $data, $prefix);
|
||||
|
||||
|
|
|
@ -339,7 +339,7 @@ $errorPage .= '</div>
|
|||
$string = strip_tags($string);
|
||||
|
||||
// If set also make the string lowercase
|
||||
if($lower){
|
||||
if($lower) {
|
||||
|
||||
$string = strtolower($string);
|
||||
|
||||
|
@ -357,33 +357,6 @@ $errorPage .= '</div>
|
|||
|
||||
}
|
||||
|
||||
// Getting news posts
|
||||
public static function getNewsPosts($limit = null, $pid = false) {
|
||||
|
||||
// Get news posts
|
||||
$newsPosts = Database::fetch('news', true, ($pid ? ['id' => [$limit, '=']] : null), ['id', true], ($limit && !$pid ? [$limit] : null));
|
||||
|
||||
// Get user data
|
||||
foreach($newsPosts as $newsId => $newsPost) {
|
||||
|
||||
$newsPosts[$newsId]['parsed'] = self::mdParse($newsPost['content']);
|
||||
$newsPosts[$newsId]['udata'] = Users::getUser($newsPost['uid']);
|
||||
$newsPosts[$newsId]['rdata'] = Users::getRank($newsPosts[$newsId]['udata']['rank_main']);
|
||||
|
||||
// Check if a custom name colour is set and if so overwrite the rank colour
|
||||
if($newsPosts[$newsId]['udata']['name_colour'] != null){
|
||||
|
||||
$newsPosts[$newsId]['rdata']['colour'] = $newsPosts[$newsId]['udata']['name_colour'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Return posts
|
||||
return $newsPosts;
|
||||
|
||||
}
|
||||
|
||||
// Loading info pages
|
||||
public static function loadInfoPage($id) {
|
||||
|
||||
|
|
|
@ -7,14 +7,80 @@ namespace Sakura;
|
|||
|
||||
class News {
|
||||
|
||||
// Posts array
|
||||
public $posts = [];
|
||||
private $posts = []; // Posts array
|
||||
private $posters = []; // Posters array (so we don't create a new user object every time)
|
||||
|
||||
// Initialise the news object
|
||||
function __construct($category) {
|
||||
function __construct($category, $comments = true) {
|
||||
|
||||
// Get the news posts and assign them to $posts
|
||||
$this->posts = Database::fetch('news', true, ['category' => [$category, '=']], ['id', true]);
|
||||
$posts = Database::fetch('news', true, ['category' => [$category, '=']], ['id', true]);
|
||||
|
||||
// Attach poster data
|
||||
foreach($posts as $post) {
|
||||
|
||||
// Check if we already have an object for this user
|
||||
if(!array_key_exists($post['uid'], $this->posters)) {
|
||||
|
||||
// Create new object
|
||||
$this->posters[$post['uid']] = new User($post['uid']);
|
||||
|
||||
}
|
||||
|
||||
// Parse the news post
|
||||
$post['content_parsed'] = Main::mdParse($post['content']);
|
||||
|
||||
// Attach the poster
|
||||
$post['poster'] = $this->posters[$post['uid']];
|
||||
|
||||
// Add post to posts array
|
||||
$this->posts[$post['id']] = $post;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Get the amount of posts
|
||||
public function getCount() {
|
||||
|
||||
return count($this->posts);
|
||||
|
||||
}
|
||||
|
||||
// Get the amount of posts
|
||||
public function postExists($id) {
|
||||
|
||||
return array_key_exists($id, $this->posts) ? $id : 0;
|
||||
|
||||
}
|
||||
|
||||
// Get a single post
|
||||
public function getPost($id) {
|
||||
|
||||
return array_key_exists($id, $this->posts) ? $this->posts[$id] : 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;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1195,21 +1195,8 @@ class Users {
|
|||
// Get user data by id
|
||||
public static function getUser($id) {
|
||||
|
||||
// Execute query
|
||||
$user = Database::fetch('users', false, ['id' => [$id, '=']]);
|
||||
|
||||
// Return false if no user was found
|
||||
if(empty($user)) {
|
||||
|
||||
$user = self::$emptyUser;
|
||||
|
||||
}
|
||||
|
||||
// Parse the json in the additional section
|
||||
$user['userData'] = json_decode($user['userData'], true);
|
||||
|
||||
// If user was found return user data
|
||||
return $user;
|
||||
return (new User($id))->data;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -357,7 +357,7 @@ class MySQL {
|
|||
}
|
||||
|
||||
// Count data from the database
|
||||
public function count($table, $data, $prefix = null) {
|
||||
public function count($table, $data = null, $prefix = null) {
|
||||
|
||||
// Begin preparation of the statement
|
||||
$prepare = 'SELECT COUNT(*) FROM `' . ($prefix ? $prefix : Configuration::getLocalConfig('database', 'prefix')) . $table . '`';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Sakura;
|
||||
|
||||
// Define Sakura version
|
||||
define('SAKURA_VERSION', '20150910');
|
||||
define('SAKURA_VERSION', '20150912');
|
||||
define('SAKURA_VLABEL', 'Eminence');
|
||||
define('SAKURA_COLOUR', '#6C3082');
|
||||
define('SAKURA_STABLE', false);
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
{% if not page.view_post %}<a href="{{ urls.format('SITE_NEWS_POST', [newsPost.id]) }}" class="news-head" id="{{ newsPost.category}}_{{ newsPost.id }}">{{ newsPost.title }}</a>{% endif %}
|
||||
{% if not viewPost %}<a href="{{ urls.format('SITE_NEWS_POST', [post.id]) }}" class="news-head" id="{{ post.category }}_{{ post.id }}">{{ post.title }}</a>{% endif %}
|
||||
<div class="news-body">
|
||||
<a class="no-underline" href="{{ urls.format('USER_PROFILE', [newsPost.uid]) }}">
|
||||
<a class="no-underline" href="{{ urls.format('USER_PROFILE', [post.poster.data.id]) }}">
|
||||
<div class="news-poster">
|
||||
<img src="{{ urls.format('IMAGE_AVATAR', [newsPost.uid]) }}" alt="{{ newsPost.udata.username }}" class="default-avatar-setting" />
|
||||
<h1 style="color: {{ newsPost.rdata.colour }}; text-shadow: 0 0 7px {% if newsPost.rdata.colour != 'inherit' %}{{ newsPost.rdata.colour }}{% else %}#222{% endif %};; padding: 0 0 10px;">{{ newsPost.udata.username }}</h1>
|
||||
<img src="{{ urls.format('IMAGE_AVATAR', [post.poster.data.id]) }}" alt="{{ post.poster.data.username }}" class="default-avatar-setting" />
|
||||
<h1 style="color: {{ post.poster.colour }}; text-shadow: 0 0 7px {% if post.poster.colour != 'inherit' %}{{ post.poster.colour }}{% else %}#222{% endif %}; padding: 0 0 10px;">{{ post.poster.data.username }}</h1>
|
||||
</div>
|
||||
</a>
|
||||
<div class="markdown">
|
||||
{{ newsPost.parsed|raw }}
|
||||
{{ post.content_parsed|raw }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<div class="news-post-time">
|
||||
Posted on {{ newsPost.date|date(sakura.dateFormat) }}{% if not page.view_post %} <a class="default" href="{{ urls.format('SITE_NEWS_POST', [newsPost.id]) }}">X comments</a>{% endif %}
|
||||
Posted on {{ post.date|date(sakura.dateFormat) }}{% if not viewPost %} <a class="default" href="{{ urls.format('SITE_NEWS_POST', [post.id]) }}">X comments</a>{% endif %}
|
||||
</div>
|
||||
|
|
11
_sakura/templates/yuuno/elements/pagination.tpl
Normal file
11
_sakura/templates/yuuno/elements/pagination.tpl
Normal file
|
@ -0,0 +1,11 @@
|
|||
<div class="pagination">
|
||||
{% if pagination.page > 0 %}
|
||||
<a href="{{ urls.format(pagination.urlPattern, [pagination.page]) }}"><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>
|
||||
{% 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>
|
||||
{% endif %}
|
||||
</div>
|
|
@ -269,7 +269,8 @@
|
|||
<li><a href="https://twitter.com/_flashii" target="_blank" title="Follow us on Twitter for news messages that are too short for the news page">Twitter</a></li>
|
||||
<li><a href="https://youtube.com/user/flashiinet" target="_blank" title="Our YouTube page where stuff barely ever gets uploaded, mainly used to archive community creations">YouTube</a></li>
|
||||
<li><a href="https://steamcommunity.com/groups/flashiinet" target="_blank" title="Our Steam group, play games with other members on the site">Steam</a></li>
|
||||
<li><a href="https://bitbucket.org/circlestorm" target="_blank" title="Our Open Source repository thing">BitBucket</a></li>
|
||||
<li><a href="https://bitbucket.org/circlestorm" target="_blank" title="Our BitBucket organisation">BitBucket</a></li>
|
||||
<li><a href="https://github.com/circlestorm" target="_blank" title="Our GitHub organisation">GitHub</a></li>
|
||||
</ul>
|
||||
<ul class="ftsection">
|
||||
<li class="fthead">Information</li>
|
||||
|
|
|
@ -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 newsPost in newsPosts %}
|
||||
{% for post in news.getPosts(0, newsCount) %}
|
||||
{% include 'elements/newsPost.tpl' %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
{% extends 'global/master.tpl' %}
|
||||
|
||||
{% block title %}{% if page.view_post %}{{ newsPosts[0].title }}{% elseif newsPosts|length < 1 %}Post does not exist!{% else %}News{% endif %}{% endblock %}
|
||||
{% set newsPosts = viewPost ? [news.getPost(postExists)] : news.getPosts(postsPerPage)[currentPage] %}
|
||||
|
||||
{% set pagination = {'page': currentPage, 'pages': news.getPosts(postsPerPage), 'urlPattern': 'SITE_NEWS_PAGE'} %}
|
||||
|
||||
{% set title %}
|
||||
{% if not newsPosts|length %}Post does not exist!{% elseif viewPost %}{{ newsPosts[0].title }}{% else %}News{% endif %}
|
||||
{% endset %}
|
||||
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
<style type="text/css">
|
||||
.pagination {
|
||||
float: right;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="content">
|
||||
<div class="content-column news">
|
||||
<div class="head">{% if page.view_post %}{{ newsPosts[0].title }}{% elseif newsPosts|length < 1 %}Post does not exist!{% else %}News <a href="{{ urls.format('SITE_NEWS_RSS') }}" class="fa fa-rss news-rss default"></a>{% endif %}</div>
|
||||
{% if newsPosts|length >= 1 %}
|
||||
{% if page.view_post %}
|
||||
{% for newsPost in newsPosts %}
|
||||
{% include 'elements/newsPost.tpl' %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for newsPost in newsPosts[page.currentPage] %}
|
||||
{% include 'elements/newsPost.tpl' %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if not page.view_post and newsPosts|length > 1 %}
|
||||
<div class="head">{{ title }}{% if not viewPost %}<a href="{{ urls.format('SITE_NEWS_RSS') }}" class="fa fa-rss news-rss default"></a>{% endif %}</div>
|
||||
{% if newsPosts|length %}
|
||||
{% for post in newsPosts %}
|
||||
{% include 'elements/newsPost.tpl' %}
|
||||
{% endfor %}
|
||||
{% if not viewPost and news.getPosts(postsPerPage)|length > 1 %}
|
||||
<div>
|
||||
<div class="pagination" style="float: right;">
|
||||
{% if page.currentPage > 0 %}
|
||||
<a href="{{ urls.format('SITE_NEWS_PAGE', [page.currentPage]) }}"><span class="fa fa-step-backward"></span></a>
|
||||
{% endif %}
|
||||
{% for id,npage in newsPosts %}
|
||||
<a href="{{ urls.format('SITE_NEWS_PAGE', [(id + 1)]) }}"{% if id == page.currentPage %} class="current"{% endif %}>{{ id + 1 }}</a>
|
||||
{% endfor %}
|
||||
{% if page.currentPage + 1 < newsPosts|length %}
|
||||
<a href="{{ urls.format('SITE_NEWS_PAGE', [(page.currentPage + 2)]) }}"><span class="fa fa-step-forward"></span></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% include 'elements/pagination.tpl' %}
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
|
@ -28,8 +28,11 @@ 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/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]
|
||||
|
||||
# Settings
|
||||
|
|
|
@ -14,47 +14,6 @@ require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sak
|
|||
|
||||
// Path the changelog JSON
|
||||
$changelog = json_decode(file_get_contents(ROOT .'_sakura/changelog.json'), true);
|
||||
//$changelog = array();
|
||||
|
||||
// Create version categories
|
||||
/*foreach($changelogFile['versions'] as $name => $data) {
|
||||
|
||||
// Reverse the array
|
||||
$data['revisions'] = array_reverse($data['revisions'], true);
|
||||
|
||||
foreach($data['revisions'] as $rev) {
|
||||
|
||||
$changelog[$rev]['name'] = $name;
|
||||
$changelog[$rev]['colour'] = $data['colour'];
|
||||
$changelog[$rev]['changes'] = array();
|
||||
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
// Sort changes properly
|
||||
/*foreach($changelogFile['changelog'] as $ver => $data) {
|
||||
|
||||
// Reverse the array
|
||||
$data = array_reverse($data, true);
|
||||
|
||||
// Add the log to the array
|
||||
foreach($data as $id => $change) {
|
||||
|
||||
$changelog[$ver]['changes'][$id] = $change;
|
||||
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
// Add a thing to only get the json
|
||||
if(isset($_REQUEST['getjson'])) {
|
||||
|
||||
// Print encoded json and exit
|
||||
print json_encode($changelog);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
// Create variable to store HTML in
|
||||
$changelogHTML = null;
|
||||
|
@ -68,7 +27,7 @@ foreach(array_reverse($changelog['changelog'], true) as $revisionId => $revision
|
|||
|
||||
unset($revisionData[0]);
|
||||
|
||||
foreach($revisionData as $id => $changeData) {
|
||||
foreach(array_reverse($revisionData) as $id => $changeData) {
|
||||
|
||||
$changelogHTML .= '<div id="r'. $revisionId .'c'. $id .'">';
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ if(isset($_GET['p'])) {
|
|||
// Set default variables
|
||||
$renderData['page'] = [
|
||||
|
||||
'content' => Main::mdParse("# Unable to load the requested info page.\r\n\r\nCheck the URL and try again.")
|
||||
'content' => Main::mdParse("# Unable to load the requested info page.\r\n\r\nCheck the URL and try again.")
|
||||
|
||||
];
|
||||
|
||||
|
@ -45,8 +45,9 @@ if(isset($_GET['p'])) {
|
|||
// Are we in forum mode?
|
||||
$forumMode = isset($_GET['forum']) ? ($_GET['forum'] == true) : false;
|
||||
|
||||
// Add page specific things
|
||||
$renderData['newsPosts'] = ($forumMode ? null : Main::getNewsPosts(Configuration::getConfig('front_page_news_posts')));
|
||||
$renderData['news'] = ($forumMode ? null : (new News(Configuration::getConfig('site_news_category'))));
|
||||
|
||||
$renderData['newsCount'] = Configuration::getConfig('front_page_news_posts');
|
||||
|
||||
$renderData['page'] = [
|
||||
'friend_req' => Users::getPendingFriends()
|
||||
|
@ -59,11 +60,11 @@ $renderData['board'] = [
|
|||
];
|
||||
|
||||
$renderData['stats'] = [
|
||||
'userCount' => ($_INDEX_USER_COUNT = count($_INDEX_USERS = Users::getAllUsers(false))),
|
||||
'userCount' => Database::count('users', ['password_algo' => ['nologin', '!='], 'rank_main' => ['1', '!=']])[0],
|
||||
'newestUser' => ($_INDEX_NEWEST_USER = new User(Users::getNewestUserId())),
|
||||
'lastRegDate' => ($_INDEX_LAST_REGDATE = date_diff(date_create(date('Y-m-d', $_INDEX_NEWEST_USER->data['regdate'])), date_create(date('Y-m-d')))->format('%a')) .' day'. ($_INDEX_LAST_REGDATE == 1 ? '' : 's'),
|
||||
'topicCount' => ($_TOPICS = count(Database::fetch('topics'))),
|
||||
'postCount' => ($_POSTS = count(Database::fetch('posts'))),
|
||||
'topicCount' => Database::count('topics')[0],
|
||||
'postCount' => Database::count('posts')[0],
|
||||
'onlineUsers' => Users::checkAllOnline()
|
||||
];
|
||||
|
||||
|
|
|
@ -12,19 +12,15 @@ use DOMDocument;
|
|||
// Include components
|
||||
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sakura.php';
|
||||
|
||||
// Add page specific things
|
||||
$renderData['newsPosts'] = Main::getNewsPosts((isset($_GET['id']) && !isset($_GET['xml']) && is_numeric($_GET['id'])) ? $_GET['id'] : null, (isset($_GET['id']) && !isset($_GET['xml']) && is_numeric($_GET['id'])));
|
||||
|
||||
$renderData['page'] = [
|
||||
|
||||
'view_post' => isset($_GET['id']) && count($renderData['newsPosts']),
|
||||
'currentPage' => 0
|
||||
|
||||
];
|
||||
// Create a new News object
|
||||
$news = new News(isset($_GET['cat']) ? $_GET['cat'] : Configuration::getConfig('site_news_category'));
|
||||
|
||||
// News XML feed
|
||||
if(isset($_GET['xml'])) {
|
||||
|
||||
// Get the news posts
|
||||
$posts = $news->getPosts();
|
||||
|
||||
// Meta data attributes
|
||||
$metaData = [
|
||||
|
||||
|
@ -33,7 +29,7 @@ if(isset($_GET['xml'])) {
|
|||
'description' => 'News about '. $_FEED_TITLE,
|
||||
'language' => 'en-gb',
|
||||
'webMaster' => (new User(1))->data['email'] .' ('. $_FEED_TITLE .' Webmaster)',
|
||||
'pubDate' => ($_FEED_DATE = date('r', $renderData['newsPosts'][0]['date'])),
|
||||
'pubDate' => ($_FEED_DATE = date('r', $posts[array_keys($posts)[0]]['date'])),
|
||||
'lastBuildDate' => $_FEED_DATE
|
||||
|
||||
];
|
||||
|
@ -41,12 +37,12 @@ if(isset($_GET['xml'])) {
|
|||
// Item attributes
|
||||
$itemData = [
|
||||
|
||||
'title' => ['text' => '{EVAL}', 'eval' => '$newsPost["title"]'],
|
||||
'link' => ['text' => $_FEED_URL .'/news/{EVAL}', 'eval' => '$newsPost["id"]'],
|
||||
'guid' => ['text' => $_FEED_URL .'/news/{EVAL}', 'eval' => '$newsPost["id"]'],
|
||||
'pubDate' => ['text' => '{EVAL}', 'eval' => 'date("D, d M Y G:i:s O", $newsPost["date"])'],
|
||||
'dc:publisher' => ['text' => '{EVAL}', 'eval' => '$newsPost["udata"]["username"]'],
|
||||
'description' => ['cdata' => '{EVAL}', 'eval' => '$newsPost["parsed"]']
|
||||
'title' => ['text' => '{EVAL}', 'eval' => '$post["title"]'],
|
||||
'link' => ['text' => $_FEED_URL .'/news/{EVAL}', 'eval' => '$post["id"]'],
|
||||
'guid' => ['text' => $_FEED_URL .'/news/{EVAL}', 'eval' => '$post["id"]'],
|
||||
'pubDate' => ['text' => '{EVAL}', 'eval' => 'date("D, d M Y G:i:s O", $post["date"])'],
|
||||
'dc:publisher' => ['text' => '{EVAL}', 'eval' => '$post["poster"]->data["username"]'],
|
||||
'description' => ['cdata' => '{EVAL}', 'eval' => '$post["content_parsed"]']
|
||||
|
||||
];
|
||||
|
||||
|
@ -82,7 +78,7 @@ if(isset($_GET['xml'])) {
|
|||
}
|
||||
|
||||
// Add all the posts
|
||||
foreach($renderData['newsPosts'] as $newsPost) {
|
||||
foreach($posts as $post) {
|
||||
|
||||
// Create item element
|
||||
$fPost = $feed->createElement('item');
|
||||
|
@ -128,14 +124,15 @@ if(isset($_GET['xml'])) {
|
|||
|
||||
}
|
||||
|
||||
// If we're not using the XML feed and we're not viewing a single post create pages
|
||||
if(!isset($_GET['id'])) {
|
||||
$renderData = array_merge($renderData, [
|
||||
|
||||
// Create the current page
|
||||
$renderData['newsPosts'] = array_chunk($renderData['newsPosts'], Configuration::getConfig('news_posts_per_page'), true);
|
||||
$renderData['page']['currentPage'] = isset($_GET['page']) && ($_GET['page'] - 1) >= 0 ? $_GET['page'] - 1 : 0;
|
||||
'news' => $news,
|
||||
'postsPerPage' => Configuration::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
|
||||
|
||||
}
|
||||
]);
|
||||
|
||||
// Print page contents
|
||||
print Templates::render('main/news.tpl', $renderData);
|
||||
|
|
Reference in a new issue