blob: 6c783a0bfbe2a18f137ca17af6490c50a47f6e82 [file] [log] [blame]
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01001<?php
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01002
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01003// CSS
4if (preg_match("/mailbox/i", $_SERVER['REQUEST_URI'])) {
5 $css_minifier->add('/web/css/site/mailbox.css');
6}
7if (preg_match("/admin/i", $_SERVER['REQUEST_URI'])) {
8 $css_minifier->add('/web/css/site/admin.css');
9}
10if (preg_match("/user/i", $_SERVER['REQUEST_URI'])) {
11 $css_minifier->add('/web/css/site/user.css');
12}
13if (preg_match("/edit/i", $_SERVER['REQUEST_URI'])) {
14 $css_minifier->add('/web/css/site/edit.css');
15}
16if (preg_match("/(quarantine|qhandler)/i", $_SERVER['REQUEST_URI'])) {
17 $css_minifier->add('/web/css/site/quarantine.css');
18}
19if (preg_match("/debug/i", $_SERVER['REQUEST_URI'])) {
20 $css_minifier->add('/web/css/site/debug.css');
21}
22if ($_SERVER['REQUEST_URI'] == '/') {
23 $css_minifier->add('/web/css/site/index.css');
24}
25
26$hash = $css_minifier->getDataHash();
27$CSSPath = '/tmp/' . $hash . '.css';
28if(!file_exists($CSSPath)) {
29 $css_minifier->minify($CSSPath);
30 cleanupCSS($hash);
31}
32
33$globalVariables = [
34 'mailcow_hostname' => getenv('MAILCOW_HOSTNAME'),
35 'mailcow_locale' => @$_SESSION['mailcow_locale'],
36 'mailcow_cc_role' => @$_SESSION['mailcow_cc_role'],
37 'mailcow_cc_username' => @$_SESSION['mailcow_cc_username'],
38 'is_master' => preg_match('/y|yes/i', getenv('MASTER')),
39 'dual_login' => @$_SESSION['dual-login'],
40 'ui_texts' => $UI_TEXTS,
41 'css_path' => '/cache/'.basename($CSSPath),
42 'theme' => strtolower(trim($DEFAULT_THEME)),
43 'logo' => customize('get', 'main_logo'),
44 'available_languages' => $AVAILABLE_LANGUAGES,
45 'lang' => $lang,
46 'skip_sogo' => (getenv('SKIP_SOGO') == 'y'),
47 'allow_admin_email_login' => (getenv('ALLOW_ADMIN_EMAIL_LOGIN') == 'n'),
48 'mailcow_apps' => $MAILCOW_APPS,
49 'app_links' => customize('get', 'app_links'),
50 'is_root_uri' => (parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) == '/'),
51 'uri' => $_SERVER['REQUEST_URI'],
52];
53
54foreach ($globalVariables as $globalVariableName => $globalVariableValue) {
55 $twig->addGlobal($globalVariableName, $globalVariableValue);
56}