mirror of
https://github.com/openvk/openvk
synced 2024-11-13 10:39:24 +03:00
Themes: Now you should not reload page twice after changeing theme
Also added a setTempTheme global presenter function
This commit is contained in:
parent
f555c781bf
commit
1dff89972e
4 changed files with 25 additions and 8 deletions
|
@ -6,6 +6,7 @@ use Chandler\Session\Session;
|
|||
use Chandler\Security\Authenticator;
|
||||
use Latte\Engine as TemplatingEngine;
|
||||
use openvk\Web\Models\Entities\IP;
|
||||
use openvk\Web\Themes\Themepacks;
|
||||
use openvk\Web\Models\Repositories\{IPs, Users, APITokens};
|
||||
|
||||
abstract class OpenVKPresenter extends SimplePresenter
|
||||
|
@ -32,6 +33,11 @@ abstract class OpenVKPresenter extends SimplePresenter
|
|||
"code" => $code,
|
||||
]));
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
|
@ -216,12 +222,21 @@ abstract class OpenVKPresenter extends SimplePresenter
|
|||
$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->getTheme())
|
||||
$this->template->theme = $this->user->identity->getTheme();
|
||||
|
||||
// Знаю, каша ебаная, целестора рефактор всё равно сделает :)))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -273,7 +273,10 @@ final class UserPresenter extends OpenVKPresenter
|
|||
$this->flashFail("succ", tr("voucher_good"), tr("voucher_redeemed"));
|
||||
} else if($_GET['act'] === "interface") {
|
||||
if (isset(Themepacks::i()[$this->postParam("style")]) || $this->postParam("style") === Themepacks::DEFAULT_THEME_ID)
|
||||
$user->setStyle($this->postParam("style"));
|
||||
{
|
||||
$user->setStyle($this->postParam("style"));
|
||||
$this->setTempTheme($this->postParam("style"));
|
||||
}
|
||||
|
||||
if ($this->postParam("style_avatar") <= 2 && $this->postParam("style_avatar") >= 0)
|
||||
$user->setStyle_Avatar((int)$this->postParam("style_avatar"));
|
||||
|
@ -308,10 +311,10 @@ final class UserPresenter extends OpenVKPresenter
|
|||
throw $ex;
|
||||
}
|
||||
|
||||
$this->flash(
|
||||
$this->flash(
|
||||
"succ",
|
||||
"Изменения сохранены",
|
||||
"Новые данные появятся на вашей странице.<br/>Если вы изменили стиль, перезагрузите страницу."
|
||||
"Новые данные появятся на вашей странице."
|
||||
);
|
||||
}
|
||||
$this->template->mode = in_array($this->queryParam("act"), [
|
||||
|
|
|
@ -16,9 +16,8 @@
|
|||
{css "css/nsfw-posts.css"}
|
||||
{/if}
|
||||
|
||||
{if !is_null($thisUser->getTheme())}
|
||||
{var theme = $thisUser->getTheme()}
|
||||
{if $theme->inheritDefault()}
|
||||
{if $theme !== null}
|
||||
{if $theme->inheritDefault()}
|
||||
{css "css/style.css"}
|
||||
{css "css/dialog.css"}
|
||||
{css "css/notifications.css"}
|
||||
|
|
2
locales
2
locales
|
@ -1 +1 @@
|
|||
Subproject commit ef1b7ab803b56a02df670d91d7c22b3e509e6779
|
||||
Subproject commit ce4ede6f8c6cb42f2421969fab23da933c81b52b
|
Loading…
Reference in a new issue