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->getFormatter($formatter); | ||||
$formatter = $this->Application->recallObject($formatter); | |||||
if ( $formatter instanceof kMultiLanguage && strpos((string)$format, 'no_default') === false ) { | if ( $formatter instanceof kMultiLanguage && strpos((string)$format, 'no_default') === false ) { | ||||
$format = rtrim('no_default;' . $format, ';'); | $format = rtrim('no_default;' . $format, ';'); | ||||
} | } | ||||
$res = $formatter->Format($value, $field_name, $this, $format); | $res = $formatter->Format($value, $field_name, $this, $format); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
public function SetField($name,$value) | public function SetField($name,$value) | ||||
{ | { | ||||
$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 | /* | ||||
// according to regional format, even when formatter is not set (try seting format to 1.234,56 to understand why) | * kFormatter is always used, to make sure, that numeric value is converted to normal representation | ||||
/** @var kFormatter $formatter */ | * according to regional format, even when formatter is not set (try setting format to 1.234,56 to | ||||
$formatter = $this->Application->recallObject(isset($options['formatter']) ? $options['formatter'] : 'kFormatter'); | * understand why). | ||||
*/ | |||||
$parsed = $formatter->Parse($value, $name, $this); | $parsed = $this | ||||
->getFormatter(isset($options['formatter']) ? $options['formatter'] : 'kFormatter') | |||||
->Parse($value, $name, $this); | |||||
$this->SetDBField($name,$parsed); | $this->SetDBField($name,$parsed); | ||||
} | } | ||||
/** | /** | ||||
* Sets current item field value | * Sets current item field value | ||||
* (doesn't apply formatting) | * (doesn't apply formatting) | ||||
* | * | ||||
▲ Show 20 Lines • Show All 334 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 */ | $this | ||||
$formatter = $this->Application->recallObject($options['formatter']); | ->getFormatter($options['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 | ||||
* | * | ||||
* @return string | * @return string | ||||
▲ Show 20 Lines • Show All 1002 Lines • ▼ Show 20 Line(s) | |||||
/** @var kDBItem $cdata */ | /** @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)); | ||||
$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 */ | /** @var kMultiLanguage $ml_formatter */ | ||||
$ml_formatter = $this->Application->recallObject('kMultiLanguage'); | $ml_formatter = $this->getFormatter('kMultiLanguage'); | ||||
/** @var kMultiLanguageHelper $ml_helper */ | /** @var kMultiLanguageHelper $ml_helper */ | ||||
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); | $ml_helper = $this->Application->recallObject('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'); | ||||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |