mirror of
https://github.com/Mowie/Mowie
synced 2024-06-07 11:19:39 +00:00
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 $baseUrl;
|
||||||
private $responseCode;
|
private $responseCode;
|
||||||
private $title;
|
private $title;
|
||||||
private $tplAssign = [];
|
|
||||||
private $templateFile;
|
|
||||||
private $domain;
|
private $domain;
|
||||||
|
private $template;
|
||||||
|
|
||||||
//url fkt
|
//url fkt
|
||||||
public function setUrl($url)
|
public function setUrl($url)
|
||||||
|
@ -68,53 +67,15 @@ class page extends Smarty
|
||||||
return $this->title;
|
return $this->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
//templatekram
|
//Template
|
||||||
/*public function assign($key, $value, $add = false)
|
public function setTemplate($template)
|
||||||
{
|
{
|
||||||
if (array_key_exists($key, $this->tplAssign) && $add)
|
$this->template = $template;
|
||||||
{
|
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Template Parsen
|
public function getTemplate()
|
||||||
public function setTemplateFile($templateFile)
|
|
||||||
{
|
{
|
||||||
$this->templateFile = $templateFile;
|
return $this->template;
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDomain()
|
public function getDomain()
|
||||||
|
|
|
@ -90,7 +90,7 @@ if (file_exists('inc/config.yml'))
|
||||||
$page->setContent(file_get_contents('inc/System/404.txt'));
|
$page->setContent(file_get_contents('inc/System/404.txt'));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Copyright bauen
|
//Build Copyright
|
||||||
$founded = date('Y', filemtime('inc/config.yml'));
|
$founded = date('Y', filemtime('inc/config.yml'));
|
||||||
$copy = $founded;
|
$copy = $founded;
|
||||||
if ($founded != date('Y'))
|
if ($founded != date('Y'))
|
||||||
|
@ -99,11 +99,12 @@ if (file_exists('inc/config.yml'))
|
||||||
}
|
}
|
||||||
$page->assign('copyright', $copy);
|
$page->assign('copyright', $copy);
|
||||||
|
|
||||||
// dat ganze ausgeben
|
//Finally render everything
|
||||||
http_response_code($page->getResponseCode());
|
http_response_code($page->getResponseCode());
|
||||||
$page->assign($MCONF['tpl_title'], $page->getTitle() . ' | ' . $MCONF['title']);
|
$page->assign($MCONF['tpl_title'], $page->getTitle() . ' | ' . $MCONF['title']);
|
||||||
$page->assign($MCONF['tpl_content'], $page->getContent());
|
$page->assign($MCONF['tpl_content'], $page->getContent());
|
||||||
$page->assign($MCONF['tpl_webUri'], $MCONF['web_uri']);
|
$page->assign($MCONF['tpl_webUri'], $MCONF['web_uri']);
|
||||||
|
$page->assign('template', $page->getTemplate());
|
||||||
$page->display($MCONF['template']);
|
$page->display($MCONF['template']);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user