aboutsummaryrefslogtreecommitdiff
path: root/lib/models/Theme.php
blob: 2b25d6eedca8543531e5995e7c74729b8d169f0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php

/**
 * Theme.php - Stud.IP Theme Model Class
 * 
 * @author    Ron Lucke <lucke@elan-ev.de>
 * @license   GPL2 or any later version
 * 
 * @property string $name
 * @property string $origin
 * @property string $version
 * @property string $studip_min_version
 * @property string $studip_max_version
 * @property string $author
 * @property string $description
 * @property \JSONArrayObject $values
 * @property string $type
 * @property int $mkdate database column
 * @property int $chdate database column
 */

 class Theme extends SimpleORMap
 {
    public const COLOR_KEY_CATEGORIES = [
        'brand' => [
            '--color--brand-primary' => '#28497c',
            '--color--brand-primary-contrast' => '#ffffff',
            '--color--brand-secondary' => '#28497c',
            '--color--brand-secondary-contrast' => '#ffffff',
        ],
        'general' => [
            '--color--global-background' => '#ffffff',
        ],
        'text' => [
            '--color--font-primary' => '#101010',
            '--color--font-secondary' => '#3c454e',
            '--color--font-inactive' => '#676767',
            '--color--font-inverted' => '#ffffff',
        ],
        'navigation' => [
            '--color--main-navigation-item' => '#28497c',
        ],
        'sidebar' => [
            '--color--sidebar-item' => '#28497c',
            '--color--sidebar-item-hover' => '#101010',
        ],
        'content' => [
            '--color--highlight' => '#28497c',
            '--color--highlight-hover' => '#d60000',
            '--color--content-link' => '#28497c',
            '--color--content-link-hover' => '#d60000',
        ],
    ];

    protected static function configure($config = [])
    {
        $config['db_table'] = 'themes';
        $config['serialized_fields']['values'] = JSONArrayObject::class;

        parent::configure($config);
    }

    /**
     * @return static[]
     */
    public static function getActiveThemes(): array
    {
        return [
            'light' => self::getActiveLightTheme(),
            'dark' => self::getActiveDarkTheme(),
            'high-contrast' => self::getActiveHighContrastTheme(),
        ];
    }

    public static function getActiveLightTheme(): ?static
    {
        return self::findOneBySQL('active = 1 AND type = "light"');
    }

    public static function getActiveDarkTheme(): ?static
    {
        return self::findOneBySQL('active = 1 AND type = "dark"');
    }

    public static function getActiveHighContrastTheme(): ?static
    {
        return self::findOneBySQL('active = 1 AND type = "high-contrast"');
    }

    public static function getcolorKeyCategories(): array
    {
        return self::COLOR_KEY_CATEGORIES;
    }

 }