Определение шаблона по cookie
This commit is contained in:
parent
a8cfe7a685
commit
517dc477ed
1 changed files with 7 additions and 2 deletions
|
|
@ -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)
|
public function getView($name)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
$registry/*: Settings*/ = $this->registry;
|
$registry/*: Settings*/ = $this->registry;
|
||||||
$template = ($this->template) ? $this->template : $registry->readKey(array('system', 'template'));
|
$template = ($this->template) ? $this->template : $this->getTemplateName($registry);
|
||||||
|
|
||||||
$selected = null;
|
$selected = null;
|
||||||
foreach ($this->viewPath as $index => $viewPath) {
|
foreach ($this->viewPath as $index => $viewPath) {
|
||||||
|
|
@ -129,7 +133,8 @@ class Controller_Component
|
||||||
|
|
||||||
public function getTemplatePath($name) {
|
public function getTemplatePath($name) {
|
||||||
$registry/*: Settings*/ = $this->registry;
|
$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) {
|
foreach ($this->viewPath as $index => $viewPath) {
|
||||||
if(is_dir(Path::join($this->viewPath[$index], 'templates', $template))) {
|
if(is_dir(Path::join($this->viewPath[$index], 'templates', $template))) {
|
||||||
return Path::join($this->viewPath[$index], 'templates', $template, $name);
|
return Path::join($this->viewPath[$index], 'templates', $template, $name);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue