Index: branches/5.0.x/core/units/helpers/mod_rewrite_helper.php =================================================================== diff -u -N -r12787 -r12808 --- branches/5.0.x/core/units/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 12787) +++ branches/5.0.x/core/units/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 12808) @@ -1,6 +1,6 @@ Application->recallObject('ThemesHelper'); - /* @var $themes_helper kThemesHelper */ + // 1. will damage actual category during category item review add process + // 2. will use "use_section" parameter of "m_Link" tag to gain same effect +// $themes_helper =& $this->Application->recallObject('ThemesHelper'); +// /* @var $themes_helper kThemesHelper */ +// +// $vars['m_cat_id'] = $themes_helper->getPageByTemplate($template_path, $vars['m_theme']); - $vars['m_cat_id'] = $themes_helper->getPageByTemplate($template_path, $vars['m_theme']); - return true; } @@ -460,7 +469,7 @@ $url_part = reset($url_parts); - $sql = 'SELECT ThemeId, IF(LOWER(Name) = ' . $this->Conn->qstr($url_part) . ', 2, PrimaryTheme) AS SortKey + $sql = 'SELECT ThemeId, IF(LOWER(Name) = ' . $this->Conn->qstr($url_part) . ', 2, PrimaryTheme) AS SortKey, TemplateAliases FROM ' . TABLE_PREFIX . 'Theme WHERE Enabled = 1 ORDER BY SortKey DESC'; @@ -471,6 +480,13 @@ // don't use next enabled theme, when primary theme is disabled $vars['m_theme'] = $theme_info['ThemeId']; + if ($theme_info['TemplateAliases']) { + $this->_templateAliases = unserialize($theme_info['TemplateAliases']); + } + else { + $this->_templateAliases = Array (); + } + if ($theme_info['SortKey'] == 2) { // theme was found by name array_shift($url_parts); @@ -868,7 +884,7 @@ $parent_path = implode(',',explode('|', substr($category['ParentPath'], 1, -1))); // item template is stored in module' system custom field - need to get that field Id - $item_template_field_id = $this->_getItemTemplateCustomField($module_prefix); + $item_template_field_id = $this->getItemTemplateCustomField($module_prefix); // looking for item template through cats hierarchy sorted by parent path $query = ' SELECT ccd.l1_cust_' . $item_template_field_id . ', @@ -881,6 +897,24 @@ ORDER BY FIND_IN_SET(c.CategoryId, ' . $this->Conn->qstr($parent_path) . ') DESC'; $item_template = $this->Conn->GetOne($query); + if (!isset($this->_templateAliases)) { + // when empty url OR mod-rewrite disabled + + $themes_helper =& $this->Application->recallObject('ThemesHelper'); + /* @var $themes_helper kThemesHelper */ + + $sql = 'SELECT TemplateAliases + FROM ' . TABLE_PREFIX . 'Theme + WHERE ThemeId = ' . (int)$themes_helper->getCurrentThemeId(); + $template_aliases = $this->Conn->GetOne($sql); + + $this->_templateAliases = $template_aliases ? unserialize($template_aliases) : Array (); + } + + if ($item_template && array_key_exists($item_template, $this->_templateAliases)) { + $item_template = $this->_templateAliases[$item_template]; + } + $this->Application->setCache(__CLASS__ . __FUNCTION__, $cache_key, $item_template); return $item_template; @@ -914,7 +948,7 @@ * @param string $module_prefix * @return int */ - function _getItemTemplateCustomField($module_prefix) + function getItemTemplateCustomField($module_prefix) { $cached_value = $this->Application->getCache(__CLASS__ . __FUNCTION__, $module_prefix); if ($cached_value !== false) {