Index: branches/5.2.x/core/units/categories/categories_item.php =================================================================== diff -u -N -r15137 -r15390 --- branches/5.2.x/core/units/categories/categories_item.php (.../categories_item.php) (revision 15137) +++ branches/5.2.x/core/units/categories/categories_item.php (.../categories_item.php) (revision 15390) @@ -1,6 +1,6 @@ Array ('ParentPath' => '|', 'NamedParentPath' => '', 'CachedTemplate' => ''), + ); + + $ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); + /* @var $ml_helper kMultiLanguageHelper */ + + $languages = $ml_helper->getLanguages(); $parent_id = $this->GetDBField('ParentId'); - if ( $parent_id == 0 ) { - $parent_path = '|'; + if ( !isset($parent_cache[$parent_id]) ) { + $select_fields = Array ('ParentPath', 'NamedParentPath', 'Template', 'CachedTemplate'); + + foreach ($languages as $language_id) { + $select_fields[] = 'l' . $language_id . '_Name'; + $select_fields[] = 'l' . $language_id . '_CachedNavbar'; + } + + $sql = 'SELECT ' . implode(', ', $select_fields) . ' + FROM ' . $this->Application->getUnitOption($this->Prefix, 'TableName') . ' + WHERE CategoryId = ' . $parent_id; + $parent_cache[$parent_id] = $this->Conn->GetRow($sql); } - else { - $sql = 'SELECT ParentPath - FROM ' . $this->Application->getUnitOption($this->Prefix, 'TableName') . ' WHERE - CategoryId = ' . $parent_id; - $parent_path = $this->Conn->GetOne($sql); + + $named_parent_path = trim($parent_cache[$parent_id]['NamedParentPath'] . '/' . $this->GetDBField('Filename'), '/'); + $cached_template = $this->GetDBField('Template') == CATEGORY_TEMPLATE_INHERIT ? $parent_cache[$parent_id]['CachedTemplate'] : $this->GetDBField('Template'); + + // maybe also build CachedNavbar field here + $ret = Array ( + 'ParentPath' => $parent_cache[$parent_id]['ParentPath'] . $this->GetID() . '|', + 'NamedParentPath' => $named_parent_path, + 'NamedParentPathHash' => kUtil::crc32(mb_strtolower(preg_replace('/^Content\//i', '', $named_parent_path))), + 'CachedTemplate' => $cached_template, + 'CachedTemplateHash' => kUtil::crc32(mb_strtolower($cached_template)), + ); + + $primary_language = $this->Application->GetDefaultLanguageId(); + + foreach ($languages as $language_id) { + $language_prefix = 'l' . $language_id . '_'; + $cached_navbar = $parent_cache[$parent_id][$language_prefix . 'CachedNavbar'] . '&|&'; + $cached_navbar .= $this->GetDBField($language_prefix . 'Name') ? $this->GetDBField($language_prefix . 'Name') : $this->GetDBField('l' . $primary_language . '_Name'); + + $ret['l' . $language_id . '_CachedNavbar'] = $cached_navbar; } - return $parent_path . $this->GetID() . '|'; + return $ret; } /**