This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/libraries/Controllers/Forum.php

60 lines
1.7 KiB
PHP
Raw Normal View History

2016-01-30 13:25:18 +00:00
<?php
namespace Sakura\Controllers;
use Sakura\Config;
use Sakura\Database;
use Sakura\Forum as ForumData;
use Sakura\Perms\Forum as ForumPerms;
use Sakura\Template;
use Sakura\User;
use Sakura\Users;
use Sakura\Utils;
/**
2016-02-02 21:04:15 +00:00
* Forum page controllers.
*
2016-01-30 13:25:18 +00:00
* @package Sakura
2016-02-02 21:04:15 +00:00
* @author Julian van de Groep <me@flash.moe>
2016-01-30 13:25:18 +00:00
*/
class Forum
{
2016-02-02 21:04:15 +00:00
/**
* Serves the forum index.
*
* @return mixed HTML for the forum index.
*/
2016-01-30 13:25:18 +00:00
public static function index()
{
// Get the global renderData
global $renderData;
// Initialise templating engine
$template = new Template();
// Merge index specific stuff with the global render data
$renderData = array_merge(
$renderData,
[
'forum' => (new ForumData\Forum()),
'stats' => [
'userCount' => Database::count('users', ['password_algo' => ['nologin', '!='], 'rank_main' => ['1', '!=']])[0],
'newestUser' => User::construct(Users::getNewestUserId()),
'lastRegData' => date_diff(
date_create(date('Y-m-d', User::construct(Users::getNewestUserId())->registered)),
date_create(date('Y-m-d'))
)->format('%a'),
'topicCount' => Database::count('topics')[0],
'postCount' => Database::count('posts')[0],
'onlineUsers' => Users::checkAllOnline(),
],
]
);
// Set parse variables
$template->setVariables($renderData);
// Return the compiled page
return $template->render('forum/index');
}
}