mirror of
https://github.com/openvk/openvk
synced 2024-11-11 01:19:53 +03:00
Make "themePreview" work correctly with themes that override templates
This commit is contained in:
parent
8b86fdecd3
commit
e73857cdc3
1 changed files with 13 additions and 19 deletions
|
@ -34,10 +34,10 @@ abstract class OpenVKPresenter extends SimplePresenter
|
|||
]));
|
||||
}
|
||||
|
||||
protected function setTempTheme(string $theme): void
|
||||
{
|
||||
Session::i()->set("_tempTheme", $theme);
|
||||
}
|
||||
protected function setTempTheme(string $theme): void
|
||||
{
|
||||
Session::i()->set("_tempTheme", $theme);
|
||||
}
|
||||
|
||||
protected function flashFail(string $type, string $title, ?string $message = NULL, ?int $code = NULL): void
|
||||
{
|
||||
|
@ -221,25 +221,19 @@ abstract class OpenVKPresenter extends SimplePresenter
|
|||
{
|
||||
parent::onBeforeRender();
|
||||
|
||||
if(!is_null($this->user)) {
|
||||
$theme = $this->user->identity->getTheme();
|
||||
if(!is_null($theme) && $theme->overridesTemplates()) {
|
||||
$this->template->_templatePath = $theme->getBaseDir() . "/tpl";
|
||||
}
|
||||
}
|
||||
if(Session::i()->get("_tempTheme"))
|
||||
$theme = Themepacks::i()[Session::i()->get("_tempTheme", "ovk")];
|
||||
else if($this->requestParam("themePreview"))
|
||||
$theme = Themepacks::i()[$this->requestParam("themePreview")];
|
||||
else if($this->user->identity !== null && $this->user->identity->getTheme())
|
||||
$theme = $this->user->identity->getTheme();
|
||||
|
||||
if(!is_null($theme) && $theme->overridesTemplates())
|
||||
$this->template->_templatePath = $theme->getBaseDir() . "/tpl";
|
||||
|
||||
if(!is_null(Session::i()->get("_error"))) {
|
||||
$this->template->flashMessage = json_decode(Session::i()->get("_error"));
|
||||
Session::i()->set("_error", NULL);
|
||||
}
|
||||
|
||||
if(Session::i()->get("_tempTheme"))
|
||||
$this->template->theme = Themepacks::i()[Session::i()->get("_tempTheme", "ovk")];
|
||||
else if($this->requestParam("themePreview"))
|
||||
$this->template->theme = Themepacks::i()[$this->requestParam("themePreview")];
|
||||
else if($this->user->identity !== null && $this->user->identity->getTheme())
|
||||
$this->template->theme = $this->user->identity->getTheme();
|
||||
|
||||
// Знаю, каша ебаная, целестора рефактор всё равно сделает :)))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue