Index: admin_templates/categories/categories_edit_custom.tpl
===================================================================
--- admin_templates/categories/categories_edit_custom.tpl (revision 14318)
+++ admin_templates/categories/categories_edit_custom.tpl (working copy)
@@ -3,7 +3,7 @@
-
+
+
+
+
-
+
+
\ No newline at end of file
Index: admin_templates/incs/custom_blocks.tpl
===================================================================
--- admin_templates/incs/custom_blocks.tpl (revision 14318)
+++ admin_templates/incs/custom_blocks.tpl (working copy)
@@ -110,7 +110,15 @@
| ', '')" onmouseout="hide_form_error('')">
-
+ *:
+
+
+
+
+
+
+
+
|
-
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
\ No newline at end of file
Index: kernel/db/dbitem.php
===================================================================
--- kernel/db/dbitem.php (revision 14318)
+++ kernel/db/dbitem.php (working copy)
@@ -1512,9 +1512,11 @@
return true;
}
- $cdata_key = rtrim($this->Prefix.'-cdata.'.$this->Special, '.');
- $cdata =& $this->Application->recallObject($cdata_key, null, Array('skip_autoload' => true, 'populate_ml_fields' => true));
+ $cdata_key = rtrim($this->Prefix . '-cdata.' . $this->Special, '.');
+ $cdata =& $this->Application->recallObject($cdata_key, null, Array('skip_autoload' => true));
+ /* @var $cdata kDBItem */
+
$resource_id = $this->GetDBField('ResourceId');
$cdata->Load($resource_id, 'ResourceId');
$cdata->SetDBField('ResourceId', $resource_id);
@@ -1522,9 +1524,25 @@
$ml_formatter =& $this->Application->recallObject('kMultiLanguage');
/* @var $ml_formatter kMultiLanguage */
+ $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper');
+ /* @var $ml_helper kMultiLanguageHelper */
+
foreach ($this->customFields as $custom_id => $custom_name) {
- $force_primary = isset($cdata->Fields['cust_'.$custom_id]['force_primary']) && $cdata->Fields['cust_'.$custom_id]['force_primary'];
- $cdata->SetDBField($ml_formatter->LangFieldName('cust_'.$custom_id, $force_primary), $this->GetDBField('cust_'.$custom_name));
+ $field_options = $cdata->GetFieldOptions('cust_' . $custom_id);
+ $force_primary = isset($field_options['force_primary']) && $field_options['force_primary'];
+
+ if ($force_primary) {
+ $cdata->SetDBField($ml_formatter->LangFieldName('cust_' . $custom_id, true), $this->GetDBField('cust_' . $custom_name));
+ }
+ else {
+ for ($language_id = 1; $language_id <= $ml_helper->languageCount; $language_id++) {
+ if (!$ml_helper->LanguageFound($language_id)) {
+ continue;
+ }
+
+ $cdata->SetDBField('l' . $language_id . '_cust_' . $custom_id, $this->GetDBField('l' . $language_id . '_cust_' . $custom_name));
+ }
+ }
}
return $cdata->isLoaded() ? $cdata->Update() : $cdata->Create();
Index: units/custom_data/custom_data_event_handler.php
===================================================================
--- units/custom_data/custom_data_event_handler.php (revision 14318)
+++ units/custom_data/custom_data_event_handler.php (working copy)
@@ -147,8 +147,7 @@
$virtual_fields = $this->Application->getUnitOption($prefix, 'VirtualFields', Array());
$cf_helper =& $this->Application->recallObject('InpCustomFieldsHelper');
- $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
- /* @var $ml_formatter kMultiLanguage */
+ /* @var $cf_helper InpCustomFieldsHelper */
$is_install = defined('IS_INSTALL') && IS_INSTALL;
@@ -157,10 +156,12 @@
$field_options = Array('type' => 'string', 'default' => $custom_params['DefaultValue']);
// raises warnings during 4.3.9 -> 5.0.0 upgrade, no fatal sqls though
- if ($custom_params['IsRequired']) {
+ if ( $custom_params['IsRequired'] ) {
$field_options['required'] = 1;
}
+ $calculated_fields['cust_' . $custom_name] = 'cust.l' . $this->Application->GetDefaultLanguageId() .'_cust_' . $custom_id;
+
switch ($custom_params['ElementType']) {
case 'date':
unset($field_options['options']);
@@ -187,19 +188,17 @@
default:
if ($custom_params['MultiLingual']) {
- $calculated_fields['cust_'.$custom_name.'_Primary'] = 'cust.'.$ml_formatter->LangFieldName('cust_'.$custom_id, true);
- $virtual_fields['cust_'.$custom_name.'_Primary'] = $field_options;
- $field_options['master_field'] = 'cust_'.$custom_name.'_Primary';
- $field_options['formatter'] = 'kCustomFieldFormatter';
+ $field_options['formatter'] = 'kMultiLanguage';
+ $calculated_fields['cust_' . $custom_name] = 'cust.l%2$s_cust_' . $custom_id;
}
break;
}
- $calculated_fields['cust_'.$custom_name] = 'cust.'.$ml_formatter->LangFieldName('cust_'.$custom_id, !$custom_params['MultiLingual']);
- if (!isset($virtual_fields['cust_'.$custom_name])) {
- $virtual_fields['cust_'.$custom_name] = Array();
+ if ( !isset($virtual_fields['cust_' . $custom_name]) ) {
+ $virtual_fields['cust_' . $custom_name] = Array ();
}
- $virtual_fields['cust_'.$custom_name] = array_merge_recursive2($field_options, $virtual_fields['cust_'.$custom_name]);
+
+ $virtual_fields['cust_' . $custom_name] = array_merge_recursive2($field_options, $virtual_fields['cust_' . $custom_name]);
$custom_fields[$custom_id] = $custom_name;
}
Index: units/custom_fields/custom_fields_config.php
===================================================================
--- units/custom_fields/custom_fields_config.php (revision 14318)
+++ units/custom_fields/custom_fields_config.php (working copy)
@@ -158,32 +158,5 @@
// 'IsSystem' => Array ('title' => 'la_col_IsSystem', 'filter_block' => 'grid_options_filter'),
),
),
-
- 'SeparateTab' => Array (
- 'Icons' => Array (
- 'default' => 'icon16_item.png',
- ),
- 'Selector' => '',
- 'Fields' => Array (
- 'FieldName' => Array ( 'title'=>'la_col_FieldName', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_like_filter', 'width' => 200, ),
- 'Prompt' => Array ( 'title'=>'la_col_Prompt', 'data_block' => 'grid_data_label_ml_td', 'ElementTypeField' => 'ElementType', 'filter_block' => 'grid_empty_filter', 'width' => 200, ),
- 'Value' => Array ( 'title'=>'la_col_Value', 'data_block' => 'edit_custom_td', 'filter_block' => 'grid_empty_filter', 'width' => 200, ),
- 'Error' => Array ( 'title'=>'la_col_Error', 'data_block' => 'custom_error_td', 'filter_block' => 'grid_empty_filter', 'width' => 100, ),
- ),
- ),
-
- 'SeparateTabOriginal' => Array (
- 'Icons' => Array (
- 'default' => 'icon16_item.png',
- ),
- 'Selector' => '',
- 'Fields' => Array (
- 'FieldName' => Array ( 'title'=>'la_col_FieldName', 'data_block' => 'grid_icon_td', 'filter_block' => 'grid_like_filter'),
- 'Prompt' => Array ( 'title'=>'la_col_Prompt', 'data_block' => 'grid_data_label_ml_td', 'ElementTypeField' => 'ElementType', 'filter_block' => 'grid_empty_filter'),
- 'Value' => Array ( 'title'=>'la_col_Value', 'data_block' => 'edit_custom_td', 'filter_block' => 'grid_empty_filter'),
- 'OriginalValue' => Array ( 'title'=>'la_col_OriginalValue', 'data_block' => 'grid_original_td', 'filter_block' => 'grid_like_filter'),
- ),
- ),
-
),
);
\ No newline at end of file
Index: units/custom_fields/custom_fields_tag_processor.php
===================================================================
--- units/custom_fields/custom_fields_tag_processor.php (revision 14318)
+++ units/custom_fields/custom_fields_tag_processor.php (working copy)
@@ -112,14 +112,25 @@
$this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); // for edit/delete links using GET
if ($source_prefix) {
- $list->SetDBField($params['value_field'], $source_object->GetDBField('cust_'.$list->GetDBField('FieldName')));
+ $options = $source_object->GetFieldOptions('cust_'.$list->GetDBField('FieldName'));
+
+ if ( isset($options['formatter']) && $options['formatter'] == 'kMultiLanguage' ) {
+ $language_prefix = 'l' . $this->Application->GetVar('m_lang') . '_';
+ }
+ else {
+ $language_prefix = '';
+ }
+
+ $list->SetDBField($params['value_field'], $source_object->GetDBField($language_prefix . 'cust_'.$list->GetDBField('FieldName')));
+
if ($display_original) {
$list->SetDBField('OriginalValue', $original_object->GetField('cust_'.$list->GetDBField('FieldName')));
}
+
$block_params['field'] = $block_params['virtual_field'] = 'cust_'.$list->GetDBField('FieldName');
$block_params['show_heading'] = ($prev_heading != $list->GetDBField('Heading') ) ? 1 : 0;
- $options = $source_object->GetFieldOptions('cust_'.$list->GetDBField('FieldName'));
+
$list->SetDBField('DirectOptions', isset($options['options']) ? $options['options'] : false);
}