From: Roland Häder Date: Fri, 19 Dec 2008 18:36:23 +0000 (+0000) Subject: More fixes for 'theme vs. extensions' X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=b5e6a957d401a32612e9e12044c9a63ce99c56fc More fixes for 'theme vs. extensions' --- diff --git a/inc/databases.php b/inc/databases.php index b67e044421..adaafd37fb 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -115,7 +115,7 @@ define('USAGE_BASE', "usage"); define('SERVER_URL', "http://www.mxchange.org"); // Current SVN revision -define('CURR_SVN_REVISION', "676"); +define('CURR_SVN_REVISION', "677"); // Take a prime number which is long (if you know a longer one please try it out!) define('_PRIME', 591623); diff --git a/inc/functions.php b/inc/functions.php index abf13e97a5..7a70b794c3 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2887,6 +2887,98 @@ function getMessage ($messageId) { return $return; } +// Get current theme name +function GET_CURR_THEME() { + global $INC_POOL, $_CONFIG, $CSS, $cacheArray; + + // The default theme is 'default'... ;-) + $ret = "default"; + + // Load default theme if not empty from configuration + if (getConfig('default_theme') != "") $ret = getConfig('default_theme'); + + if (!isSessionVariableSet('mxchange_theme')) { + // Set default theme + set_session("mxchange_theme", $ret); + } elseif ((isSessionVariableSet('mxchange_theme')) && (GET_EXT_VERSION("sql_patches") >= "0.1.4")) { + //die("
".print_r($cacheArray['themes'], true)."
"); + // Get theme from cookie + $ret = get_session('mxchange_theme'); + + // Is it valid? + if (THEME_GET_ID($ret) == 0) { + // Fix it to default + $ret = "default"; + } // END - if + } elseif ((!isBooleanConstantAndTrue('mxchange_installed')) && ((isBooleanConstantAndTrue('mxchange_installing')) || ($CSS == true)) && ((!empty($_GET['theme'])) || (!empty($_POST['theme'])))) { + // Prepare FQFN for checking + $theme = sprintf("%stheme/%s/theme.php", PATH, SQL_ESCAPE($_GET['theme'])); + + // Installation mode active + if ((!empty($_GET['theme'])) && (FILE_READABLE($theme))) { + // Set cookie from URL data + set_session("mxchange_theme", SQL_ESCAPE($_GET['theme'])); + } elseif (FILE_READABLE(sprintf("%stheme/%s/theme.php", PATH, SQL_ESCAPE($_POST['theme'])))) { + // Set cookie from posted data + set_session("mxchange_theme", SQL_ESCAPE($_POST['theme'])); + } + + // Set return value + $ret = get_session('mxchange_theme'); + } else { + // Invalid design, reset cookie + set_session("mxchange_theme", $ret); + } + + // Add (maybe) found theme.php file to inclusion list + $theme = sprintf("%stheme/%s/theme.php", PATH, SQL_ESCAPE($ret)); + + // Try to load the requested include file + if (FILE_READABLE($theme)) $INC_POOL[] = $theme; + + // Return theme value + return $ret; +} + +// Get id from theme +function THEME_GET_ID ($name) { + global $cacheArray, $_CONFIG; + + // Is the extension "theme" installed? + if (!EXT_IS_ACTIVE("theme")) { + // Then abort here + return 0; + } // END - if + + // Default id + $id = 0; + + // Is the cache entry there? + if (isset($cacheArray['themes']['id'][$name])) { + // Get the version from cache + $id = $cacheArray['themes']['id'][$name]; + + // Count up + if (getConfig('cache_hits') > 0) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } + } elseif (GET_EXT_VERSION("cache") != "0.1.8") { + // Check if current theme is already imported or not + $result = SQL_QUERY_ESC("SELECT id FROM `"._MYSQL_PREFIX."_themes` WHERE theme_path='%s' LIMIT 1", + array($name), __FILE__, __LINE__); + + // Entry found? + if (SQL_NUMROWS($result) == 1) { + // Fetch data + list($id) = SQL_FETCHROW($result); + } // END - if + + // Free result + SQL_FREERESULT($result); + } + + // Return id + return $id; +} + ////////////////////////////////////////////////// // // // AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS // diff --git a/inc/language/de.php b/inc/language/de.php index dda9ec3c97..b6284cfd5c 100644 --- a/inc/language/de.php +++ b/inc/language/de.php @@ -1195,7 +1195,7 @@ define('MOD_REWRITE_ERROR', "Sie müssen mod_rewrite in Apache aktiviert hab define('ADMIN_BUILD_STATUS_HANDLER', "Status-Handler"); define('TASK_SUBJ_EXTENSION_DEACTIVATED', "Erweiterung deaktiviert"); define('ADMIN_SUBJECT_EXTENSION_DEACTIVATED', "Automatische Deaktivierung einer Erweiterung"); -define('FATAL_EXTENSION_LOADED', "Erweiterung %s/u> bereits geladen!"); +define('FATAL_EXTENSION_LOADED', "Erweiterung %s bereits geladen!"); define('ADMIN_ACCESS_DENIED', "Zugriff auf diesen Adminmenüpunkt nicht gestattet."); define('ADMIN_URL_BLACKLIST_DISABLED', "URL-Sperrliste ist deaktiviert."); diff --git a/inc/libs/theme_functions.php b/inc/libs/theme_functions.php index ba09b55a20..db1eb19ee1 100644 --- a/inc/libs/theme_functions.php +++ b/inc/libs/theme_functions.php @@ -37,65 +37,6 @@ if (!defined('__SECURITY')) { require($INC); } -// Always make sure the session management is initialized first -require_once(PATH."inc/session.php"); - -// Dirty fix for dublicate function -if (!function_exists('GET_CURR_THEME')) { -// Get current theme name -function GET_CURR_THEME() { - global $INC_POOL, $_CONFIG, $CSS, $cacheArray; - - // The default theme is 'default'... ;-) - $ret = "default"; - - // Load default theme if not empty from configuration - if (getConfig('default_theme') != "") $ret = getConfig('default_theme'); - - if (!isSessionVariableSet('mxchange_theme')) { - // Set default theme - set_session("mxchange_theme", $ret); - } elseif ((isSessionVariableSet('mxchange_theme')) && (GET_EXT_VERSION("sql_patches") >= "0.1.4")) { - //die("
".print_r($cacheArray['themes'], true)."
"); - // Get theme from cookie - $ret = get_session('mxchange_theme'); - - // Is it valid? - if (THEME_GET_ID($ret) == 0) { - // Fix it to default - $ret = "default"; - } // END - if - } elseif ((!isBooleanConstantAndTrue('mxchange_installed')) && ((isBooleanConstantAndTrue('mxchange_installing')) || ($CSS == true)) && ((!empty($_GET['theme'])) || (!empty($_POST['theme'])))) { - // Prepare FQFN for checking - $theme = sprintf("%stheme/%s/theme.php", PATH, SQL_ESCAPE($_GET['theme'])); - - // Installation mode active - if ((!empty($_GET['theme'])) && (FILE_READABLE($theme))) { - // Set cookie from URL data - set_session("mxchange_theme", SQL_ESCAPE($_GET['theme'])); - } elseif (FILE_READABLE(sprintf("%stheme/%s/theme.php", PATH, SQL_ESCAPE($_POST['theme'])))) { - // Set cookie from posted data - set_session("mxchange_theme", SQL_ESCAPE($_POST['theme'])); - } - - // Set return value - $ret = get_session('mxchange_theme'); - } else { - // Invalid design, reset cookie - set_session("mxchange_theme", $ret); - } - - // Add (maybe) found theme.php file to inclusion list - $theme = sprintf("%stheme/%s/theme.php", PATH, SQL_ESCAPE($ret)); - - // Try to load the requested include file - if (FILE_READABLE($theme)) $INC_POOL[] = $theme; - - // Return theme value - return $ret; -} -} // END - if - function THEME_SELECTION_BOX($mod, $act, $wht, $result) { // Construction URL $FORM = URL."/modules.php?module=".$mod; @@ -177,45 +118,6 @@ function THEME_GET_VERSION ($name) { return $cver; } -// Get id from theme -function THEME_GET_ID ($name) { - global $cacheArray, $_CONFIG; - - // Is the extension "theme" installed? - if (!EXT_IS_ACTIVE("theme")) { - // Then abort here - return 0; - } // END - if - - // Default id - $id = 0; - - // Is the cache entry there? - if (isset($cacheArray['themes']['id'][$name])) { - // Get the version from cache - $id = $cacheArray['themes']['id'][$name]; - - // Count up - if (getConfig('cache_hits') > 0) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } - } elseif (GET_EXT_VERSION("cache") != "0.1.8") { - // Check if current theme is already imported or not - $result = SQL_QUERY_ESC("SELECT id FROM `"._MYSQL_PREFIX."_themes` WHERE theme_path='%s' LIMIT 1", - array($name), __FILE__, __LINE__); - - // Entry found? - if (SQL_NUMROWS($result) == 1) { - // Fetch data - list($id) = SQL_FETCHROW($result); - } // END - if - - // Free result - SQL_FREERESULT($result); - } - - // Return id - return $id; -} - // Checks wether a theme is found in db function THEME_CHECK_EXIST ($name) { // Get theme and is it not nul? diff --git a/inc/mysql-connect.php b/inc/mysql-connect.php index 62885d2e31..efe013a278 100644 --- a/inc/mysql-connect.php +++ b/inc/mysql-connect.php @@ -167,12 +167,6 @@ if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndT // Run daily reset require_once(PATH."inc/check-reset.php"); - // Create missing configuration file - if (!function_exists('GET_CURR_THEME')) { - // Load dummy theme functions - require_once(PATH."inc/theme-dummy.php"); - } // END - if - // Load admin include file if he is admin if (IS_ADMIN()) { // Administrative functions @@ -269,12 +263,6 @@ if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndT require_once(PATH."inc/databases.php"); require_once(PATH."inc/session.php"); - // Create missing configuration file - if (!function_exists('GET_CURR_THEME')) { - // Load dummy theme functions - require_once(PATH."inc/theme-dummy.php"); - } // END - if - // Check if we are in installation routine $installPhp = basename($_SERVER['PHP_SELF']); if (($installPhp != "install.php") && ($CSS != "1") && ($CSS != -1)) { diff --git a/inc/theme-dummy.php b/inc/theme-dummy.php index e4beb87787..f87b68fd31 100644 --- a/inc/theme-dummy.php +++ b/inc/theme-dummy.php @@ -1,50 +1,3 @@