mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2024-12-10 10:40:15 +02:00
[BS5] add theme selector
This commit is contained in:
parent
7384aab2f4
commit
37b4ff811d
@ -83,6 +83,8 @@ foreach ($RSPAMD_MAPS['regex'] as $rspamd_regex_desc => $rspamd_regex_map) {
|
||||
];
|
||||
}
|
||||
|
||||
$themes = array_diff(scandir('/web/css/themes'), array('..', '.'));
|
||||
$themes = array_filter((str_replace("-bootstrap.css", "", $themes)));
|
||||
|
||||
$template = 'admin.twig';
|
||||
$template_data = [
|
||||
@ -90,6 +92,7 @@ $template_data = [
|
||||
'tfa_id' => @$_SESSION['tfa_id'],
|
||||
'fido2_cid' => @$_SESSION['fido2_cid'],
|
||||
'fido2_data' => $fido2_data,
|
||||
'themes' => $themes,
|
||||
'gal' => @$_SESSION['gal'],
|
||||
'license_guid' => license('guid'),
|
||||
'api' => [
|
||||
|
@ -116,6 +116,21 @@ function customize($_action, $_item, $_data = null) {
|
||||
$ui_announcement_text = $_data['ui_announcement_text'];
|
||||
$ui_announcement_type = (in_array($_data['ui_announcement_type'], array('info', 'warning', 'danger'))) ? $_data['ui_announcement_type'] : false;
|
||||
$ui_announcement_active = (!empty($_data['ui_announcement_active']) ? 1 : 0);
|
||||
|
||||
// check theme
|
||||
$theme = strtolower($_data['ui_theme']);
|
||||
$themes = array_diff(scandir('/web/css/themes'), array('..', '.'));
|
||||
$themes = array_filter((str_replace("-bootstrap.css", "", $themes)));
|
||||
if (!in_array($theme, $themes)){
|
||||
// err, theme not found
|
||||
$_SESSION['return'][] = array(
|
||||
'type' => 'danger',
|
||||
'log' => array(__FUNCTION__, $_action, $_item, $_data),
|
||||
'msg' => "Theme not found"
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$redis->set('TITLE_NAME', htmlspecialchars($title_name));
|
||||
$redis->set('MAIN_NAME', htmlspecialchars($main_name));
|
||||
@ -125,6 +140,7 @@ function customize($_action, $_item, $_data = null) {
|
||||
$redis->set('UI_ANNOUNCEMENT_TEXT', $ui_announcement_text);
|
||||
$redis->set('UI_ANNOUNCEMENT_TYPE', $ui_announcement_type);
|
||||
$redis->set('UI_ANNOUNCEMENT_ACTIVE', $ui_announcement_active);
|
||||
$redis->set('UI_THEME', $theme);
|
||||
}
|
||||
catch (RedisException $e) {
|
||||
$_SESSION['return'][] = array(
|
||||
@ -228,6 +244,19 @@ function customize($_action, $_item, $_data = null) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'ui_theme':
|
||||
try {
|
||||
return $redis->get('UI_THEME');
|
||||
}
|
||||
catch (RedisException $e) {
|
||||
$_SESSION['return'][] = array(
|
||||
'type' => 'danger',
|
||||
'log' => array(__FUNCTION__, $_action, $_item, $_data),
|
||||
'msg' => array('redis_error', $e)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'main_logo_specs':
|
||||
try {
|
||||
$image = new Imagick();
|
||||
|
@ -252,7 +252,7 @@ $css_minifier = new CSSminifierExtended();
|
||||
$css_dir = array_diff(scandir('/web/css/build'), array('..', '.'));
|
||||
// get customized ui data
|
||||
$UI_TEXTS = customize('get', 'ui_texts');
|
||||
$UI_THEME = "lumen"; // TODO: customize('get', 'ui_theme');
|
||||
$UI_THEME = customize('get', 'ui_theme');
|
||||
// minify bootstrap theme
|
||||
if (file_exists('/web/css/themes/'.$UI_THEME.'-bootstrap.css'))
|
||||
$css_minifier->add('/web/css/themes/'.$UI_THEME.'-bootstrap.css');
|
||||
|
@ -337,6 +337,7 @@
|
||||
"ui_header_announcement_type_info": "Info",
|
||||
"ui_header_announcement_type_warning": "Important",
|
||||
"ui_texts": "UI labels and texts",
|
||||
"ui_theme": "Design",
|
||||
"unban_pending": "unban pending",
|
||||
"unchanged_if_empty": "If unchanged leave blank",
|
||||
"upload": "Upload",
|
||||
|
@ -67,6 +67,14 @@
|
||||
<legend data-bs-target="#ui_texts" style="padding-top:20px" unselectable="on">{{ lang.admin.ui_texts }}</legend><hr />
|
||||
<div id="ui_texts">
|
||||
<form class="form" data-id="uitexts" role="form" method="post">
|
||||
<div class="mb-4 d-flex flex-column">
|
||||
<label for="uitests_theme">{{ lang.admin.ui_theme }}:</label>
|
||||
<select class="full-width-select" data-live-search="true" id="uitests_theme" name="ui_theme" required>
|
||||
{% for theme in themes %}
|
||||
<option>{{ theme }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<label for="uitests_title_name">{{ lang.admin.title_name }}:</label>
|
||||
<input type="text" class="form-control" id="uitests_title_name" name="title_name" placeholder="mailcow UI" value="{{ ui_texts.title_name|raw }}">
|
||||
|
Loading…
Reference in New Issue
Block a user