Index: trunk/kernel/include/category.php =================================================================== diff -u -r5431 -r6093 --- trunk/kernel/include/category.php (.../category.php) (revision 5431) +++ trunk/kernel/include/category.php (.../category.php) (revision 6093) @@ -9,18 +9,18 @@ class clsCategory extends clsItem { var $Permissions; - + var $DescriptionField = ''; - + function clsCategory($CategoryId=NULL) { global $objSession; $this->clsItem(TRUE); - + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); $this->TitleField = $ml_formatter->LangFieldName('Name'); $this->DescriptionField = $ml_formatter->LangFieldName('Description'); - + $this->tablename = GetTablePrefix()."Category"; $this->type=1; $this->BasePermission ="CATEGORY"; @@ -314,59 +314,68 @@ } return $dataValid; } - + function UpdateCachedPath() { if( $this->UsingTempTable() == true) return ; $Id = $this->Get('CategoryId'); $Id2 = $Id; - + $path_parts = Array(); - $nav_parts = Array(); + $nav_parts = Array(); $named_parts = Array(); $cateogry_template = ''; $item_template = ''; - - do { - $rs = $this->adodbConnection->Execute('SELECT ParentId, '.$this->TitleField.', Filename, CachedCategoryTemplate, CachedItemTemplate FROM '.$this->tablename.' WHERE CategoryId = '.$Id2); + + $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper'); + $language_count = $ml_helper->getLanguageCount(); + $primary_lang_id = $this->Application->GetDefaultLanguageId(); + + do { + $rs = $this->adodbConnection->Execute('SELECT * FROM '.$this->tablename.' WHERE CategoryId = '.$Id2); $path_parts[] = $Id2; - $nav_parts[] = $rs->fields[$this->TitleField]; $named_parts[] = $rs->fields['Filename']; + $i = 1; + while ($i <= $language_count) { + $nav_parts[$i][] = $rs->fields['l'.$i.'_Name'] ? $rs->fields['l'.$i.'_Name'] : $rs->fields['l'.$primary_lang_id.'_Name']; + $i++; + } + if (!$cateogry_template && $rs->fields['CachedCategoryTemplate']) { $cateogry_template = $rs->fields['CachedCategoryTemplate']; } - - if (!$item_template && $rs->fields['CachedItemTemplate']) { - $item_template = $rs->fields['CachedItemTemplate']; - } - + $Id2 = ($rs && !$rs->EOF) ? $rs->fields['ParentId'] : '0'; - + } while ($Id2 != '0'); - + $parent_path = '|'.implode('|', array_reverse($path_parts) ).'|'; - $nav_bar = implode('>', array_reverse($nav_parts) ); $named_path = implode('/', array_reverse($named_parts) ); - + + $i = 1; + while ($i <= $language_count) { + $this->Set('l'.$i.'_CachedNavbar', implode('&|&', array_reverse($nav_parts[$i]) )); + $i++; + } + $this->Set('ParentPath', $parent_path); - $this->Set('CachedNavbar', $nav_bar); $this->Set('NamedParentPath', $named_path); $this->Set('CachedCategoryTemplate', $cateogry_template); - $this->Set('CachedItemTemplate', $item_template); $this->Update(); - + } - function GetCachedNavBar() - { - $res = $this->Get("CachedNavbar"); - if(!strlen($res)) - { - $this->UpdateCachedPath(); - $res = $this->Get("CachedNavbar"); - } - return $res; + function GetCachedNavBar() + { + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + $navbar_field = $ml_formatter->LangFieldName('CachedNavbar'); + $res = $this->Get($navbar_field); + if (!strlen($res)) { + $this->UpdateCachedPath(); + $res = $this->Get($navbar_field); + } + return str_replace('&|&', ' > ', $res); } function Increment_Count() { @@ -828,6 +837,12 @@ return $res; } + function GetNavbar() + { + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + return str_replace('&|&', ' > ', $this->Get($ml_formatter->LangFieldName('CachedNavbar'))); + } + function ParseObject($element) { global $objConfig, $objCatList, $rootURL, $var_list, $var_list_update, $m_var_list_update, $objItemTypes,$objCountCache, $objUsers; @@ -890,6 +905,9 @@ @field:cat.cachednavbar @description: Category cached navbar */ + + $this->Set('CachedNavbar', $this->GetNavbar()); + $ret = $this->HighlightField("CachedNavbar"); if(!strlen($ret)) { @@ -1360,8 +1378,9 @@ return $this->Get("ParentId"); break; case "cat_fullpath": - return $this->Get("CachedNavbar"); + return $this->GetNavbar(); break; + case "cat_name": return $this->Get($this->TitleField); break; @@ -1472,7 +1491,7 @@ } } - function ParentNames() + /*function ParentNames() { global $objCatList; @@ -1500,9 +1519,9 @@ $this->Set("CachedNavbar",$nav); $this->Update(); } - $res = explode(">",$this->Get("CachedNavbar")); + $res = explode("&|&",$this->Get("CachedNavbar")); return $res; - } + }*/ // not used anywhere /* function UpdateCacheCounts() @@ -1546,15 +1565,15 @@ var $TitleField = ''; var $DescriptionField = ''; - + function clsCatList() { global $m_var_list; $this->clsItemCollection(); $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); $this->TitleField = $ml_formatter->LangFieldName('Name'); $this->DescriptionField = $ml_formatter->LangFieldName('Description'); - + $this->Prefix = 'c'; $this->classname="clsCategory"; $this->AdminSearchFields = array($this->TitleField, $this->DescriptionField); @@ -2097,24 +2116,24 @@ function &Add_NEW($fields_hash, $from_import = false) { global $objSession; - + $fields_hash['CreatedById'] = $objSession->Get('PortalUserId'); - + $d = new clsCategory(NULL); $fields_hash['Filename'] = $d->StripDisallowed($fields_hash['Filename']); $d->tablename = $this->SourceTable; - + if ( $d->UsingTempTable() ) { $d->Set('CategoryId', -1); } $d->idfield = 'CategoryId'; - + foreach ($fields_hash as $field_name => $field_value) { $d->Set($field_name, $field_value); } - + $d->Create(); - + if (!$from_import) { if ($d->Get('Status') == STATUS_ACTIVE) { $d->SendUserEventMail("CATEGORY.ADD", $objSession->Get("PortalUserId")); @@ -2129,7 +2148,7 @@ } return $d; } - + function &Add( $ParentId, $Name, $Description, $CreatedOn, $EditorsPick, $Status, $Hot, $New, $Pop, $Priority, $MetaKeywords,$MetaDesc, $auto_filename = 1, $filename = '') { @@ -2166,16 +2185,16 @@ return $d; } - function &Edit_Category($category_id, $fields_hash) + function &Edit_Category($category_id, $fields_hash) { $d =& $this->GetCategory($category_id); - + $fields_hash['Filename'] = $d->StripDisallowed($fields_hash['Filename']); - + foreach ($fields_hash as $field_name => $field_value) { $d->Set($field_name, $field_value); } - + $d->Update(); $d->UpdateCachedPath(); return $d; @@ -2349,7 +2368,7 @@ } $perm_status = $objSession->HasCatPermission('CATEGORY.DELETE', $check_cat); } - + if (($d->Get("CategoryId") == $Id) && $perm_status) { $d->SendUserEventMail("CATEGORY.DELETE",$objSession->Get("PortalUserId")); $d->SendAdminEventMail("CATEGORY.DELETE"); @@ -2417,7 +2436,9 @@ $rs->MoveNext(); } - $rs = $this->adodbConnection->Execute("SELECT * FROM ".$this->SourceTable." WHERE CachedNavbar IS NULL or CachedNavBar=''"); + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + $navbar_field = $ml_formatter->LangFieldName('CachedNavbar'); + $rs = $this->adodbConnection->Execute('SELECT * FROM '.$this->SourceTable.' WHERE '.$navbar_field.' IS NULL OR '.$navbar_field.' = ""'); while($rs && !$rs->EOF) { $c = new clsCategory(NULL);