Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 1 | <?php |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 2 | |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 3 | // CSS |
| 4 | if (preg_match("/mailbox/i", $_SERVER['REQUEST_URI'])) { |
| 5 | $css_minifier->add('/web/css/site/mailbox.css'); |
| 6 | } |
| 7 | if (preg_match("/admin/i", $_SERVER['REQUEST_URI'])) { |
| 8 | $css_minifier->add('/web/css/site/admin.css'); |
| 9 | } |
| 10 | if (preg_match("/user/i", $_SERVER['REQUEST_URI'])) { |
| 11 | $css_minifier->add('/web/css/site/user.css'); |
| 12 | } |
| 13 | if (preg_match("/edit/i", $_SERVER['REQUEST_URI'])) { |
| 14 | $css_minifier->add('/web/css/site/edit.css'); |
| 15 | } |
| 16 | if (preg_match("/(quarantine|qhandler)/i", $_SERVER['REQUEST_URI'])) { |
| 17 | $css_minifier->add('/web/css/site/quarantine.css'); |
| 18 | } |
| 19 | if (preg_match("/debug/i", $_SERVER['REQUEST_URI'])) { |
| 20 | $css_minifier->add('/web/css/site/debug.css'); |
| 21 | } |
| 22 | if ($_SERVER['REQUEST_URI'] == '/') { |
| 23 | $css_minifier->add('/web/css/site/index.css'); |
| 24 | } |
| 25 | |
| 26 | $hash = $css_minifier->getDataHash(); |
| 27 | $CSSPath = '/tmp/' . $hash . '.css'; |
| 28 | if(!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 | |
| 54 | foreach ($globalVariables as $globalVariableName => $globalVariableValue) { |
| 55 | $twig->addGlobal($globalVariableName, $globalVariableValue); |
| 56 | } |