PHP_SMART_HOME_V3/app/models/Partial.php

35 lines
821 B
PHP
Raw Normal View History

2019-08-23 11:39:42 +00:00
<?php
class Partial{
2020-04-21 15:59:37 +00:00
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-21 15:59:37 +00:00
if (!empty('../app/templates/part/' . $path . '.phtml') && file_exists('../app/templates/part/' . $path . '.phtml')) {
2019-08-23 11:39:42 +00:00
$this->path = $path;
} else {
echo '<pre>';
echo 'PHTML: Parial 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() {
if (!empty($this->assignedValues)){
extract($this->assignedValues);
}
2020-04-21 15:59:37 +00:00
require('../app/templates/part/' . $this->path . '.phtml');
2019-08-23 11:39:42 +00:00
}
}