Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/application.php
Show First 20 Lines • Show All 615 Lines • ▼ Show 20 Line(s) | |||||
* Returns front-end primary theme id (even, when called from admin console) | * Returns front-end primary theme id (even, when called from admin console) | ||||
* | * | ||||
* @param bool $force_front | * @param bool $force_front | ||||
* @return int | * @return int | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function GetDefaultThemeId($force_front = false) | public function GetDefaultThemeId($force_front = false) | ||||
{ | { | ||||
static $theme_id = 0; | static $cache = array('force_front=yes' => 0, 'force_front=no' => 0); | ||||
if ( $theme_id > 0 ) { | $static_cache_key = $force_front ? 'force_front=yes' : 'force_front=no'; | ||||
return $theme_id; | |||||
if ( $cache[$static_cache_key] > 0 ) { | |||||
return $cache[$static_cache_key]; | |||||
} | } | ||||
if ( kUtil::constOn('DBG_FORCE_THEME') ) { | if ( kUtil::constOn('DBG_FORCE_THEME') ) { | ||||
$theme_id = DBG_FORCE_THEME; | $cache[$static_cache_key] = DBG_FORCE_THEME; | ||||
} | } | ||||
elseif ( !$force_front && $this->isAdmin ) { | elseif ( !$force_front && $this->isAdmin ) { | ||||
$theme_id = 999; | $cache[$static_cache_key] = 999; | ||||
} | } | ||||
else { | else { | ||||
$cache_key = 'primary_theme[%ThemeSerial%]'; | $cache_key = 'primary_theme[%ThemeSerial%]'; | ||||
$theme_id = $this->getCache($cache_key); | $cache[$static_cache_key] = $this->getCache($cache_key); | ||||
if ( $theme_id === false ) { | if ( $cache[$static_cache_key] === false ) { | ||||
$this->Conn->nextQueryCachable = true; | $this->Conn->nextQueryCachable = true; | ||||
$sql = 'SELECT ' . $this->getUnitOption('theme', 'IDField') . ' | $sql = 'SELECT ' . $this->getUnitOption('theme', 'IDField') . ' | ||||
FROM ' . $this->getUnitOption('theme', 'TableName') . ' | FROM ' . $this->getUnitOption('theme', 'TableName') . ' | ||||
WHERE (PrimaryTheme = 1) AND (Enabled = 1)'; | WHERE (PrimaryTheme = 1) AND (Enabled = 1)'; | ||||
$theme_id = $this->Conn->GetOne($sql); | $cache[$static_cache_key] = $this->Conn->GetOne($sql); | ||||
if ( $theme_id !== false ) { | if ( $cache[$static_cache_key] !== false ) { | ||||
$this->setCache($cache_key, $theme_id); | $this->setCache($cache_key, $cache[$static_cache_key]); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
return $theme_id; | return $cache[$static_cache_key]; | ||||
} | } | ||||
/** | /** | ||||
* Returns site primary currency ISO code | * Returns site primary currency ISO code | ||||
* | * | ||||
* @return string | * @return string | ||||
* @access public | * @access public | ||||
* @todo Move into In-Commerce | * @todo Move into In-Commerce | ||||
▲ Show 20 Lines • Show All 2491 Lines • Show Last 20 Lines |