diff --git a/Web/Presenters/OpenVKPresenter.php b/Web/Presenters/OpenVKPresenter.php index 17e36e8a..380dd3cd 100755 --- a/Web/Presenters/OpenVKPresenter.php +++ b/Web/Presenters/OpenVKPresenter.php @@ -8,6 +8,7 @@ use Latte\Engine as TemplatingEngine; use openvk\Web\Models\Entities\IP; use openvk\Web\Themes\Themepacks; use openvk\Web\Models\Repositories\{IPs, Users, APITokens, Tickets}; +use WhichBrowser; abstract class OpenVKPresenter extends SimplePresenter { @@ -34,9 +35,10 @@ abstract class OpenVKPresenter extends SimplePresenter ])); } - protected function setTempTheme(string $theme): void + protected function setSessionTheme(string $theme, bool $once = false): void { - Session::i()->set("_tempTheme", $theme); + if(once) Session::i()->set("_tempTheme", $theme); + else Session::i()->set("_sessionTheme", $theme); } protected function flashFail(string $type, string $title, ?string $message = NULL, ?int $code = NULL, bool $json = false): void @@ -234,10 +236,17 @@ abstract class OpenVKPresenter extends SimplePresenter { parent::onBeforeRender(); + $whichbrowser = new WhichBrowser\Parser(getallheaders()); + $mobiletheme = OPENVK_ROOT_CONF["openvk"]["preferences"]["defaultMobileTheme"]; + if($mobiletheme && $whichbrowser->isType('mobile') && Session::i()->get("_tempTheme") == null) + $this->setSessionTheme($mobiletheme); + $theme = NULL; if(Session::i()->get("_tempTheme")) { $theme = Themepacks::i()[Session::i()->get("_tempTheme", "ovk")]; Session::i()->set("_tempTheme", NULL); + } else if(Session::i()->get("_sessionTheme")) { + $theme = Themepacks::i()[Session::i()->get("_sessionTheme", "ovk")]; } else if($this->requestParam("themePreview")) { $theme = Themepacks::i()[$this->requestParam("themePreview")]; } else if($this->user->identity !== null && $this->user->identity->getTheme()) { diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index ddcddb95..fec3798f 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -354,7 +354,7 @@ final class UserPresenter extends OpenVKPresenter if (isset(Themepacks::i()[$this->postParam("style")]) || $this->postParam("style") === Themepacks::DEFAULT_THEME_ID) { $user->setStyle($this->postParam("style")); - $this->setTempTheme($this->postParam("style")); + $this->setSessionTheme($this->postParam("style")); } if ($this->postParam("style_avatar") <= 2 && $this->postParam("style_avatar") >= 0) diff --git a/openvk-example.yml b/openvk-example.yml index 0f8a9b55..df9c55ef 100644 --- a/openvk-example.yml +++ b/openvk-example.yml @@ -59,6 +59,7 @@ openvk: bellsAndWhistles: fartscroll: false testLabel: false + defaultMobileTheme: "" telemetry: plausible: