mirror of
https://github.com/openvk/openvk
synced 2024-12-22 16:42:32 +03:00
Allow disabling themes
This commit is contained in:
parent
ebc618452f
commit
c18ceae61c
2 changed files with 15 additions and 7 deletions
|
@ -7,13 +7,15 @@ class Themepack
|
|||
private $ver;
|
||||
private $meta;
|
||||
private $home;
|
||||
private $enabled;
|
||||
|
||||
function __construct(string $id, string $ver, object $meta)
|
||||
function __construct(string $id, string $ver, bool $enabled, object $meta)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->ver = $ver;
|
||||
$this->meta = $meta;
|
||||
$this->home = OPENVK_ROOT . "/themepacks/$id";
|
||||
$this->id = $id;
|
||||
$this->ver = $ver;
|
||||
$this->meta = $meta;
|
||||
$this->home = OPENVK_ROOT . "/themepacks/$id";
|
||||
$this->enabled = $enabled;
|
||||
}
|
||||
|
||||
function getId(): string
|
||||
|
@ -21,6 +23,11 @@ class Themepack
|
|||
return $this->id;
|
||||
}
|
||||
|
||||
function isEnabled(): bool
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
function getName(?string $lang = NULL): string
|
||||
{
|
||||
if(!$this->meta->name)
|
||||
|
@ -71,6 +78,6 @@ class Themepack
|
|||
if($manifest->openvk_version > Themepacks::THEMPACK_ENGINE_VERSION)
|
||||
throw new Exceptions\IncompatibleThemeException("Theme is built for newer OVK (themeEngine" . $manifest->openvk_version . ")");
|
||||
|
||||
return new static($manifest->id, $manifest->version, (object) $manifest->metadata);
|
||||
return new static($manifest->id, $manifest->version, (bool) ($manifest->enabled ?? true), (object) $manifest->metadata);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,8 @@ class Themepacks implements \ArrayAccess
|
|||
function getThemeList(): \Traversable
|
||||
{
|
||||
foreach($this->loadedThemepacks as $id => $theme)
|
||||
yield $id => ($theme->getName(Session::i()->get("lang", "ru")));
|
||||
if($theme->isEnabled())
|
||||
yield $id => ($theme->getName(Session::i()->get("lang", "ru")));
|
||||
}
|
||||
|
||||
/* ArrayAccess */
|
||||
|
|
Loading…
Reference in a new issue