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 // Get news posts
$newsPosts = Database::fetch('news', true, null, ['id', true], ($limit ? [$limit] : null)); $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 posts
return $newsPosts; return $newsPosts;

View file

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

View file

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