Oomox.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <?php
  2. declare(strict_types = 1);
  3. // {{{ License
  4. // This file is part of GNU social - https://www.gnu.org/software/social
  5. //
  6. // GNU social is free software: you can redistribute it and/or modify
  7. // it under the terms of the GNU Affero General Public License as published by
  8. // the Free Software Foundation, either version 3 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // GNU social is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU Affero General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU Affero General Public License
  17. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  18. // }}}
  19. namespace Plugin\Oomox\Entity;
  20. use App\Core\Entity;
  21. use DateTimeInterface;
  22. /**
  23. * For storing theme colour settings
  24. *
  25. * @package GNUsocial
  26. * @category Oomox
  27. *
  28. * @author Eliseu Amaro <mail@eliseuama.ro>
  29. * @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
  30. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  31. */
  32. class Oomox extends Entity
  33. {
  34. // {{{ Autocode
  35. // @codeCoverageIgnoreStart
  36. private int $actor_id;
  37. private ?string $colour_foreground_light;
  38. private ?string $colour_background_hard_light;
  39. private ?string $colour_background_card_light;
  40. private ?string $colour_border_light;
  41. private ?string $colour_accent_light;
  42. private ?string $colour_foreground_dark;
  43. private ?string $colour_background_hard_dark;
  44. private ?string $colour_background_card_dark;
  45. private ?string $colour_border_dark;
  46. private ?string $colour_accent_dark;
  47. private DateTimeInterface $created;
  48. private DateTimeInterface $modified;
  49. public function setActorId(int $actor_id): self
  50. {
  51. $this->actor_id = $actor_id;
  52. return $this;
  53. }
  54. public function getActorId(): int
  55. {
  56. return $this->actor_id;
  57. }
  58. public function setColourForegroundLight(?string $colour_foreground_light): self
  59. {
  60. $this->colour_foreground_light = $colour_foreground_light;
  61. return $this;
  62. }
  63. public function getColourForegroundLight(): ?string
  64. {
  65. return $this->colour_foreground_light;
  66. }
  67. public function setColourBackgroundHardLight(?string $colour_background_hard_light): self
  68. {
  69. $this->colour_background_hard_light = $colour_background_hard_light;
  70. return $this;
  71. }
  72. public function getColourBackgroundHardLight(): ?string
  73. {
  74. return $this->colour_background_hard_light;
  75. }
  76. public function setColourBackgroundCardLight(?string $colour_background_card_light): self
  77. {
  78. $this->colour_background_card_light = $colour_background_card_light;
  79. return $this;
  80. }
  81. public function getColourBackgroundCardLight(): ?string
  82. {
  83. return $this->colour_background_card_light;
  84. }
  85. public function setColourBorderLight(?string $colour_border_light): self
  86. {
  87. $this->colour_border_light = $colour_border_light;
  88. return $this;
  89. }
  90. public function getColourBorderLight(): ?string
  91. {
  92. return $this->colour_border_light;
  93. }
  94. public function setColourAccentLight(?string $colour_accent_light): self
  95. {
  96. $this->colour_accent_light = $colour_accent_light;
  97. return $this;
  98. }
  99. public function getColourAccentLight(): ?string
  100. {
  101. return $this->colour_accent_light;
  102. }
  103. public function setColourForegroundDark(?string $colour_foreground_dark): self
  104. {
  105. $this->colour_foreground_dark = $colour_foreground_dark;
  106. return $this;
  107. }
  108. public function getColourForegroundDark(): ?string
  109. {
  110. return $this->colour_foreground_dark;
  111. }
  112. public function setColourBackgroundHardDark(?string $colour_background_hard_dark): self
  113. {
  114. $this->colour_background_hard_dark = $colour_background_hard_dark;
  115. return $this;
  116. }
  117. public function getColourBackgroundHardDark(): ?string
  118. {
  119. return $this->colour_background_hard_dark;
  120. }
  121. public function setColourBackgroundCardDark(?string $colour_background_card_dark): self
  122. {
  123. $this->colour_background_card_dark = $colour_background_card_dark;
  124. return $this;
  125. }
  126. public function getColourBackgroundCardDark(): ?string
  127. {
  128. return $this->colour_background_card_dark;
  129. }
  130. public function setColourBorderDark(?string $colour_border_dark): self
  131. {
  132. $this->colour_border_dark = $colour_border_dark;
  133. return $this;
  134. }
  135. public function getColourBorderDark(): ?string
  136. {
  137. return $this->colour_border_dark;
  138. }
  139. public function setColourAccentDark(?string $colour_accent_dark): self
  140. {
  141. $this->colour_accent_dark = $colour_accent_dark;
  142. return $this;
  143. }
  144. public function getColourAccentDark(): ?string
  145. {
  146. return $this->colour_accent_dark;
  147. }
  148. public function setCreated(DateTimeInterface $created): self
  149. {
  150. $this->created = $created;
  151. return $this;
  152. }
  153. public function getCreated(): DateTimeInterface
  154. {
  155. return $this->created;
  156. }
  157. public function setModified(DateTimeInterface $modified): self
  158. {
  159. $this->modified = $modified;
  160. return $this;
  161. }
  162. public function getModified(): DateTimeInterface
  163. {
  164. return $this->modified;
  165. }
  166. public function resetTheme(bool $is_light) {
  167. if ($is_light) {
  168. $this->colour_background_hard_light = '#09090d';
  169. $this->colour_background_card_light = '#ebebeb';
  170. $this->colour_foreground_light = '#f0f0f0';
  171. $this->colour_border_light = '#d5d5d5';
  172. $this->colour_accent_light = '#a22430';
  173. } else {
  174. $this->colour_background_hard_dark = '#141216';
  175. $this->colour_background_card_dark = '#131217';
  176. $this->colour_foreground_dark = '#f0f6f6';
  177. $this->colour_border_dark = '#201f25';
  178. $this->colour_accent_dark = '#5ddbcf';
  179. }
  180. }
  181. // @codeCoverageIgnoreEnd
  182. // }}} Autocode
  183. public static function schemaDef(): array
  184. {
  185. return [
  186. 'name' => 'oomox',
  187. 'fields' => [
  188. 'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to actor table'],
  189. 'colour_foreground_light' => ['type' => 'text', 'description' => 'colour hex code'],
  190. 'colour_background_hard_light' => ['type' => 'text', 'description' => 'colour hex code'],
  191. 'colour_background_card_light' => ['type' => 'text', 'description' => 'colour hex code'],
  192. 'colour_border_light' => ['type' => 'text', 'description' => 'colour hex code'],
  193. 'colour_accent_light' => ['type' => 'text', 'description' => 'colour hex code'],
  194. 'colour_foreground_dark' => ['type' => 'text', 'description' => 'colour hex code'],
  195. 'colour_background_hard_dark' => ['type' => 'text', 'description' => 'colour hex code'],
  196. 'colour_background_card_dark' => ['type' => 'text', 'description' => 'colour hex code'],
  197. 'colour_border_dark' => ['type' => 'text', 'description' => 'colour hex code'],
  198. 'colour_accent_dark' => ['type' => 'text', 'description' => 'colour hex code'],
  199. 'created' => ['type' => 'datetime', 'not null' => true, 'description' => 'date this record was created', 'default' => 'CURRENT_TIMESTAMP'],
  200. 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified', 'default' => 'CURRENT_TIMESTAMP'],
  201. ],
  202. 'primary key' => ['actor_id'],
  203. ];
  204. }
  205. }