Added Method to set a template

This commit is contained in:
kolaente 2017-04-30 00:12:32 +02:00 committed by konrad
parent a15b1d92aa
commit a784c5a574
2 changed files with 9 additions and 47 deletions

View File

@ -7,9 +7,8 @@ class page extends Smarty
private $baseUrl;
private $responseCode;
private $title;
private $tplAssign = [];
private $templateFile;
private $domain;
private $template;
//url fkt
public function setUrl($url)
@ -68,53 +67,15 @@ class page extends Smarty
return $this->title;
}
//templatekram
/*public function assign($key, $value, $add = false)
//Template
public function setTemplate($template)
{
if (array_key_exists($key, $this->tplAssign) && $add)
{
$this->tplAssign[$key] .= $value;
}elseif (array_key_exists($key, $this->tplAssign) && !$add)
{
$this->tplAssign[$key] = $value;
} elseif (!array_key_exists($key, $this->tplAssign))
{
$this->tplAssign[$key] = $value;
}
}*/
public function getTplAssign()
{
return $this->tplAssign;
$this->template = $template;
}
//Template Parsen
public function setTemplateFile($templateFile)
public function getTemplate()
{
$this->templateFile = $templateFile;
}
public function parseTpl()
{
$tplFile = file_get_contents($this->templateFile);
$tplKeys = $this->getTplAssign();
function page_key($key)
{
$tplKeys = $GLOBALS['page']->getTplAssign();
$key_tpl = $key[0];
$key_tpl = str_replace('{', '', $key_tpl);
$key_tpl = str_replace('}', '', $key_tpl);
if (array_key_exists($key_tpl, $tplKeys))
{
return $tplKeys[$key_tpl];
}
else
{
return '';
}
}
echo preg_replace_callback('/{[A-Za-z0-9_:,\-\|]+}/', 'page_key', $tplFile);
return $this->template;
}
public function getDomain()

View File

@ -90,7 +90,7 @@ if (file_exists('inc/config.yml'))
$page->setContent(file_get_contents('inc/System/404.txt'));
}
//Copyright bauen
//Build Copyright
$founded = date('Y', filemtime('inc/config.yml'));
$copy = $founded;
if ($founded != date('Y'))
@ -99,11 +99,12 @@ if (file_exists('inc/config.yml'))
}
$page->assign('copyright', $copy);
// dat ganze ausgeben
//Finally render everything
http_response_code($page->getResponseCode());
$page->assign($MCONF['tpl_title'], $page->getTitle() . ' | ' . $MCONF['title']);
$page->assign($MCONF['tpl_content'], $page->getContent());
$page->assign($MCONF['tpl_webUri'], $MCONF['web_uri']);
$page->assign('template', $page->getTemplate());
$page->display($MCONF['template']);
}
} else