gnu-social/plugins/Oomox/Entity/Oomox.php

243 lines
8.1 KiB
PHP
Raw Normal View History

2021-11-26 13:04:45 +00:00
<?php
declare(strict_types = 1);
// {{{ License
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
namespace Plugin\Oomox\Entity;
use App\Core\Entity;
use DateTimeInterface;
/**
* For storing theme colour settings
*
* @package GNUsocial
* @category Oomox
*
* @author Eliseu Amaro <mail@eliseuama.ro>
* @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class Oomox extends Entity
{
// {{{ Autocode
// @codeCoverageIgnoreStart
private int $actor_id;
private ?string $colour_foreground_light = null;
private ?string $colour_background_hard_light = null;
private ?string $colour_background_card_light = null;
private ?string $colour_border_light = null;
private ?string $colour_accent_light = null;
private ?string $colour_foreground_dark = null;
private ?string $colour_background_hard_dark = null;
private ?string $colour_background_card_dark = null;
private ?string $colour_border_dark = null;
private ?string $colour_accent_dark = null;
private DateTimeInterface $created;
private DateTimeInterface $modified;
2021-11-26 13:04:45 +00:00
public function setActorId(int $actor_id): self
{
$this->actor_id = $actor_id;
return $this;
}
public function getActorId(): int
{
return $this->actor_id;
}
public function setColourForegroundLight(?string $colour_foreground_light): self
2021-11-26 13:04:45 +00:00
{
$this->colour_foreground_light = $colour_foreground_light;
2021-11-26 13:04:45 +00:00
return $this;
}
public function getColourForegroundLight(): ?string
2021-11-26 13:04:45 +00:00
{
return $this->colour_foreground_light;
2021-11-26 13:04:45 +00:00
}
public function setColourBackgroundHardLight(?string $colour_background_hard_light): self
2021-11-26 13:04:45 +00:00
{
$this->colour_background_hard_light = $colour_background_hard_light;
2021-11-26 13:04:45 +00:00
return $this;
}
public function getColourBackgroundHardLight(): ?string
2021-11-26 13:04:45 +00:00
{
return $this->colour_background_hard_light;
2021-11-26 13:04:45 +00:00
}
public function setColourBackgroundCardLight(?string $colour_background_card_light): self
{
$this->colour_background_card_light = $colour_background_card_light;
return $this;
}
public function getColourBackgroundCardLight(): ?string
{
return $this->colour_background_card_light;
}
public function setColourBorderLight(?string $colour_border_light): self
{
$this->colour_border_light = $colour_border_light;
return $this;
}
public function getColourBorderLight(): ?string
{
return $this->colour_border_light;
}
public function setColourAccentLight(?string $colour_accent_light): self
{
$this->colour_accent_light = $colour_accent_light;
return $this;
}
public function getColourAccentLight(): ?string
{
return $this->colour_accent_light;
}
public function setColourForegroundDark(?string $colour_foreground_dark): self
{
$this->colour_foreground_dark = $colour_foreground_dark;
return $this;
}
public function getColourForegroundDark(): ?string
{
return $this->colour_foreground_dark;
}
public function setColourBackgroundHardDark(?string $colour_background_hard_dark): self
{
$this->colour_background_hard_dark = $colour_background_hard_dark;
return $this;
}
public function getColourBackgroundHardDark(): ?string
{
return $this->colour_background_hard_dark;
}
public function setColourBackgroundCardDark(?string $colour_background_card_dark): self
{
$this->colour_background_card_dark = $colour_background_card_dark;
return $this;
}
public function getColourBackgroundCardDark(): ?string
{
return $this->colour_background_card_dark;
}
public function setColourBorderDark(?string $colour_border_dark): self
{
$this->colour_border_dark = $colour_border_dark;
return $this;
}
public function getColourBorderDark(): ?string
{
return $this->colour_border_dark;
}
public function setColourAccentDark(?string $colour_accent_dark): self
{
$this->colour_accent_dark = $colour_accent_dark;
return $this;
}
public function getColourAccentDark(): ?string
{
return $this->colour_accent_dark;
}
public function setCreated(DateTimeInterface $created): self
2021-11-26 13:04:45 +00:00
{
$this->created = $created;
return $this;
}
public function getCreated(): DateTimeInterface
2021-11-26 13:04:45 +00:00
{
return $this->created;
}
public function setModified(DateTimeInterface $modified): self
2021-11-26 13:04:45 +00:00
{
$this->modified = $modified;
return $this;
}
public function getModified(): DateTimeInterface
2021-11-26 13:04:45 +00:00
{
return $this->modified;
}
// @codeCoverageIgnoreEnd
// }}} Autocode
2021-12-26 09:48:16 +00:00
public function resetTheme(bool $is_light)
{
if ($is_light) {
$this->colour_background_hard_light = '#09090d';
$this->colour_background_card_light = '#ebebeb';
2021-12-26 09:48:16 +00:00
$this->colour_foreground_light = '#f0f0f0';
$this->colour_border_light = '#d5d5d5';
$this->colour_accent_light = '#a22430';
} else {
$this->colour_background_hard_dark = '#141216';
$this->colour_background_card_dark = '#131217';
2021-12-26 09:48:16 +00:00
$this->colour_foreground_dark = '#f0f6f6';
$this->colour_border_dark = '#201f25';
$this->colour_accent_dark = '#5ddbcf';
}
}
2021-11-26 13:04:45 +00:00
public static function schemaDef(): array
{
return [
'name' => 'oomox',
'fields' => [
'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to actor table'],
'colour_foreground_light' => ['type' => 'text', 'description' => 'colour hex code'],
'colour_background_hard_light' => ['type' => 'text', 'description' => 'colour hex code'],
'colour_background_card_light' => ['type' => 'text', 'description' => 'colour hex code'],
'colour_border_light' => ['type' => 'text', 'description' => 'colour hex code'],
'colour_accent_light' => ['type' => 'text', 'description' => 'colour hex code'],
'colour_foreground_dark' => ['type' => 'text', 'description' => 'colour hex code'],
'colour_background_hard_dark' => ['type' => 'text', 'description' => 'colour hex code'],
'colour_background_card_dark' => ['type' => 'text', 'description' => 'colour hex code'],
'colour_border_dark' => ['type' => 'text', 'description' => 'colour hex code'],
'colour_accent_dark' => ['type' => 'text', 'description' => 'colour hex code'],
'created' => ['type' => 'datetime', 'not null' => true, 'description' => 'date this record was created', 'default' => 'CURRENT_TIMESTAMP'],
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified', 'default' => 'CURRENT_TIMESTAMP'],
2021-11-26 13:04:45 +00:00
],
'primary key' => ['actor_id'],
];
}
}