Make news use less heavy functions

This commit is contained in:
flash 2015-03-30 17:45:27 +02:00
parent bbaa8ac4f8
commit 6c298a5bcf
3 changed files with 10 additions and 6 deletions

View file

@ -150,6 +150,12 @@ class Main {
// Get news posts
$newsPosts = Database::fetch('news', true, null, ['id', true], ($limit ? [$limit] : null));
// Get user data
foreach($newsPosts as $newsPost) {
$newsPost['udata'] = Users::getUser($newsPost['uid']);
$newsPost['gdata'] = Users::getGroup($newsPost['udata']['group_main']);
}
// Return posts
return $newsPosts;

View file

@ -11,7 +11,7 @@ namespace Sakura;
ob_start();
// Define Sakura version
define('SAKURA_VERSION', '20150329');
define('SAKURA_VERSION', '20150330');
// Define Sakura Path
define('ROOT_DIRECTORY', str_replace('_sakura', '', dirname(__FILE__)));
@ -59,7 +59,5 @@ $renderData = array(
],
'user' => [
'loggedin' => Users::loggedIn()
],
'users' => Users::getAllUsers(),
'groups' => Users::getAllGroups()
]
);

View file

@ -2,8 +2,8 @@
<div class="news-body">
<a class="default" href="/u/{{ newsPost.uid }}">
<div class="news-poster">
<img src="/a/{{ newsPost.uid }}" alt="{{ users[newsPost.uid].username }}" class="default-avatar-setting" />
<h1 style="color: #{{ groups[users[newsPost.uid].group_main].colour }} !important; text-shadow: 0 0 7px #888; padding: 0 0 10px;">{{ users[newsPost.uid].username }}</h1>
<img src="/a/{{ newsPost.uid }}" alt="{{ newsPost.udata.username }}" class="default-avatar-setting" />
<h1 style="color: #{{ newsPost.gdata.colour }} !important; text-shadow: 0 0 7px #888; padding: 0 0 10px;">{{ newsPost.udata.username }}</h1>
</div>
</a>
<div class="markdown">