Index: branches/5.1.x/core/units/helpers/mod_rewrite_helper.php =================================================================== diff -u -r13489 -r13559 --- branches/5.1.x/core/units/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 13489) +++ branches/5.1.x/core/units/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 13559) @@ -1,6 +1,6 @@ HTTPQuery =& $this->Application->recallObject('HTTPQuery'); + + // domain based primary language + $this->primaryLanguageId = $this->Application->siteDomainField('PrimaryLanguageId'); + + // domain based primary theme + $this->primaryThemeId = $this->Application->siteDomainField('PrimaryThemeId'); } function processRewriteURL() @@ -129,7 +149,7 @@ $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'CachedUrls - WHERE Hash = ' . crc32($url); + WHERE Hash = ' . crc32($url) . ' AND DomainId = ' . (int)$this->Application->siteDomainField('DomainId'); $data = $this->Conn->GetRow($sql); if ($data) { @@ -194,6 +214,7 @@ $fields_hash = Array ( 'Url' => $url, 'Hash' => crc32($url), + 'DomainId' => (int)$this->Application->siteDomainField('DomainId'), 'Prefixes' => $prefixes ? '|' . implode('|', $prefixes) . '|' : '', 'ParsedVars' => serialize($data), 'Cached' => adodb_mktime(), @@ -409,8 +430,12 @@ } // add language - $default_language_id = $this->Application->GetDefaultLanguageId(); - if ($processed_params['m_lang'] && ($processed_params['m_lang'] != $default_language_id)) { + if (!$this->primaryLanguageId) { + // when domain-based language not found -> use site-wide language + $this->primaryLanguageId = $this->Application->GetDefaultLanguageId(); + } + + if ($processed_params['m_lang'] && ($processed_params['m_lang'] != $this->primaryLanguageId)) { $language_name = $this->Application->getCache('language_names[%LangIDSerial:' . $processed_params['m_lang'] . '%]'); if ($language_name === false) { $sql = 'SELECT PackName @@ -425,8 +450,12 @@ } // add theme - $default_theme_id = $this->Application->GetDefaultThemeId(true); - if ($processed_params['m_theme'] && ($processed_params['m_theme'] != $default_theme_id)) { + if (!$this->primaryThemeId) { + // when domain-based theme not found -> use site-wide theme + $this->primaryThemeId = $this->Application->GetDefaultThemeId(true); + } + + if ($processed_params['m_theme'] && ($processed_params['m_theme'] != $this->primaryThemeId)) { $theme_name = $this->Application->getCache('theme_names[%ThemeIDSerial:' . $processed_params['m_theme'] . '%]'); if ($theme_name === false) { $sql = 'SELECT Name @@ -533,6 +562,10 @@ // language was found by pack name array_shift($url_parts); } + elseif ($this->primaryLanguageId) { + // use domain-based primary language instead of site-wide primary language + $vars['m_lang'] = $this->primaryLanguageId; + } return true; } @@ -577,6 +610,10 @@ // theme was found by name array_shift($url_parts); } + elseif ($this->primaryThemeId) { + // use domain-based primary theme instead of site-wide primary theme + $vars['m_theme'] = $this->primaryThemeId; + } return true; } @@ -1076,17 +1113,31 @@ } /** - * Sets default parsed values before actual url parsing + * Sets default parsed values before actual url parsing (only, for empty url) * * @param Array $vars */ function _setDefaultValues(&$vars) { - $defaults = Array ('m_cat_id' => 0, 'm_cat_page' => 1, 'm_opener' => 's', 't' => 'index'); + $defaults = Array ( + 'm_cat_id' => 0, // no category + 'm_cat_page' => 1, // first category page + 'm_opener' => 's', // stay on same page + 't' => 'index' // main site page + ); + if ($this->primaryLanguageId) { + // domain-based primary language + $defaults['m_lang'] = $this->primaryLanguageId; + } + + if ($this->primaryThemeId) { + // domain-based primary theme + $defaults['m_theme'] = $this->primaryThemeId; + } + foreach ($defaults as $default_key => $default_value) { - // bug: null is never returned - if ($this->HTTPQuery->Get($default_key) == null) { + if ($this->HTTPQuery->Get($default_key) === false) { $vars[$default_key] = $default_value; } }