Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/db/dbitem.php
Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Line(s) | |||||
if (!$formatted) { | if (!$formatted) { | ||||
return $value; | return $value; | ||||
} | } | ||||
$res = $value; | $res = $value; | ||||
$formatter = $this->GetFieldOption($field_name, 'formatter'); | $formatter = $this->GetFieldOption($field_name, 'formatter'); | ||||
if ( $formatter ) { | if ( $formatter ) { | ||||
/** @var kFormatter $formatter */ | |||||
$formatter = $this->Application->recallObject($formatter); | $formatter = $this->Application->recallObject($formatter); | ||||
/* @var $formatter kFormatter */ | |||||
$res = $formatter->Format($value, $field_name, $this, $format); | $res = $formatter->Format($value, $field_name, $this, $format); | ||||
} | } | ||||
return $res; | return $res; | ||||
} | } | ||||
/** | /** | ||||
Show All 40 Lines | |||||
$options = $this->GetFieldOptions($name); | $options = $this->GetFieldOptions($name); | ||||
$parsed = $value; | $parsed = $value; | ||||
if ($value == '') { | if ($value == '') { | ||||
$parsed = NULL; | $parsed = NULL; | ||||
} | } | ||||
// kFormatter is always used, to make sure, that numeric value is converted to normal representation | // kFormatter is always used, to make sure, that numeric value is converted to normal representation | ||||
// according to regional format, even when formatter is not set (try seting format to 1.234,56 to understand why) | // according to regional format, even when formatter is not set (try seting format to 1.234,56 to understand why) | ||||
/** @var kFormatter $formatter */ | |||||
$formatter = $this->Application->recallObject(isset($options['formatter']) ? $options['formatter'] : 'kFormatter'); | $formatter = $this->Application->recallObject(isset($options['formatter']) ? $options['formatter'] : 'kFormatter'); | ||||
/* @var $formatter kFormatter */ | |||||
$parsed = $formatter->Parse($value, $name, $this); | $parsed = $formatter->Parse($value, $name, $this); | ||||
$this->SetDBField($name,$parsed); | $this->SetDBField($name,$parsed); | ||||
} | } | ||||
/** | /** | ||||
* Sets current item field value | * Sets current item field value | ||||
▲ Show 20 Lines • Show All 336 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
public function UpdateFormattersMasterFields() | public function UpdateFormattersMasterFields() | ||||
{ | { | ||||
$this->initValidator(); // used, when called not from kValidator::Validate method | $this->initValidator(); // used, when called not from kValidator::Validate method | ||||
foreach ($this->Fields as $field => $options) { | foreach ($this->Fields as $field => $options) { | ||||
if ( isset($options['formatter']) ) { | if ( isset($options['formatter']) ) { | ||||
/** @var kFormatter $formatter */ | |||||
$formatter = $this->Application->recallObject($options['formatter']); | $formatter = $this->Application->recallObject($options['formatter']); | ||||
/* @var $formatter kFormatter */ | |||||
$formatter->UpdateMasterFields($field, $this->GetDBField($field), $options, $this); | $formatter->UpdateMasterFields($field, $this->GetDBField($field), $options, $this); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Returns variable name, used to store pending file actions | * Returns variable name, used to store pending file actions | ||||
▲ Show 20 Lines • Show All 628 Lines • ▼ Show 20 Line(s) | |||||
{ | { | ||||
$main_prefix = $this->Application->GetTopmostPrefix($this->Prefix); | $main_prefix = $this->Application->GetTopmostPrefix($this->Prefix); | ||||
$this->Application->StoreVar($main_prefix . '_modified', '1', true); // true for optional | $this->Application->StoreVar($main_prefix . '_modified', '1', true); // true for optional | ||||
if ($this->ShouldLogChanges(true)) { | if ($this->ShouldLogChanges(true)) { | ||||
$this->LogChanges($main_prefix, $mode); | $this->LogChanges($main_prefix, $mode); | ||||
if (!$this->IsTempTable()) { | if (!$this->IsTempTable()) { | ||||
/** @var kDBEventHandler $handler */ | |||||
$handler = $this->Application->recallObject($this->Prefix . '_EventHandler'); | $handler = $this->Application->recallObject($this->Prefix . '_EventHandler'); | ||||
/* @var $handler kDBEventHandler */ | |||||
$ses_var_name = $main_prefix . '_changes_' . $this->Application->GetTopmostWid($this->Prefix); | $ses_var_name = $main_prefix . '_changes_' . $this->Application->GetTopmostWid($this->Prefix); | ||||
$handler->SaveLoggedChanges($ses_var_name, $this->ShouldLogChanges()); | $handler->SaveLoggedChanges($ses_var_name, $this->ShouldLogChanges()); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
Show All 36 Lines | |||||
$fields_hash['ParentPrefix'] = Array ($main_prefix); | $fields_hash['ParentPrefix'] = Array ($main_prefix); | ||||
$fields_hash['ParentId'] = Array ($main_prefix => $this->GetID()); | $fields_hash['ParentId'] = Array ($main_prefix => $this->GetID()); | ||||
} | } | ||||
else { | else { | ||||
// sub item | // sub item | ||||
// collect foreign key values (for serial reset) | // collect foreign key values (for serial reset) | ||||
$foreign_keys = $this->Application->getUnitOption($this->Prefix, 'ForeignKey', Array ()); | $foreign_keys = $this->Application->getUnitOption($this->Prefix, 'ForeignKey', Array ()); | ||||
$dependent_fields = $fields_hash['ParentId'] = $fields_hash['ParentPrefix'] = Array (); | $dependent_fields = $fields_hash['ParentId'] = $fields_hash['ParentPrefix'] = Array (); | ||||
/* @var $foreign_keys Array */ | /** @var Array $foreign_keys */ | ||||
if ( is_array($foreign_keys) ) { | if ( is_array($foreign_keys) ) { | ||||
foreach ($foreign_keys as $prefix => $field_name) { | foreach ($foreign_keys as $prefix => $field_name) { | ||||
$dependent_fields[$field_name] = $this->GetDBField($field_name); | $dependent_fields[$field_name] = $this->GetDBField($field_name); | ||||
$fields_hash['ParentPrefix'][] = $prefix; | $fields_hash['ParentPrefix'][] = $prefix; | ||||
$fields_hash['ParentId'][$prefix] = $this->getParentId($prefix); | $fields_hash['ParentId'][$prefix] = $this->getParentId($prefix); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 260 Lines • ▼ Show 20 Line(s) | |||||
protected function saveCustomFields() | protected function saveCustomFields() | ||||
{ | { | ||||
if ( !$this->customFields || $this->inCloning ) { | if ( !$this->customFields || $this->inCloning ) { | ||||
return true; | return true; | ||||
} | } | ||||
$cdata_key = rtrim($this->Prefix . '-cdata.' . $this->Special, '.'); | $cdata_key = rtrim($this->Prefix . '-cdata.' . $this->Special, '.'); | ||||
/** @var kDBItem $cdata */ | |||||
$cdata = $this->Application->recallObject($cdata_key, null, Array ('skip_autoload' => true)); | $cdata = $this->Application->recallObject($cdata_key, null, Array ('skip_autoload' => true)); | ||||
/* @var $cdata kDBItem */ | |||||
$resource_id = $this->GetDBField('ResourceId'); | $resource_id = $this->GetDBField('ResourceId'); | ||||
$cdata->Load($resource_id, 'ResourceId'); | $cdata->Load($resource_id, 'ResourceId'); | ||||
$cdata->SetDBField('ResourceId', $resource_id); | $cdata->SetDBField('ResourceId', $resource_id); | ||||
/** @var kMultiLanguage $ml_formatter */ | |||||
$ml_formatter = $this->Application->recallObject('kMultiLanguage'); | $ml_formatter = $this->Application->recallObject('kMultiLanguage'); | ||||
/* @var $ml_formatter kMultiLanguage */ | |||||
/** @var kMultiLanguageHelper $ml_helper */ | |||||
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); | $ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); | ||||
/* @var $ml_helper kMultiLanguageHelper */ | |||||
$languages = $ml_helper->getLanguages(); | $languages = $ml_helper->getLanguages(); | ||||
foreach ($this->customFields as $custom_id => $custom_name) { | foreach ($this->customFields as $custom_id => $custom_name) { | ||||
$force_primary = $cdata->GetFieldOption('cust_' . $custom_id, 'force_primary'); | $force_primary = $cdata->GetFieldOption('cust_' . $custom_id, 'force_primary'); | ||||
if ( $force_primary ) { | if ( $force_primary ) { | ||||
$cdata->SetDBField($ml_formatter->LangFieldName('cust_' . $custom_id, true), $this->GetDBField('cust_' . $custom_name)); | $cdata->SetDBField($ml_formatter->LangFieldName('cust_' . $custom_id, true), $this->GetDBField('cust_' . $custom_name)); | ||||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |