This commit is contained in:
2024-07-12 11:31:04 +03:00
parent 6d38f62e8d
commit 91dc9194e0
13 changed files with 38 additions and 32 deletions

View File

@ -1,14 +0,0 @@
<?php
namespace app\controllers;
class Controller
{
protected \Twig\Loader\FilesystemLoader $loader;
protected \Twig\Environment $twig;
public function __construct()
{
$this->loader = new \Twig\Loader\FilesystemLoader(__DIR__.'/../views');
$this->twig = new \Twig\Environment($this->loader, ['cache' => 'app/views/cache']);
}
}

View File

@ -2,12 +2,13 @@
namespace app\controllers;
use app\models\Question;
use kernel\Controller;
class QuestionController extends Controller{
public function actionCreate()
{
echo $this->twig->render('questionCreate.html');
echo $this->twig->render('question_create.html.twig');
}
public function actionGetQuestionsWithAnswers(): array

View File

@ -2,9 +2,9 @@
namespace app\controllers;
use app\helpers\Debug;
use app\models\Question;
use app\models\User;
use kernel\Controller;
class UserController extends Controller{
public function actionCreate(): void

View File

@ -1,14 +0,0 @@
<!DOCTYPE html>
<html lang="ru-RU">
<head>
<meta charset="UTF-8">
<title>Примеры шаблонизатора Twig</title>
</head>
<body>
<h1>HEADER</h1>
{% block content %}
{% endblock %}
<h1>FOOTER</h1>
</body>
</html>

View File

@ -1,13 +0,0 @@
{% extends "mainLayout.html" %}
{% block content %}
<form action="/admin/question" method="post">
Вопрос: <br>
<label>
<textarea name = "question" rows="10" cols="50" placeholder="Введите здесь ваш вопрос"></textarea>
</label> <br> <br>
<input type = "submit" value="Подтвердить">
<input type="reset">
</form>
{% endblock %}

View File

@ -1,23 +0,0 @@
{% extends "mainLayout.html" %}
{% block content %}
<form action="/admin/user/" method="post">
Логин:<br>
<label>
<input type = "text" name = "username" required size="50" autofocus placeholder="Логин">
</label> <br> <br>
Пароль:<br>
<label>
<input type = "text" name = "password_hash" required size="50" placeholder="Пароль">
</label> <br> <br>
Email адрес: <br>
<label>
<input type="Email" name="email" required placeholder="Email">
</label> <br><br>
<input type = "submit" value="Подтвердить">
<input type="reset">
</form>
{% endblock %}

View File

@ -1,26 +0,0 @@
{% extends "mainLayout.html" %}
{% block content %}
<table border="1" style="width: 80%;">
<thead>
<tr>
<td>id</td>
<td>Username</td>
<td>Email</td>
<td>Created at</td>
<td>Updated at</td>
</tr>
</thead>
<tbody>
{% for users in userArr %}
<tr>
<td>{{ users.id }}</td>
<td>{{ users.username }}</td>
<td>{{ users.email }}</td>
<td>{{ users.created_at }}</td>
<td>{{ users.updated_at }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@ -1,28 +0,0 @@
{% extends "mainLayout.html" %}
{% block content %}
<form action="/admin/user/edit" method="post">
id пользователя:<br>
<label>
<input type = "text" name = "id" required size="50" autofocus placeholder="id">
</label> <br> <br>
Логин:<br>
<label>
<input type = "text" name = "username" required size="50" autofocus placeholder="Логин">
</label> <br> <br>
Пароль:<br>
<label>
<input type = "text" name = "password_hash" required size="50" placeholder="Пароль">
</label> <br> <br>
Email адрес: <br>
<label>
<input type="Email" name="email" required>
</label> <br><br>
<input type = "submit" value="Подтвердить">
<input type="reset">
</form>
{% endblock %}