Index: trunk/core/kernel/db/dbitem.php =================================================================== diff -u -N -r7855 -r8061 --- trunk/core/kernel/db/dbitem.php (.../dbitem.php) (revision 7855) +++ trunk/core/kernel/db/dbitem.php (.../dbitem.php) (revision 8061) @@ -72,11 +72,17 @@ /** * Set's default values for all fields * + * @param bool $populate_ml_fields create all ml fields from db in config or not + * * @access public */ - function SetDefaultValues() + function SetDefaultValues($populate_ml_fields = false) { - parent::SetDefaultValues(); + parent::SetDefaultValues($populate_ml_fields); + if ($populate_ml_fields) { + $this->PopulateMultiLangFields(); + } + foreach ($this->Fields as $field => $params) { if ( isset($params['default']) ) { $this->SetDBField($field, $params['default']); @@ -747,6 +753,25 @@ return $ret; } + function PopulateMultiLangFields() + { + $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper'); + $lang_count = $ml_helper->getLanguageCount(); + foreach ($this->Fields as $field => $options) + { + if (isset($options['formatter']) && $options['formatter'] == 'kMultiLanguage' && isset($options['master_field'])) { + if (preg_match('/^l([0-9]+)_(.*)/', $field, $regs)) { + $l = $regs[1]; + $name = $regs[2]; + for ($i=1; $i<=$lang_count; $i++) { + if ($i == $l) continue; + $this->Fields['l'.$i.'_'.$name] = $options; + } + } + } + } + } + /** * Sets new name for item in case if it is beeing copied * in same table