Add themepack option to not inherit default themepack styles

This commit is contained in:
Alma Armas 2020-11-22 10:06:49 +00:00
parent 2e8ddc090d
commit 7314f369af
2 changed files with 26 additions and 4 deletions

View file

@ -7,15 +7,22 @@
<link rel="shortcut icon" href="/assets/packages/static/openvk/img/icon.ico" /> <link rel="shortcut icon" href="/assets/packages/static/openvk/img/icon.ico" />
<meta name="application-name" content="OpenVK" /> <meta name="application-name" content="OpenVK" />
<meta n:ifset="$csrfToken" name="csrf" value="{$csrfToken}" /> <meta n:ifset="$csrfToken" name="csrf" value="{$csrfToken}" />
{css "css/style.css"}
{css "css/dialog.css"}
{script "js/node_modules/jquery/dist/jquery.min.js"} {script "js/node_modules/jquery/dist/jquery.min.js"}
{script "js/node_modules/umbrellajs/umbrella.min.js"} {script "js/node_modules/umbrellajs/umbrella.min.js"}
{script "js/openvk.cls.js"} {script "js/openvk.cls.js"}
{ifset $thisUser} {ifset $thisUser}
{if !is_null($thisUser->getTheme())} {if !is_null($thisUser->getTheme())}
{var theme = $thisUser->getTheme()} {var theme = $thisUser->getTheme()}
{if $theme->inheritDefault()}
{css "css/style.css"}
{css "css/dialog.css"}
{/if}
<link rel="stylesheet" href="/themepack/{$theme->getId()}/{$theme->getVersion()}/stylesheet/styles.css" /> <link rel="stylesheet" href="/themepack/{$theme->getId()}/{$theme->getVersion()}/stylesheet/styles.css" />
{else}
{css "css/style.css"}
{css "css/dialog.css"}
{/if} {/if}
{if $thisUser->getStyleAvatar() == 1} {if $thisUser->getStyleAvatar() == 1}
@ -24,6 +31,9 @@
{if $thisUser->getStyleAvatar() == 2} {if $thisUser->getStyleAvatar() == 2}
{css "css/avatar.2.css"} {css "css/avatar.2.css"}
{/if} {/if}
{else}
{css "css/style.css"}
{css "css/dialog.css"}
{/ifset} {/ifset}
{ifset headIncludes}{include headIncludes}{/ifset} {ifset headIncludes}{include headIncludes}{/ifset}
@ -48,6 +58,11 @@
<div class="page_header"> <div class="page_header">
<a href="/" class="home_button" title="OpenVK">openvk</a> <a href="/" class="home_button" title="OpenVK">openvk</a>
<div n:if="isset($thisUser) ? !$thisUser->isBanned() : true" class="header_navigation"> <div n:if="isset($thisUser) ? !$thisUser->isBanned() : true" class="header_navigation">
{if $_SERVER['SERVER_NAME'] == "openvk2.veselcraft.ru"}
<div class="link">
<a href="https://openvk.su/"><b>new domain!</b></a>
</div>
{/if}
{ifset $thisUser} {ifset $thisUser}
<div class="link"> <div class="link">
<a href="/">{_"header_home"}</a> <a href="/">{_"header_home"}</a>

View file

@ -5,14 +5,16 @@ class Themepack
{ {
private $id; private $id;
private $ver; private $ver;
private $inh;
private $meta; private $meta;
private $home; private $home;
private $enabled; private $enabled;
function __construct(string $id, string $ver, bool $enabled, object $meta) function __construct(string $id, string $ver, bool $inh, bool $enabled, object $meta)
{ {
$this->id = $id; $this->id = $id;
$this->ver = $ver; $this->ver = $ver;
$this->inh = $inh;
$this->meta = $meta; $this->meta = $meta;
$this->home = OPENVK_ROOT . "/themepacks/$id"; $this->home = OPENVK_ROOT . "/themepacks/$id";
$this->enabled = $enabled; $this->enabled = $enabled;
@ -58,6 +60,11 @@ class Themepack
return $this->meta->author ?? $this->getName() . " authors"; return $this->meta->author ?? $this->getName() . " authors";
} }
function inheritDefault(): bool
{
return $this->inh;
}
function fetchStyleSheet(): ?string function fetchStyleSheet(): ?string
{ {
$file = "$this->home/stylesheet.css"; $file = "$this->home/stylesheet.css";
@ -83,6 +90,6 @@ class Themepack
if($manifest->openvk_version > Themepacks::THEMPACK_ENGINE_VERSION) if($manifest->openvk_version > Themepacks::THEMPACK_ENGINE_VERSION)
throw new Exceptions\IncompatibleThemeException("Theme is built for newer OVK (themeEngine" . $manifest->openvk_version . ")"); throw new Exceptions\IncompatibleThemeException("Theme is built for newer OVK (themeEngine" . $manifest->openvk_version . ")");
return new static($manifest->id, $manifest->version, (bool) ($manifest->enabled ?? true), (object) $manifest->metadata); return new static($manifest->id, $manifest->version, (bool) ($manifest->inherit_master ?? true), (bool) ($manifest->enabled ?? true), (object) $manifest->metadata);
} }
} }