Пробуем подключить пародию на шаблонизатор.
This commit is contained in:
parent
5ac30becb7
commit
e4343f28b5
21
classes/Template.php
Normal file
21
classes/Template.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
# Date: 30.09.2020 (09:42)
|
||||
|
||||
abstract class Template
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
//Ничего не генерируем, обращаемся к статике сразу.
|
||||
}
|
||||
|
||||
public static function header($title = null)
|
||||
{
|
||||
return <<<HTML_HEADER
|
||||
<!doctype html>
|
||||
<html lang="ru">
|
||||
<meta charset="utf-8">
|
||||
<link href="/css/main.css" rel="stylesheet">
|
||||
<title>$title</title>
|
||||
HTML_HEADER;
|
||||
}
|
||||
}
|
25
inf.php
25
inf.php
@ -7,29 +7,15 @@ $userInfo = new UserInfo($login);
|
||||
$presentsModel = new PresentsModel($userInfo->id);
|
||||
$presentsList = $presentsModel->getAllPresents();
|
||||
$userInfo->watcher_id = $userInfo->id ?? null;
|
||||
|
||||
if (empty($userInfo->id)): ?>
|
||||
<!doctype html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Ошибка</title>
|
||||
</head>
|
||||
<body style="color: #666; background-color: #d5d5d5; text-align: center; font-family: Consolas,monospace;">
|
||||
Template::header('Ошибка');
|
||||
Ошибка: персонаж <em><?= $login ?></em> не найден...
|
||||
<p><a style="color: #99f" href="javascript:window.history.go(-1);">←назад</a></p>
|
||||
</body>
|
||||
</html>
|
||||
<?php exit(); endif; ?>
|
||||
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<title>Информация о <?= $userInfo->login ?></title>
|
||||
<meta charset=UTF-8"/>
|
||||
<link href="css/main.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
Template::header('Информация о'.$userInfo->login);
|
||||
try {
|
||||
$userInfo->showUserInfo();
|
||||
|
||||
@ -37,7 +23,4 @@ try {
|
||||
echo "<div class='debug'>Ошибка генератора showUserInfo() в User.php: {$e_showUserInfo}</div>";
|
||||
}
|
||||
|
||||
include_once 'views/presents-list.php';
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
include_once 'views/presents-list.php';
|
Loading…
Reference in New Issue
Block a user