Index: branches/5.2.x/core/kernel/managers/rewrite_url_processor.php =================================================================== diff -u -N -r14751 -r14753 --- branches/5.2.x/core/kernel/managers/rewrite_url_processor.php (.../rewrite_url_processor.php) (revision 14751) +++ branches/5.2.x/core/kernel/managers/rewrite_url_processor.php (.../rewrite_url_processor.php) (revision 14753) @@ -567,57 +567,41 @@ */ protected function _parsePhysicalTemplate($url_parts, &$vars) { - if (!$url_parts) { + if ( !$url_parts ) { return false; } + $themes_helper =& $this->Application->recallObject('ThemesHelper'); + /* @var $themes_helper kThemesHelper */ + do { $template_path = implode('/', $url_parts); + $template_found = $themes_helper->getTemplateId($template_path, $vars['m_theme']); - $physical_template = $this->Application->getPhysicalTemplate($template_path); - - if (($physical_template !== false) && (substr($physical_template, 0, 3) != 'id:')) { - // replace menu template name with it's actual template name on disk - list ($template_path) = explode(':', $physical_template, 2); - } - - $t_parts['path'] = dirname($template_path) == '.' ? '' : '/' . dirname($template_path); - $t_parts['file'] = basename($template_path); - - $sql = 'SELECT FileId - FROM ' . TABLE_PREFIX . 'ThemeFiles - WHERE (ThemeId = ' . $vars['m_theme'] . ') AND (FilePath = ' . $this->Conn->qstr($t_parts['path']) . ') AND (FileName = ' . $this->Conn->qstr($t_parts['file'] . '.tpl') . ')'; - $template_found = $this->Conn->GetOne($sql); - - if (!$template_found) { + if ( !$template_found ) { array_shift($url_parts); } - } while (!$template_found && $url_parts); + } while ( !$template_found && $url_parts ); - if ($template_found) { + if ( $template_found ) { $vars['t'] = $template_path; $template_parts = explode('/', $template_path); while ( $template_parts ) { - $this->partParsed( array_pop($template_parts), 'rtl' ); + $this->partParsed(array_pop($template_parts), 'rtl'); } // 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; } return false; } - - /** * Returns environment variable values for given prefix (uses directly given params, when available) * @@ -685,20 +669,20 @@ $cache_key = __CLASS__ . '::' . __FUNCTION__ . '[%CIDSerial:' . $category_id . '%]:' . $module_prefix; $cached_value = $this->Application->getCache($cache_key); - if ($cached_value !== false) { + if ( $cached_value !== false ) { return $cached_value; } - if (!is_array($category)) { - if ($category == 0) { + if ( !is_array($category) ) { + if ( $category == 0 ) { $category = $this->Application->findModule('Var', $module_prefix, 'RootCat'); } $sql = 'SELECT c.ParentPath, c.CategoryId FROM ' . TABLE_PREFIX . 'Category AS c WHERE c.CategoryId = ' . $category; $category = $this->Conn->GetRow($sql); } - $parent_path = implode(',',explode('|', substr($category['ParentPath'], 1, -1))); + $parent_path = implode(',', explode('|', substr($category['ParentPath'], 1, -1))); // item template is stored in module' system custom field - need to get that field Id $primary_lang = $this->Application->GetDefaultLanguageId(); @@ -715,7 +699,7 @@ ORDER BY FIND_IN_SET(c.CategoryId, ' . $this->Conn->qstr($parent_path) . ') DESC'; $item_template = $this->Conn->GetOne($query); - if (!isset($this->_templateAliases)) { + if ( !isset($this->_templateAliases) ) { // when empty url OR mod-rewrite disabled $themes_helper =& $this->Application->recallObject('ThemesHelper'); @@ -729,8 +713,9 @@ $this->_templateAliases = $template_aliases ? unserialize($template_aliases) : Array (); } - if ($item_template && array_key_exists($item_template, $this->_templateAliases)) { - $item_template = $this->_templateAliases[$item_template]; + if ( substr($item_template, 0, 1) == '#' ) { + // it's template alias + "#" isn't allowed in filenames + $item_template = (string)getArrayValue($this->_templateAliases, $item_template); } $this->Application->setCache($cache_key, $item_template);