Index: branches/unlabeled/unlabeled-1.28.2/kernel/units/categories/categories_tag_processor.php =================================================================== diff -u -N -r5631 -r5636 --- branches/unlabeled/unlabeled-1.28.2/kernel/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 5631) +++ branches/unlabeled/unlabeled-1.28.2/kernel/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 5636) @@ -82,9 +82,7 @@ function RootCategoryName($params) { - $root_phrase = $this->Application->ConfigValue('Root_Name'); - $ret = $this->Application->Phrase($root_phrase); - return $ret; + return $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params); } function CheckModuleRoot($params) @@ -111,63 +109,63 @@ function CategoryPath($params) { $module_name = getArrayValue($params, 'module') ? $params['module'] : 'In-Commerce'; - $module =& $this->Application->recallObject('mod.'.$module_name); - $module_root_cat = $module->GetDBField('RootCat'); + $module_category_id = $this->Application->findModule('Name', $module_name, 'RootCat'); + $module_item_id = $this->Application->GetVar($this->Application->findModule('Name', $module_name, 'Var').'_id'); - $block_params['current'] = 0; $block_params['separator'] = $params['separator']; - if(!isset($params['cat_id'])) - { + if (!isset($params['cat_id'])) { $params['cat_id'] = getArrayValue($params, 'cat_id') ? $params['cat_id'] : $this->Application->GetVar('m_cat_id'); - $block_params['current'] = 1; } - $product_id = $this->Application->GetVar('p_id'); - if ($product_id) { - $block_params['current'] = 0; - } - $block_params['is_module_root'] = ($params['cat_id'] == $module_root_cat) ? 1 : 0; - - if($params['cat_id'] == 0) - { - $block_params['name'] = $this->SelectParam($params, 'root_cat_render_as,block_root_cat,rootcatblock'); + if ($params['cat_id'] == 0) { + $block_params['current'] = 1; + $block_params['cat_id'] = 0; + $block_params['cat_name'] = $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params); + $block_params['name'] = $this->SelectParam($params, 'root_cat_render_as,block_root_cat,rootcatblock,render_as'); return $this->Application->ParseBlock($block_params); } - else - { - $block_params['name'] = $this->SelectParam($params,'render_as,block'); - // $cat_object = &$this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix.'_List' ); - $sql = 'SELECT CategoryId, ParentId, '.$this->getTitleField().' AS Name - FROM '.$this->Application->getUnitOption($this->Prefix, 'TableName').' - WHERE CategoryId = '.$params['cat_id']; - $res = $this->Conn->GetRow($sql); - if ($res === false) { - // in case if category is deleted - return ''; + else { + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + $navbar_field = $ml_formatter->LangFieldName('CachedNavBar'); + + $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); + $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName'); + $sql = 'SELECT '.$navbar_field.', ParentPath + FROM '.$table_name.' + WHERE '.$id_field.' = '.$params['cat_id']; + $category_data = $this->Conn->GetRow($sql); + $ret = ''; + if ($category_data) { + $category_names = explode('|', $category_data[$navbar_field]); + $category_ids = explode('|', substr($category_data['ParentPath'], 1, -1)); + + // add "Home" category at beginning of path + array_unshift($category_names, $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params)); + array_unshift($category_ids, 0); + + foreach ($category_ids as $category_pos => $category_id) { + $block_params['cat_id'] = $category_id; + $block_params['cat_name'] = $category_names[$category_pos]; + $block_params['current'] = ($params['cat_id'] == $category_id) && !$module_item_id ? 1 : 0; + $block_params['is_module_root'] = $category_id == $module_category_id ? 1 : 0; + $block_params['name'] = $this->SelectParam($params, 'render_as,block'); + + // which block to parse as current ? + if ($block_params['is_module_root'] == 1) { // module root + $block_params['name'] = $this->SelectParam($params, 'module_root_render_as,block_module_root,rootmoduleblock,render_as'); + } + + if ($block_params['current'] == 1) { // current cat (label) + $block_params['name'] = $this->SelectParam($params, 'current_render_as,block_current,currentblock,render_as'); + } + + $this->Application->SetVar($this->Prefix.'_id', $category_id); + $ret .= $this->Application->ParseBlock($block_params, 1); + } } - - $block_params['cat_name'] = $res['Name']; - $block_params['cat_id'] = $res['CategoryId']; - - $parent_params = $params; - $parent_params['cat_id'] = $res['ParentId']; - - // which block to parse as current ? - if ($block_params['is_module_root'] == 1) { // module root - $block_params['name'] = $this->SelectParam($params, 'module_root_render_as,block_module_root,rootmoduleblock'); - } - if ($block_params['current'] == 1) { // current cat (label) - $block_params['name'] = $this->SelectParam($params, 'current_render_as,block_current,currentblock'); - } - - $this->Application->SetVar($this->Prefix.'_id', $res['CategoryId']); - $current_cat = $this->Application->ParseBlock($block_params, 1); - - $this->Application->SetVar($this->Prefix.'_id', $res['ParentId']); - $parent_cat = $this->CategoryPath($parent_params); - - return $parent_cat.$current_cat; + + return $ret; } }