Определение шаблона по cookie

This commit is contained in:
Podlesnov Phedor 2022-02-01 14:44:53 +03:00
parent a8cfe7a685
commit 517dc477ed

View file

@ -85,11 +85,15 @@ class Controller_Component
}
}
public function getTemplateName($_registry/*: Settings*/) {
return (isset($_COOKIE['with_template']) && preg_match('/^[\w\d-]{3,20}$/', $_COOKIE['with_template'])) ? $_COOKIE['with_template'] : $_registry->readKey(array('system', 'template'));
}
public function getView($name)
{
//
$registry/*: Settings*/ = $this->registry;
$template = ($this->template) ? $this->template : $registry->readKey(array('system', 'template'));
$template = ($this->template) ? $this->template : $this->getTemplateName($registry);
$selected = null;
foreach ($this->viewPath as $index => $viewPath) {
@ -129,7 +133,8 @@ class Controller_Component
public function getTemplatePath($name) {
$registry/*: Settings*/ = $this->registry;
$template = ($this->template) ? $this->template : $registry->readKey(array('system', 'template'));
// Брать настройки из куков если есть
$template = ($this->template) ? $this->template : $this->getTemplateName($registry);
foreach ($this->viewPath as $index => $viewPath) {
if(is_dir(Path::join($this->viewPath[$index], 'templates', $template))) {
return Path::join($this->viewPath[$index], 'templates', $template, $name);