[*] исправлен шаблонизатор главной страницы

This commit is contained in:
rsgrinko committed 2023-07-07 14:33:10 +03:00
1 parent e8a955067c
commit a422976535
5 files changed
+640 -535

No files matched your search

+32 -6
View File
@@ -21,21 +21,47 @@
namespace Core;
use Core\Models\Posts;
use Core\DataBases\DB;
use Core\Helpers\Cache;
use Core\Helpers\Files;
use Core\Helpers\SystemFunctions;
use Core\Models\{Posts, User};
class App
{
/**
* Отрисовка главной страницы
*
* @return void
* @throws CoreException
*/
public static function index()
{
global $twig, $USER;
$userData = $USER ? $USER->getAllUserData() : '';
$userRoles = $USER ? $USER->getRolesObject()->getFullRoles() : '';
$finish_time = microtime(true);
$delta = round($finish_time - START_TIME, 3);
if ($delta < 0.001) {
$delta = 0.001;
}
echo $twig->render(
'index.twig',
[
'sections' => (new Posts())->getMainSections(),
'user' => $USER ? $USER->getAllUserData() : null,
]
'isAuthorized' => User::isAuthorized(),
'isAdmin' => User::isAuthorized() && $USER->isAdmin(),
'userDataTable' => User::isAuthorized() ? str_replace(
'<table style="',
'<table style="width:100%;',
SystemFunctions::arrayToTable($USER->getAllUserData(), 'Информация о пользователе')
) : '',
'statString' => 'Использовано ОЗУ: '
. round(memory_get_usage() / 1024 / 1024, 2) . ' МБ / БД: '
. round(DB::$workingTime,3) . ' сек (' . DB::$quantity . ' шт.) / Кэш: '
. Files::convertBytes(Cache::getCacheSize())
. ' / Генерация: ' . $delta . ' сек',
]
);
}