Index: trunk/kernel/units/categories/categories_item.php =================================================================== diff -u -r5173 -r6093 --- trunk/kernel/units/categories/categories_item.php (.../categories_item.php) (revision 5173) +++ trunk/kernel/units/categories/categories_item.php (.../categories_item.php) (revision 6093) @@ -133,11 +133,47 @@ { if ( !$this->GetDBField('AutomaticFilename') && $this->GetDBField('Filename') ) return false; - $title_field = $this->Application->getUnitOption($this->Prefix, 'TitleField'); - $name = $this->stripDisallowed( $this->GetDBField($title_field) ); + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + $name = $this->stripDisallowed( $this->GetDBField( $ml_formatter->LangFieldName('Name', true) ) ); if ( $name != $this->GetDBField('Filename') ) $this->SetDBField('Filename', $name); } + + /** + * Allows to detect if root category being edited + * + * @param Array $params + */ + function IsRoot() + { + $category_id = $this->Application->GetVar($this->getPrefixSpecial().'_id'); + if (is_numeric($category_id) && $category_id == 0) { + $sql = 'SELECT '.$this->IDField.' + FROM '.$this->TableName.' + WHERE '.$this->IDField.' = '.$category_id; + if ($this->Conn->GetOne($sql) === false) { + return true; + } + } + + return false; + } + + /** + * Sets correct name to Home category while editing it + * + * @return bool + */ + function IsNewItem() + { + if ($this->IsRoot()) { + $title_field = $this->Application->getUnitOption($this->Prefix, 'TitleField'); + $category_name = $this->Application->Phrase( $this->Application->ConfigValue('Root_Name') ); + $this->SetDBField($title_field, $category_name); + return false; + } + return parent::IsNewItem(); + } } ?> \ No newline at end of file