diff options
| author | Ron Lucke <lucke@elan-ev.de> | 2025-07-14 09:36:18 +0200 |
|---|---|---|
| committer | Ron Lucke <lucke@elan-ev.de> | 2025-07-14 09:36:18 +0200 |
| commit | 4355ded9bc56e0b06fbceffe61ddc37061cc3bc7 (patch) | |
| tree | 348493b6b0fd1286b86f213e5077413b97cf9747 /db | |
| parent | 1e59dd2dacc51b3313d7780b66d4bf72e0484f86 (diff) | |
Color-Themes-System, fixes #5361
Closes #5361
Merge request studip/studip!4038
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrations/6.1.13_add_themes_config.php | 57 | ||||
| -rw-r--r-- | db/migrations/6.1.14_add_themes_table.php | 76 |
2 files changed, 133 insertions, 0 deletions
diff --git a/db/migrations/6.1.13_add_themes_config.php b/db/migrations/6.1.13_add_themes_config.php new file mode 100644 index 0000000..d1b4704 --- /dev/null +++ b/db/migrations/6.1.13_add_themes_config.php @@ -0,0 +1,57 @@ +<?php + +final class AddThemesConfig extends Migration +{ + public function description() + { + return 'Add configs for Stud.IP Themes'; + } + + public function up() + { + $query = 'INSERT INTO `config` (`field`, `value`, `type`, `section`, `range`, `description`, `mkdate`, `chdate`) + VALUES (:name, :value, :type, :section, :range, :description, UNIX_TIMESTAMP(), UNIX_TIMESTAMP())'; + $statement = DBManager::get()->prepare($query); + $statement->execute([ + 'name' => 'STUDIP_THEME_LIGHT', + 'value' => '1', + 'type' => 'integer', + 'section' => 'Themes', + 'range' => 'global', + 'description' => 'Welches Theme soll im Light-Mode verwendet werden?' + ]); + $statement->execute([ + 'name' => 'STUDIP_THEME_DARK', + 'value' => '2', + 'type' => 'integer', + 'section' => 'Themes', + 'range' => 'global', + 'description' => 'Welches Theme soll im Dark-Mode verwendet werden?' + ]); + $statement->execute([ + 'name' => 'STUDIP_THEME_HIGH_CONTRAST', + 'value' => '3', + 'type' => 'integer', + 'section' => 'Themes', + 'range' => 'global', + 'description' => 'Welches Theme soll im High-Contrast-Mode verwendet werden?' + ]); + } + + public function down() + { + $query = "DELETE `config`, `config_values`, `i18n` + FROM `config` + LEFT JOIN `config_values` USING (`field`) + LEFT JOIN `i18n` + ON `table` = 'config' + AND `field` = 'value' + AND `object_id` = MD5(`config`.`field`) + WHERE `field` IN ( + 'STUDIP_THEME_LIGHT', + 'STUDIP_THEME_DARK', + 'STUDIP_THEME_HIGH_CONTRAST' + )"; + DBManager::get()->exec($query); + } +}
\ No newline at end of file diff --git a/db/migrations/6.1.14_add_themes_table.php b/db/migrations/6.1.14_add_themes_table.php new file mode 100644 index 0000000..f5ccc70 --- /dev/null +++ b/db/migrations/6.1.14_add_themes_table.php @@ -0,0 +1,76 @@ +<?php + +final class AddThemesTable extends Migration +{ + public function description() + { + return 'Create table for Stud.IP Themes'; + } + + public function up() + { + $query = "CREATE TABLE IF NOT EXISTS `themes` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `active` TINYINT(1) NOT NULL DEFAULT 0, + `name` VARCHAR(255) NOT NULL, + `origin` ENUM('system', 'custom') COLLATE latin1_bin NOT NULL, + `version` VARCHAR(50) NOT NULL, + `studip_min_version` VARCHAR(50) NOT NULL, + `studip_max_version` VARCHAR(50) NOT NULL, + `author` VARCHAR(255) NOT NULL, + `description` VARCHAR(255) NOT NULL, + `type` ENUM('light', 'dark', 'high-contrast') COLLATE latin1_bin NOT NULL, + `values` MEDIUMTEXT NOT NULL, + `mkdate` INT(11) NOT NULL, + `chdate` INT(11) NOT NULL, + PRIMARY KEY (`id`) + )"; + DBManager::get()->exec($query); + + $default_values = json_encode([ + '--color--brand-primary' => '#28497c', + '--color--brand-primary-contrast' => '#ffffff', + '--color--brand-secondary' => '#28497c', + '--color--brand-secondary-contrast' => '#ffffff', + '--color--global-background' => '#ffffff', + '--color--font-primary' => '#101010', + '--color--font-secondary' => '#3c454e', + '--color--font-inactive' => '#676767', + '--color--font-inverted' => '#ffffff', + '--color--main-navigation-item' => '#28497c', + '--color--sidebar-item' => '#28497c', + '--color--sidebar-item-hover' => '#d60000', + '--color--highlight' => '#28497c', + '--color--highlight-hover' => '#d60000', + '--color--content-link' => '#28497c', + '--color--content-link-hover' => '#d60000', + ]); + + $stmt = DBManager::get()->prepare(" + INSERT INTO `themes` + (`id`, `active`, `name`, `origin`, `version`, `studip_min_version`, `studip_max_version`, `author`, `description`, `type`, `values`, `mkdate`, `chdate`) + VALUES + (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()) + "); + + $stmt->execute([ + 1, + 1, + 'Stud.IP Light Theme', + 'system', + '1.0', + '6.1', + '6.1', + 'Ron Lucke', + 'Default Light Theme', + 'light', + $default_values, + ]); + + } + + public function down() + { + DBManager::get()->exec('DROP TABLE IF EXISTS `themes`'); + } +} |
