You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
3.1 KiB
108 lines
3.1 KiB
<?php
|
|
|
|
declare(strict_types = 1);
|
|
|
|
/**
|
|
* @author Robert Strutts <Bob_586@Yahoo.com>
|
|
* @copyright (c) 2025, Robert Strutts
|
|
* @license MIT
|
|
*/
|
|
namespace Project\controllers\app;
|
|
|
|
use \CodeHydrater\base_controller;
|
|
use \CodeHydrater\enums\view_type as ViewType;
|
|
use \CodeHydrater\http\response as Response;
|
|
|
|
/**
|
|
* Description of home_ctrl URL Route: /FOLDER/FILE/METHOD
|
|
* /app/home/name_demo
|
|
*/
|
|
class home_ctrl extends base_controller {
|
|
private $footer;
|
|
|
|
public function init() {
|
|
// FROM on_footer_banner.php in the configs folder...
|
|
if (function_exists("\Project\get_footer")) {
|
|
$this->footer = \Project\get_footer();
|
|
} else {
|
|
$this->footer = "";
|
|
}
|
|
}
|
|
|
|
public function index(): Response {
|
|
$this->html->set_footer($this->footer);
|
|
$this->html->set_author("Robert Strutts, plus ME!");
|
|
|
|
$this->view->set('html', $this->html);
|
|
$this->view->set_template('main');
|
|
$this->view->include("app/header", ViewType::PHP);
|
|
$this->view->include("app/footer", ViewType::PHP);
|
|
$content = $this->view->fetch($this, "app/home_index", ViewType::PHP);
|
|
|
|
$this->response->set_content($content);
|
|
return $this->response;
|
|
}
|
|
|
|
public function name_demo(): Response {
|
|
echo $this->footer;
|
|
|
|
$view = new \CodeHydrater\view();
|
|
$view->set('twig_data', ['name' => "John Doe"]);
|
|
$content = $view->fetch($this, "app/test", ViewType::TWIG);
|
|
|
|
$this->response->set_content($content);
|
|
return $this->response;
|
|
}
|
|
|
|
public function liquid(): Response {
|
|
echo $this->footer;
|
|
$this->view->set('template_assigns', [
|
|
'name' => "James Smith",
|
|
'date' => date('Y-m-d')
|
|
]);
|
|
$content = $this->view->fetch($this, "app/liquid", ViewType::LIQUID);
|
|
|
|
$this->response->set_content($content);
|
|
return $this->response;
|
|
}
|
|
|
|
public function extra(): Response {
|
|
$loaded = \CodeHydrater\extras_booter::tryToEnableFeature("testing", refresh: true);
|
|
if ($loaded === false) {
|
|
$content = "Unable to load Feature...";
|
|
} else {
|
|
$content = "";
|
|
}
|
|
|
|
$this->response->set_content($content);
|
|
return $this->response;
|
|
}
|
|
|
|
public function make_hash(): Response {
|
|
$content = \CodeHydrater\security::do_password_hash("Hello, World");
|
|
|
|
$this->response->set_content($content);
|
|
return $this->response;
|
|
}
|
|
|
|
/**
|
|
* from Routes
|
|
*
|
|
*/
|
|
public function test(int $id): Response {
|
|
$content = "The ID for Test Example is # $id";
|
|
|
|
$this->response->set_content($content);
|
|
return $this->response;
|
|
}
|
|
|
|
public function demo(?string $name="Test", ?int $limit=10, ?int $page=1): Response {
|
|
$content = "DEMO Name: ". \CodeHydrater\bootstrap\safer_io::p($name);
|
|
$content .= "LIMIT = ". $limit;
|
|
$content .= "PAGE = ". $page;
|
|
|
|
$this->response->set_content($content);
|
|
return $this->response;
|
|
}
|
|
|
|
}
|
|
|