2019-08-23 11:39:42 +00:00
|
|
|
<?php
|
2020-04-21 15:59:37 +00:00
|
|
|
class Template{
|
|
|
|
private $assignedValues = [];
|
|
|
|
private $partBuffer;
|
|
|
|
private $path;
|
|
|
|
private $debug;
|
2019-08-23 11:39:42 +00:00
|
|
|
|
|
|
|
function __construct($path = "", $debug = false) {
|
|
|
|
$this->debug = $debug;
|
2020-04-28 07:28:46 +00:00
|
|
|
if (!empty('../app/views/templates/' . $path . '.phtml') && file_exists('../app/views/templates/' . $path . '.phtml')) {
|
2019-08-23 11:39:42 +00:00
|
|
|
$this->path = $path;
|
|
|
|
} else {
|
|
|
|
echo '<pre>';
|
|
|
|
echo 'PHTML: Template File ' . $path . ' not found';
|
|
|
|
echo '</pre>';
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function prepare($searchS, $repleaceS) {
|
|
|
|
if (!empty($searchS)) {
|
|
|
|
$this->assignedValues[strtoupper($searchS)] = $repleaceS;
|
|
|
|
}
|
|
|
|
echo ($this->debug == true ? var_dump($this->assignedValues) : '');
|
|
|
|
}
|
|
|
|
|
|
|
|
function render() {
|
|
|
|
extract($this->assignedValues);
|
2020-04-21 15:59:37 +00:00
|
|
|
if (!empty('../app/controls/' . $this->path . '.php') && file_exists('../app/controls/' . $this->path . '.php')) {
|
|
|
|
include('../app/controls/' . $this->path . '.php');
|
2019-08-23 11:39:42 +00:00
|
|
|
}
|
2020-04-28 07:28:46 +00:00
|
|
|
require_once('../app/views/templates/' . $this->path . '.phtml');
|
2019-08-23 11:39:42 +00:00
|
|
|
}
|
|
|
|
}
|