Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/utility/formatters/multilang_formatter.php
Show First 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | |||||
// prevents real field with formatter set to be saved in db | // prevents real field with formatter set to be saved in db | ||||
$virtual_fields[$field_name] = $object_fields[$field_name]; | $virtual_fields[$field_name] = $object_fields[$field_name]; | ||||
$object->SetFieldOptions($field_name, $object_fields[$field_name], true); | $object->SetFieldOptions($field_name, $object_fields[$field_name], true); | ||||
} | } | ||||
elseif (array_key_exists($field_name, $virtual_fields)) { | elseif (array_key_exists($field_name, $virtual_fields)) { | ||||
// substitute virtual field | // substitute virtual field | ||||
$calculated_fields = $this->Application->getUnitOption($object->Prefix, 'CalculatedFields', Array ()); | $calculated_fields = $this->Application->getUnitOption($object->Prefix, 'CalculatedFields', Array ()); | ||||
$calculated_field_special = array_key_exists($object->Special, $calculated_fields) ? $object->Special : (array_key_exists('', $calculated_fields) ? '' : false); | $calculated_field_special = array_key_exists($object->Special, $calculated_fields) ? $object->Special : (array_key_exists('', $calculated_fields) ? '' : false); | ||||
/* @var $calculated_fields Array */ | /** @var Array $calculated_fields */ | ||||
$tmp_field_options = $virtual_fields[$field_name]; | $tmp_field_options = $virtual_fields[$field_name]; | ||||
$tmp_field_options['master_field'] = $field_name; | $tmp_field_options['master_field'] = $field_name; | ||||
$tmp_field_options['error_field'] = $field_name; | $tmp_field_options['error_field'] = $field_name; | ||||
$field_required = array_key_exists('required', $tmp_field_options) && $tmp_field_options['required']; | $field_required = array_key_exists('required', $tmp_field_options) && $tmp_field_options['required']; | ||||
foreach ($languages as $language_id) { | foreach ($languages as $language_id) { | ||||
// make all non-primary language fields not required | // make all non-primary language fields not required | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
$object->setFields($object_fields); | $object->setFields($object_fields); | ||||
$virtual_field_options = $object->GetFieldOptions($field_name, true); | $virtual_field_options = $object->GetFieldOptions($field_name, true); | ||||
unset($virtual_fields[$field_name]['required'], $virtual_field_options['required']); | unset($virtual_fields[$field_name]['required'], $virtual_field_options['required']); | ||||
$object->SetFieldOptions($field_name, $virtual_field_options, true); | $object->SetFieldOptions($field_name, $virtual_field_options, true); | ||||
} | } | ||||
// substitute grid fields | // substitute grid fields | ||||
/** @var Array $grids */ | |||||
$grids = $this->Application->getUnitOption($object->Prefix, 'Grids', Array ()); | $grids = $this->Application->getUnitOption($object->Prefix, 'Grids', Array ()); | ||||
/* @var $grids Array */ | |||||
foreach ($grids as $name => $grid) { | foreach ($grids as $name => $grid) { | ||||
if ( getArrayValue($grid, 'Fields', $field_name) ) { | if ( getArrayValue($grid, 'Fields', $field_name) ) { | ||||
// used by column picker to track column position | // used by column picker to track column position | ||||
$grids[$name]['Fields'][$field_name]['formatter_renamed'] = true; | $grids[$name]['Fields'][$field_name]['formatter_renamed'] = true; | ||||
if (!array_key_exists('format', $grids[$name]['Fields'][$field_name])) { | if (!array_key_exists('format', $grids[$name]['Fields'][$field_name])) { | ||||
// prevent displaying value from primary language | // prevent displaying value from primary language | ||||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | |||||
*/ | */ | ||||
public function Parse($value, $field_name, &$object) | public function Parse($value, $field_name, &$object) | ||||
{ | { | ||||
if ($value == '') return NULL; | if ($value == '') return NULL; | ||||
return $value; | return $value; | ||||
} | } | ||||
} | } | ||||
No newline at end of file | No newline at end of file |