+// Get current theme name
+function getActualTheme () {
+ // The default theme is 'default'... ;-)
+ $ret = 'default';
+
+ // Load default theme if not empty from configuration
+ if ((isConfigEntrySet('default_theme')) && (getConfig('default_theme') != '')) {
+ $ret = getConfig('default_theme');
+ } // END - if
+
+ if (!isMailerThemeSet()) {
+ // Set default theme
+ setMailerTheme($ret);
+ } elseif ((isMailerThemeSet()) && (isExtensionInstalledAndNewer('sql_patches', '0.1.4'))) {
+ //die("<pre>".print_r($GLOBALS['cache_array']['themes'], TRUE)."</pre>");
+ // Get theme from cookie
+ $ret = getSession('mailer_theme');
+
+ // Is it valid?
+ if ((!isExtensionActive('theme')) || (getThemeId($ret) == '0')) {
+ // Fix it to default
+ $ret = 'default';
+ } // END - if
+ } elseif ((!isInstalled()) && ((isInstalling()) || (isHtmlOutputMode())) && ((isGetRequestElementSet('theme')) || (isPostRequestElementSet('theme')))) {
+ // Prepare filename for checking
+ $themeFile = sprintf("theme/%s/theme.php", getRequestElement('theme'));
+
+ // Installation mode active
+ if ((isGetRequestElementSet('theme')) && (isIncludeReadable($theme))) {
+ // Set cookie from URL data
+ setMailerTheme(getRequestElement('theme'));
+ } elseif (isIncludeReadable(sprintf("theme/%s/theme.php", postRequestElement('theme')))) {
+ // Set cookie from posted data
+ setMailerTheme(postRequestElement('theme'));
+ }
+
+ // Set return value
+ $ret = getSession('mailer_theme');
+ } else {
+ // Invalid design, reset cookie
+ setMailerTheme($ret);
+ }