mirror of
https://github.com/openvk/openvk
synced 2024-11-14 02:59:12 +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
|
||||
|
@ -33,6 +34,11 @@ abstract class OpenVKPresenter extends SimplePresenter
|
|||
]));
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
$this->flash($type, $title, $message, $code);
|
||||
|
@ -223,5 +229,14 @@ abstract class OpenVKPresenter extends SimplePresenter
|
|||
$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"));
|
||||
$this->setTempTheme($this->postParam("style"));
|
||||
}
|
||||
|
||||
if ($this->postParam("style_avatar") <= 2 && $this->postParam("style_avatar") >= 0)
|
||||
$user->setStyle_Avatar((int)$this->postParam("style_avatar"));
|
||||
|
@ -311,7 +314,7 @@ final class UserPresenter extends OpenVKPresenter
|
|||
$this->flash(
|
||||
"succ",
|
||||
"Изменения сохранены",
|
||||
"Новые данные появятся на вашей странице.<br/>Если вы изменили стиль, перезагрузите страницу."
|
||||
"Новые данные появятся на вашей странице."
|
||||
);
|
||||
}
|
||||
$this->template->mode = in_array($this->queryParam("act"), [
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
{css "css/nsfw-posts.css"}
|
||||
{/if}
|
||||
|
||||
{if !is_null($thisUser->getTheme())}
|
||||
{var theme = $thisUser->getTheme()}
|
||||
{if $theme !== null}
|
||||
{if $theme->inheritDefault()}
|
||||
{css "css/style.css"}
|
||||
{css "css/dialog.css"}
|
||||
|
|
2
locales
2
locales
|
@ -1 +1 @@
|
|||
Subproject commit ef1b7ab803b56a02df670d91d7c22b3e509e6779
|
||||
Subproject commit ce4ede6f8c6cb42f2421969fab23da933c81b52b
|
Loading…
Reference in a new issue