diff --git a/class2.php b/class2.php index a38c3966b..281f77706 100755 --- a/class2.php +++ b/class2.php @@ -1321,7 +1321,7 @@ $sql->db_Mark_Time('Find/Load Theme-Layout'); // needs to run after checkvalidth if(!defined("THEME_LAYOUT")) { - $def = ""; // no custom pages found yet. + /* $def = ""; // no custom pages found yet. $cusPagePref = (varset($user_pref['sitetheme_custompages'])) ? $user_pref['sitetheme_custompages'] : varset($pref['sitetheme_custompages']); if(is_array($cusPagePref) && count($cusPagePref)>0) // check if we match a page in layout custompages. @@ -1330,6 +1330,8 @@ if(!defined("THEME_LAYOUT")) $c_url = str_replace(array('&'), array('&'), e_REQUEST_URL);//.(e_QUERY ? '?'.e_QUERY : '');// mod_rewrite support // FIX - check against urldecoded strings $c_url = rtrim(rawurldecode($c_url), '?'); + + foreach($cusPagePref as $lyout=>$cusPageArray) { @@ -1362,7 +1364,7 @@ if(!defined("THEME_LAYOUT")) } } } - } + }*/ /* Done via e_IFRAME and USER_AREA force combination, check moved to menu.php if(strpos(e_SELF.'?'.e_QUERY, $ADMIN_DIRECTORY. 'menus.php?configure')!==FALSE) @@ -1384,7 +1386,7 @@ if(!defined("THEME_LAYOUT")) { define("THEME_STYLE", 'style.css'); } - +/* if($def) // custom-page layout. { define("THEME_LAYOUT",$def); @@ -1392,11 +1394,12 @@ if(!defined("THEME_LAYOUT")) else // default layout. { $deflayout = (!isset($user_pref['sitetheme_deflayout'])) ? varset($pref['sitetheme_deflayout']) : $user_pref['sitetheme_deflayout']; - /** - * @ignore - */ + define("THEME_LAYOUT",$deflayout); // default layout. - } + }*/ + + $deflayout = e107::getTheme()->getThemeLayout(); + define("THEME_LAYOUT",$deflayout); unset($def,$lyout,$cusPagePref,$menus_equery,$deflayout); diff --git a/e107_core/templates/header_default.php b/e107_core/templates/header_default.php index 8770ecac3..799b09113 100644 --- a/e107_core/templates/header_default.php +++ b/e107_core/templates/header_default.php @@ -24,7 +24,7 @@ $sql = e107::getDb(); $sql->db_Mark_Time('(Header Top)'); // Load library dependencies. -e107::getTheme('current', true)->loadLibrary(); +e107::getTheme('current')->loadLibrary(); //e107::js('core', 'bootstrap/js/bootstrap-tooltip.js','jquery'); // e107::css('core', 'bootstrap/css/tooltip.css','jquery'); diff --git a/e107_handlers/admin_log_class.php b/e107_handlers/admin_log_class.php index b2d62a7f4..6839a289e 100644 --- a/e107_handlers/admin_log_class.php +++ b/e107_handlers/admin_log_class.php @@ -625,7 +625,7 @@ class e_admin_log /** * Add a message to the queue * - * @param string $text - the message text for logging/display + * @param string|array $text - the message text for logging/display * @param int $type - the 'importance' of the message. E_MESSAGE_SUCCESS|E_MESSAGE_ERROR|E_MESSAGE_INFO|E_MESSAGE_DEBUG|E_MESSAGE_NODISPLAY * (Values as used in message handler, apart from the last, which causes the message to not be passed to the message handler * @param boolean|int $logLevel - TRUE to give same importance as for message display. FALSE to not log. @@ -685,7 +685,7 @@ class e_admin_log /** * Add a success message to the log queue * - * @param string $text + * @param string|array $text * @param boolean $message if true - register with eMessage handler * @param boolean $session add session message * @return e_admin_log diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index b050e8de4..bba01ce6e 100755 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -1523,7 +1523,16 @@ class e107 } } - return self::getSingleton('e_theme', true, null, array('themedir'=> $themedir, 'force'=> $clearCache)); + // e107::getDb()->db_Mark_time('start e_theme'); + /** @var e_theme $ret */ + $ret = self::getSingleton('e_theme', true, null, array('themedir'=> $themedir, 'force'=> $clearCache)); + + // e107::getDb()->db_Mark_time('end e_theme'); + /* echo "
";
+		debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
+		echo "
";*/ + + return $ret; } diff --git a/e107_handlers/library_manager.php b/e107_handlers/library_manager.php index 8ff92d68a..1b0e1e6d3 100755 --- a/e107_handlers/library_manager.php +++ b/e107_handlers/library_manager.php @@ -2066,7 +2066,7 @@ class e_library_manager { $excludedLibraries = array(); - $exclude = e107::getTheme('current', true)->cssAttribute('auto', 'exclude'); + $exclude = e107::getTheme('current', false)->cssAttribute('auto', 'exclude'); if($exclude) { diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index ea47805b9..7dbf637dc 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -71,7 +71,6 @@ class e_theme if(empty($this->_data) || $options['force'] === true) { - $this->load($options['force']); } @@ -280,6 +279,85 @@ class e_theme return isset($this->_data[$this->_current][$var]) ? $this->_data[$this->_current][$var] : false; } + + /** + * Calculate THEME_LAYOUT constant based on theme preferences and current URL. + * @param null $url + * @return string + */ + public function getThemeLayout($request_url = null) + { + if($request_url === null) + { + $request_url = e_REQUEST_URL; + } + + $user_pref = e107::getUser()->getPref(); + $pref = e107::getPref(); + + + $def = ""; // no custom pages found yet. + $cusPagePref = (varset($user_pref['sitetheme_custompages'])) ? $user_pref['sitetheme_custompages'] : varset($pref['sitetheme_custompages']); + + if(is_array($cusPagePref) && count($cusPagePref)>0) // check if we match a page in layout custompages. + { + //e_SELF.(e_QUERY ? '?'.e_QUERY : ''); + $c_url = str_replace(array('&'), array('&'), $request_url);//.(e_QUERY ? '?'.e_QUERY : '');// mod_rewrite support + // FIX - check against urldecoded strings + $c_url = rtrim(rawurldecode($c_url), '?'); + + foreach($cusPagePref as $lyout=>$cusPageArray) + { + if(!is_array($cusPageArray)) { continue; } + + // NEW - Front page template check - early + if(in_array('FRONTPAGE', $cusPageArray) && ($c_url == SITEURL || rtrim($c_url, '/') == SITEURL.'index.php')) + { + $def = $lyout; + break; + } + foreach($cusPageArray as $kpage) + { + if(substr($kpage, -1) === '!' ) + { + $kpage = rtrim($kpage, '!'); + if(substr($c_url, - strlen($kpage)) === $kpage) + { + $def = $lyout; + break 2; + } + continue; + } + + if ($kpage && ($kpage == defset('e_PAGE') || strpos($c_url, $kpage) !== false)) + { + // $def = ($lyout) ? $lyout : "legacyCustom"; + $def = $lyout; + break 2; + } + } + } + } + + + if($def) // custom-page layout. + { + $layout = $def; + } + else // default layout. + { + $layout = (!isset($user_pref['sitetheme_deflayout'])) ? varset($pref['sitetheme_deflayout']) : $user_pref['sitetheme_deflayout']; + } + + return $layout; + + } + + + + + + /** * Return a list of all local themes in various formats. * Replaces getThemeList