diff --git a/src/Controller/Component.php b/src/Controller/Component.php index 12ba059..7077175 100644 --- a/src/Controller/Component.php +++ b/src/Controller/Component.php @@ -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);