mirror of https://github.com/Mowie/Mowie
Added Method to set a template
This commit is contained in:
parent
a15b1d92aa
commit
a784c5a574
51
inc/page.php
51
inc/page.php
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue