PHP_SMART_HOME_V3/app/class/Template.php

35 lines
928 B
PHP
Raw Normal View History

2019-08-23 11:39:42 +00:00
<?php
class Template extends Partial{
var $assignedValues = [];
var $partBuffer;
var $path;
var $debug;
function __construct($path = "", $debug = false) {
$this->debug = $debug;
2019-09-19 12:48:31 +00:00
if (!empty('app/templates/' . $path . '.phtml') && file_exists('app/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);
2019-09-19 12:48:31 +00:00
if (!empty('app/controls/' . $this->path . '.php') && file_exists('app/controls/' . $this->path . '.php')) {
2020-02-18 20:30:44 +00:00
include('app/controls/' . $this->path . '.php');
2019-08-23 11:39:42 +00:00
}
2019-09-19 12:48:31 +00:00
require_once('app/templates/' . $this->path . '.phtml');
2019-08-23 11:39:42 +00:00
}
}