admin themes
This commit is contained in:
@ -2,9 +2,14 @@
|
||||
|
||||
namespace kernel;
|
||||
|
||||
use app\helpers\Debug;
|
||||
|
||||
class CgView
|
||||
{
|
||||
public string $viewPath = '';
|
||||
|
||||
public string $layoutPath = '';
|
||||
public array $varToLayout = [];
|
||||
public bool|string $layout = false;
|
||||
|
||||
public function __construct()
|
||||
@ -26,29 +31,47 @@ class CgView
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function addVarToLayout($key, $value): void
|
||||
{
|
||||
$this->varToLayout[$key] = $value;
|
||||
}
|
||||
|
||||
private function createContent(string $view, array $data = []): false|string
|
||||
{
|
||||
ob_start();
|
||||
|
||||
foreach ($data as $key => $datum){
|
||||
foreach ($data as $key => $datum) {
|
||||
${"$key"} = $datum;
|
||||
}
|
||||
|
||||
include ($this->viewPath . $view);
|
||||
include($this->viewPath . $view);
|
||||
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean ();
|
||||
ob_end_clean();
|
||||
|
||||
ob_start();
|
||||
|
||||
$file_content = $content;
|
||||
|
||||
if ($this->layout){
|
||||
if (file_exists($this->viewPath . $this->layout)){
|
||||
include ($this->viewPath . $this->layout);
|
||||
$layoutPath = $this->viewPath;
|
||||
|
||||
if ($this->layout) {
|
||||
|
||||
if ($this->layoutPath !== '') {
|
||||
|
||||
$layoutPath = $this->layoutPath;
|
||||
}
|
||||
if (file_exists($layoutPath . $this->layout)) {
|
||||
if ($this->varToLayout){
|
||||
foreach ($this->varToLayout as $key => $datum) {
|
||||
${"$key"} = $datum;
|
||||
}
|
||||
}
|
||||
include($layoutPath . $this->layout);
|
||||
$file_content = ob_get_contents();
|
||||
}
|
||||
}
|
||||
ob_end_clean ();
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
return $file_content;
|
||||
}
|
||||
|
Reference in New Issue
Block a user