diff --git a/.gitignore b/.gitignore
index 0468705a..f151ef56 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,5 +6,8 @@ Web/static/js/node_modules
tmp/*
!tmp/.gitkeep
+!tmp/themepack_artifacts/.gitkeep
+themepacks/*
+!themepacks/.gitkeep
storage/*
!storage/.gitkeep
diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php
index 1833fec4..c5c1f488 100644
--- a/Web/Models/Entities/User.php
+++ b/Web/Models/Entities/User.php
@@ -1,5 +1,6 @@
getRecord()->id;
}
- function getStyle(): int
+ function getStyle(): string
{
return $this->getRecord()->style;
}
+ function getTheme(): ?Themepack
+ {
+ return Themepacks::i()[$this->getStyle()] ?? NULL;
+ }
+
function getStyleAvatar(): int
{
return $this->getRecord()->style_avatar;
diff --git a/Web/Presenters/ThemepacksPresenter.php b/Web/Presenters/ThemepacksPresenter.php
new file mode 100644
index 00000000..de960768
--- /dev/null
+++ b/Web/Presenters/ThemepacksPresenter.php
@@ -0,0 +1,35 @@
+notFound();
+ else
+ $theme = Themepacks::i()[$themepack];
+
+ if($resClass === "resource") {
+ $data = $theme->fetchStaticResource($resource);
+ } else if($resClass === "stylesheet") {
+ if($resource !== "styles.css")
+ $this->notFound();
+ else
+ $data = $theme->fetchStyleSheet();
+ } else {
+ $this->notFound();
+ }
+
+ if(!$data)
+ $this->notFound();
+
+ header("Content-Type: " . system_extension_mime_type($resource));
+ header("Content-Size: " . strlen($data));
+ header("Cache-Control: public, no-transform, max-age=31536000");
+ exit($data);
+ }
+}
diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php
index 46ac7040..27951d80 100644
--- a/Web/Presenters/UserPresenter.php
+++ b/Web/Presenters/UserPresenter.php
@@ -1,6 +1,7 @@
notFound();
- else
+
$user = $this->users->get($id);
if($_SERVER["REQUEST_METHOD"] === "POST") {
if($_GET['act'] === "main" || $_GET['act'] == NULL) {
@@ -215,78 +216,79 @@ final class UserPresenter extends OpenVKPresenter
if(!$id)
$this->notFound();
- else
- $user = $this->users->get($id);
- if($_SERVER["REQUEST_METHOD"] === "POST") {
- if($_GET['act'] === "main" || $_GET['act'] == NULL) {
- if($this->postParam("old_pass") && $this->postParam("new_pass") && $this->postParam("repeat_pass")) {
- if($this->postParam("new_pass") === $this->postParam("repeat_pass")) {
- if(!$this->user->identity->getChandlerUser()->updatePassword($this->postParam("new_pass"), $this->postParam("old_pass")))
- $this->flashFail("err", "Ошибка", "Старый пароль не совпадает.");
- } else {
- $this->flashFail("err", "Ошибка", "Новые пароли не совпадают.");
- }
+
+ $user = $this->users->get($id);
+ if($_SERVER["REQUEST_METHOD"] === "POST") {
+ if($_GET['act'] === "main" || $_GET['act'] == NULL) {
+ if($this->postParam("old_pass") && $this->postParam("new_pass") && $this->postParam("repeat_pass")) {
+ if($this->postParam("new_pass") === $this->postParam("repeat_pass")) {
+ if(!$this->user->identity->getChandlerUser()->updatePassword($this->postParam("new_pass"), $this->postParam("old_pass")))
+ $this->flashFail("err", "Ошибка", "Старый пароль не совпадает.");
+ } else {
+ $this->flashFail("err", "Ошибка", "Новые пароли не совпадают.");
}
-
- if(!$user->setShortCode(empty($this->postParam("sc")) ? NULL : $this->postParam("sc")))
- $this->flashFail("err", "Ошибка", "Короткий адрес имеет некорректный формат.");
- }elseif($_GET['act'] === "privacy") {
- $settings = [
- "page.read",
- "page.info.read",
- "groups.read",
- "photos.read",
- "videos.read",
- "notes.read",
- "friends.read",
- "friends.add",
- "wall.write",
- ];
- foreach($settings as $setting) {
- $input = $this->postParam(str_replace(".", "_", $setting));
- $user->setPrivacySetting($setting, min(3, abs($input ?? $user->getPrivacySetting($setting))));
- }
- }elseif($_GET['act'] === "interface") {
- if ($this->postParam("style") <= 20 && $this->postParam("style") >= 0)
- $user->setStyle((int)$this->postParam("style"));
-
- if ($this->postParam("style_avatar") <= 2 && $this->postParam("style_avatar") >= 0)
- $user->setStyle_Avatar((int)$this->postParam("style_avatar"));
-
- if (in_array($this->postParam("rating"), [0, 1]))
- $user->setShow_Rating((int) $this->postParam("rating"));
- }elseif($_GET['act'] === "lMenu") {
- $settings = [
- "menu_bildoj" => "photos",
- "menu_filmetoj" => "videos",
- "menu_mesagoj" => "messages",
- "menu_notatoj" => "notes",
- "menu_grupoj" => "groups",
- "menu_novajoj" => "news",
- ];
- foreach($settings as $checkbox => $setting)
- $user->setLeftMenuItemStatus($setting, $this->checkbox($checkbox));
}
- try {
- $user->save();
- } catch(\PDOException $ex) {
- if($ex->getCode() == 23000)
- $this->flashFail("err", "Ошибка", "Данный короткий адрес уже занят.");
- else
- throw $ex;
+ if(!$user->setShortCode(empty($this->postParam("sc")) ? NULL : $this->postParam("sc")))
+ $this->flashFail("err", "Ошибка", "Короткий адрес имеет некорректный формат.");
+ }elseif($_GET['act'] === "privacy") {
+ $settings = [
+ "page.read",
+ "page.info.read",
+ "groups.read",
+ "photos.read",
+ "videos.read",
+ "notes.read",
+ "friends.read",
+ "friends.add",
+ "wall.write",
+ ];
+ foreach($settings as $setting) {
+ $input = $this->postParam(str_replace(".", "_", $setting));
+ $user->setPrivacySetting($setting, min(3, abs($input ?? $user->getPrivacySetting($setting))));
}
+ }elseif($_GET['act'] === "interface") {
+ if (isset(Themepacks::i()[$this->postParam("style")]) || $this->postParam("style") === Themepacks::DEFAULT_THEME_ID)
+ $user->setStyle($this->postParam("style"));
- $this->flash(
- "succ",
- "Изменения сохранены",
- "Новые данные появятся на вашей странице.
Если вы изменили стиль, перезагрузите страницу."
- );
+ if ($this->postParam("style_avatar") <= 2 && $this->postParam("style_avatar") >= 0)
+ $user->setStyle_Avatar((int)$this->postParam("style_avatar"));
+
+ if (in_array($this->postParam("rating"), [0, 1]))
+ $user->setShow_Rating((int) $this->postParam("rating"));
+ }elseif($_GET['act'] === "lMenu") {
+ $settings = [
+ "menu_bildoj" => "photos",
+ "menu_filmetoj" => "videos",
+ "menu_mesagoj" => "messages",
+ "menu_notatoj" => "notes",
+ "menu_grupoj" => "groups",
+ "menu_novajoj" => "news",
+ ];
+ foreach($settings as $checkbox => $setting)
+ $user->setLeftMenuItemStatus($setting, $this->checkbox($checkbox));
}
- $this->template->mode = in_array($this->queryParam("act"), [
- "main", "privacy", "finance", "interface"
- ]) ? $this->queryParam("act")
- : "main";
- $this->template->user = $user;
+
+ try {
+ $user->save();
+ } catch(\PDOException $ex) {
+ if($ex->getCode() == 23000)
+ $this->flashFail("err", "Ошибка", "Данный короткий адрес уже занят.");
+ else
+ throw $ex;
+ }
+
+ $this->flash(
+ "succ",
+ "Изменения сохранены",
+ "Новые данные появятся на вашей странице.
Если вы изменили стиль, перезагрузите страницу."
+ );
+ }
+ $this->template->mode = in_array($this->queryParam("act"), [
+ "main", "privacy", "finance", "interface"
+ ]) ? $this->queryParam("act")
+ : "main";
+ $this->template->user = $user;
+ $this->template->themes = Themepacks::i()->getThemeList();
}
}
diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.xml
index 601a13cb..77cc47df 100644
--- a/Web/Presenters/templates/@layout.xml
+++ b/Web/Presenters/templates/@layout.xml
@@ -12,74 +12,9 @@
{script "js/node_modules/umbrellajs/umbrella.min.js"}
{script "js/openvk.cls.js"}
{ifset $thisUser}
- {var style = (int) ($_GET['__ovkStyleOverride'] ?? $thisUser->getStyle())}
-
- {if $style == 1}
- {css "css/vkontakte.css"}
- {/if}
- {if $style == 2}
- {css "css/ovkdan.5.css"}
- {/if}
- {if $style == 3}
- {css "css/vkontakte.css"}
- {css "css/vkontakte2006.css"}
- {/if}
- {if $style == 4}
- {css "css/ovkg.css"}
- {/if}
- {if $style == 5}
- {css "css/black.css"}
- {/if}
- {if $style == 6}
- {css "css/ash_oss_themes/vk2015.2.css"}
- {/if}
- {if $style == 7}
- {css "css/spacepink.css"}
- {/if}
- {if $style == 9}
- {css "css/vriska.css"}
- {/if}
- {if $style == 8}
- {css "css/ash_oss_themes/vk2015.2.css"}
- {/if}
- {if $style == 10}
- {css "css/ash_oss_themes/ВСоюзе.css"}
- {/if}
- {if $style == 11}
- {css "css/ash_oss_themes/fb2005.css"}
- {/if}
- {if $style == 12}
- {css "css/ooer.css"}
- {/if}
- {if $style == 13}
- {css "css/ash_oss_themes/Twitter2007.css"}
- {/if}
- {if $style == 14}
- {css "css/kos.css"}
- {/if}
- {if $style == 15}
- {css "css/ash_oss_themes/pager.css"}
- {/if}
- {if $style == 16}
- {css "css/ash_oss_themes/vkdark.css"}
- {/if}
- {if $style == 17}
- {css "css/ash_oss_themes/vtlenu.css"}
- {/if}
- {if $style == 18}
- {css "css/ash_oss_themes/Fb2006.css"}
- {/if}
- {if $style == 19}
- {css "css/ash_oss_themes/vkdefenders08.css"}
- {/if}
- {if $style == 20}
- {css "css/ash_oss_themes/tlenta.css"}
- {/if}
- {if $thisUser->getStyleAvatar() == 1}
- {css "css/avatar.1.css"}
- {/if}
- {if $thisUser->getStyleAvatar() == 2}
- {css "css/avatar.2.css"}
+ {if !is_null($thisUser->getTheme())}
+ {var theme = $thisUser->getTheme()}
+
{/if}
{/ifset}
@@ -105,11 +40,7 @@