From a3faec247ee00023a908aad543e82e82548e0a8d Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 16 Apr 2024 17:13:42 +0300 Subject: [PATCH] bd 7.0 --- .../17/17b0eaaa5d26fb4fa6894d430c1c27da.php | 98 ----------------- .../1c/1c1a65045d16ca598e290fed477b7831.php | 97 ----------------- .../b6/b6a9b94df97efc8dc9336c36ada05909.php | 103 ------------------ .../ea/ea1278337c261f39a1523ba336d5c786.php | 102 ----------------- index.php | 1 + public/js/ajax.js | 12 ++ src/app/controllers/AdminController.php | 17 +++ views/admin/ajax.php | 1 + views/admin/index.php | 27 ++--- views/layouts/admin_layout.php | 3 +- 10 files changed, 42 insertions(+), 419 deletions(-) delete mode 100644 compilation_cache/17/17b0eaaa5d26fb4fa6894d430c1c27da.php delete mode 100644 compilation_cache/1c/1c1a65045d16ca598e290fed477b7831.php delete mode 100644 compilation_cache/b6/b6a9b94df97efc8dc9336c36ada05909.php delete mode 100644 compilation_cache/ea/ea1278337c261f39a1523ba336d5c786.php create mode 100644 public/js/ajax.js create mode 100644 views/admin/ajax.php diff --git a/compilation_cache/17/17b0eaaa5d26fb4fa6894d430c1c27da.php b/compilation_cache/17/17b0eaaa5d26fb4fa6894d430c1c27da.php deleted file mode 100644 index 2ba31b1..0000000 --- a/compilation_cache/17/17b0eaaa5d26fb4fa6894d430c1c27da.php +++ /dev/null @@ -1,98 +0,0 @@ -source = $this->getSourceContext(); - - $this->blocks = [ - 'title' => [$this, 'block_title'], - 'content' => [$this, 'block_content'], - ]; - } - - protected function doGetParent(array $context) - { - // line 1 - return "layouts/simple.html.twig"; - } - - protected function doDisplay(array $context, array $blocks = []) - { - $macros = $this->macros; - $this->parent = $this->loadTemplate("layouts/simple.html.twig", "form/resultItem.html.twig", 1); - $this->parent->display($context, array_merge($this->blocks, $blocks)); - } - - // line 3 - public function block_title($context, array $blocks = []) - { - $macros = $this->macros; - echo twig_escape_filter($this->env, ($context["title"] ?? null), "html", null, true); - } - - // line 5 - public function block_content($context, array $blocks = []) - { - $macros = $this->macros; - // line 6 - echo "

"; - echo twig_escape_filter($this->env, ($context["title"] ?? null), "html", null, true); - echo "

- - "; - // line 8 - echo twig_escape_filter($this->env, $this->env->getFunction('create_get_action')->getCallable()(), "html", null, true); - echo " - -"; - } - - /** - * @codeCoverageIgnore - */ - public function getTemplateName() - { - return "form/resultItem.html.twig"; - } - - /** - * @codeCoverageIgnore - */ - public function isTraitable() - { - return false; - } - - /** - * @codeCoverageIgnore - */ - public function getDebugInfo() - { - return array ( 64 => 8, 58 => 6, 54 => 5, 47 => 3, 36 => 1,); - } - - public function getSourceContext() - { - return new Source("", "form/resultItem.html.twig", "/home/kali/php/untitled/views/form/resultItem.html.twig"); - } -} diff --git a/compilation_cache/1c/1c1a65045d16ca598e290fed477b7831.php b/compilation_cache/1c/1c1a65045d16ca598e290fed477b7831.php deleted file mode 100644 index 141a7d7..0000000 --- a/compilation_cache/1c/1c1a65045d16ca598e290fed477b7831.php +++ /dev/null @@ -1,97 +0,0 @@ -source = $this->getSourceContext(); - - $this->blocks = [ - 'title' => [$this, 'block_title'], - 'content' => [$this, 'block_content'], - ]; - } - - protected function doGetParent(array $context) - { - // line 1 - return "layouts/simple.html.twig"; - } - - protected function doDisplay(array $context, array $blocks = []) - { - $macros = $this->macros; - $this->parent = $this->loadTemplate("layouts/simple.html.twig", "form/form.html.twig", 1); - $this->parent->display($context, array_merge($this->blocks, $blocks)); - } - - // line 3 - public function block_title($context, array $blocks = []) - { - $macros = $this->macros; - echo twig_escape_filter($this->env, ($context["title"] ?? null), "html", null, true); - } - - // line 5 - public function block_content($context, array $blocks = []) - { - $macros = $this->macros; - // line 6 - echo "

"; - echo twig_escape_filter($this->env, ($context["title"] ?? null), "html", null, true); - echo "

-"; - // line 7 - echo twig_escape_filter($this->env, $this->env->getFunction('create_form')->getCallable()(), "html", null, true); - echo " - -"; - } - - /** - * @codeCoverageIgnore - */ - public function getTemplateName() - { - return "form/form.html.twig"; - } - - /** - * @codeCoverageIgnore - */ - public function isTraitable() - { - return false; - } - - /** - * @codeCoverageIgnore - */ - public function getDebugInfo() - { - return array ( 63 => 7, 58 => 6, 54 => 5, 47 => 3, 36 => 1,); - } - - public function getSourceContext() - { - return new Source("", "form/form.html.twig", "/home/kali/php/untitled/views/form/form.html.twig"); - } -} diff --git a/compilation_cache/b6/b6a9b94df97efc8dc9336c36ada05909.php b/compilation_cache/b6/b6a9b94df97efc8dc9336c36ada05909.php deleted file mode 100644 index 69844b3..0000000 --- a/compilation_cache/b6/b6a9b94df97efc8dc9336c36ada05909.php +++ /dev/null @@ -1,103 +0,0 @@ -source = $this->getSourceContext(); - - $this->parent = false; - - $this->blocks = [ - 'title' => [$this, 'block_title'], - 'content' => [$this, 'block_content'], - ]; - } - - protected function doDisplay(array $context, array $blocks = []) - { - $macros = $this->macros; - // line 1 - echo " - - - - "; - // line 5 - $this->displayBlock('title', $context, $blocks); - echo " - - - - - -
-
-
- "; - // line 15 - $this->displayBlock('content', $context, $blocks); - // line 16 - echo "
- -
- - -
- - -"; - } - - // line 5 - public function block_title($context, array $blocks = []) - { - $macros = $this->macros; - } - - // line 15 - public function block_content($context, array $blocks = []) - { - $macros = $this->macros; - } - - /** - * @codeCoverageIgnore - */ - public function getTemplateName() - { - return "layouts/simple.html.twig"; - } - - /** - * @codeCoverageIgnore - */ - public function getDebugInfo() - { - return array ( 78 => 15, 72 => 5, 60 => 16, 58 => 15, 45 => 5, 39 => 1,); - } - - public function getSourceContext() - { - return new Source("", "layouts/simple.html.twig", "/home/kali/php/untitled/views/layouts/simple.html.twig"); - } -} diff --git a/compilation_cache/ea/ea1278337c261f39a1523ba336d5c786.php b/compilation_cache/ea/ea1278337c261f39a1523ba336d5c786.php deleted file mode 100644 index 3395aae..0000000 --- a/compilation_cache/ea/ea1278337c261f39a1523ba336d5c786.php +++ /dev/null @@ -1,102 +0,0 @@ -source = $this->getSourceContext(); - - $this->blocks = [ - 'title' => [$this, 'block_title'], - 'content' => [$this, 'block_content'], - ]; - } - - protected function doGetParent(array $context) - { - // line 1 - return "layouts/simple.html.twig"; - } - - protected function doDisplay(array $context, array $blocks = []) - { - $macros = $this->macros; - $this->parent = $this->loadTemplate("layouts/simple.html.twig", "form/result.html.twig", 1); - $this->parent->display($context, array_merge($this->blocks, $blocks)); - } - - // line 3 - public function block_title($context, array $blocks = []) - { - $macros = $this->macros; - echo twig_escape_filter($this->env, ($context["title"] ?? null), "html", null, true); - } - - // line 5 - public function block_content($context, array $blocks = []) - { - $macros = $this->macros; - // line 6 - echo "

"; - echo twig_escape_filter($this->env, ($context["title"] ?? null), "html", null, true); - echo "

- - "; - // line 8 - echo twig_escape_filter($this->env, $this->env->getFunction('create_table')->getCallable()(), "html", null, true); - echo " - "; - // line 9 - echo twig_escape_filter($this->env, $this->env->getFunction('create_pagination')->getCallable()(), "html", null, true); - echo " - -"; - } - - /** - * @codeCoverageIgnore - */ - public function getTemplateName() - { - return "form/result.html.twig"; - } - - /** - * @codeCoverageIgnore - */ - public function isTraitable() - { - return false; - } - - /** - * @codeCoverageIgnore - */ - public function getDebugInfo() - { - return array ( 68 => 9, 64 => 8, 58 => 6, 54 => 5, 47 => 3, 36 => 1,); - } - - public function getSourceContext() - { - return new Source("", "form/result.html.twig", "/home/kali/php/untitled/views/form/result.html.twig"); - } -} diff --git a/index.php b/index.php index 07842fd..4f92388 100755 --- a/index.php +++ b/index.php @@ -32,6 +32,7 @@ $router->get("/form-delete/{id}", [\itguild\forms\app\controllers\FormController $router->get("/form-edit/{id}", [\itguild\forms\app\controllers\FormController::class, "editAction"]); $router->get("/admin/create-form", [\itguild\forms\app\controllers\AdminController::class, "createAction"]); $router->post("/admin/save-form", [\itguild\forms\app\controllers\AdminController::class, "saveForm"]); +$router->post("/admin/handler", [\itguild\forms\app\controllers\AdminController::class, "ajax"]); $dispatcher = new Phroute\Phroute\Dispatcher($router->getData()); $response = $dispatcher->dispatch($_SERVER['REQUEST_METHOD'], parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)); diff --git a/public/js/ajax.js b/public/js/ajax.js new file mode 100644 index 0000000..6e5957a --- /dev/null +++ b/public/js/ajax.js @@ -0,0 +1,12 @@ +function ajaxRequest() { + const request = new XMLHttpRequest(); + request.open("POST", "handler"); + request.addEventListener("load", () => { + const responseText = request.responseText; + const targetElement = document.getElementById("buttonAdd"); + + targetElement.insertAdjacentHTML("beforebegin", responseText); + + }); + request.send(); +} \ No newline at end of file diff --git a/src/app/controllers/AdminController.php b/src/app/controllers/AdminController.php index 535db23..16a5e0b 100644 --- a/src/app/controllers/AdminController.php +++ b/src/app/controllers/AdminController.php @@ -7,6 +7,13 @@ use itguild\forms\app\core\BaseController; use itguild\forms\app\models\FormModel; use itguild\forms\core\cg_view\CgView; +/** +* @var \itguild\forms\ActiveForm $form ; + */ + +use itguild\forms\Form; +use itguild\forms\inputs\TextInput; +use itguild\forms\inputs\TextArea; class AdminController extends BaseController { @@ -31,6 +38,16 @@ class AdminController extends BaseController echo "Форма сохранена!"; } } + public function ajax() + { + $form = new ActiveForm(); + $form->field(TextInput::class, name: "title", params: [ + 'class' => "form-control", + 'placeholder' => 'Название формы' + ]) + ->setLabel("Название формы") + ->render(); + } diff --git a/views/admin/ajax.php b/views/admin/ajax.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/views/admin/ajax.php @@ -0,0 +1 @@ +setLabel("Название формы") ->render(); -$form->field(TextArea::class, name: "params", params: [ - 'class' => "form-control", - 'placeholder' => 'Параметры формы' -]) - ->setLabel("Параметры формы") - ->render(); + + +?> + + + + +field(\itguild\forms\inputs\Button::class, name: "btn-submit", params: [ 'class' => "btn btn-primary ", 'value' => 'Отправить', 'typeInput' => 'submit' ]) ->render(); +$form->endForm(); ?> - -endForm(); ?> diff --git a/views/layouts/admin_layout.php b/views/layouts/admin_layout.php index 050562d..fed82de 100644 --- a/views/layouts/admin_layout.php +++ b/views/layouts/admin_layout.php @@ -9,9 +9,10 @@ <?php echo $title ?> - + +