Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/kbase.php
Show First 20 Lines • Show All 877 Lines • ▼ Show 20 Line(s) | |||||
*/ | */ | ||||
public function GetField($name, $format = null) | public function GetField($name, $format = null) | ||||
{ | { | ||||
$formatter_class = $this->GetFieldOption($name, 'formatter'); | $formatter_class = $this->GetFieldOption($name, 'formatter'); | ||||
if ( $formatter_class ) { | if ( $formatter_class ) { | ||||
$value = ($formatter_class == 'kMultiLanguage') && !preg_match('/^l[0-9]+_/', $name) ? '' : $this->GetDBField($name); | $value = ($formatter_class == 'kMultiLanguage') && !preg_match('/^l[0-9]+_/', $name) ? '' : $this->GetDBField($name); | ||||
/** @var kFormatter $formatter */ | |||||
$formatter = $this->Application->recallObject($formatter_class); | $formatter = $this->Application->recallObject($formatter_class); | ||||
/* @var $formatter kFormatter */ | |||||
return $formatter->Format($value, $name, $this, $format); | return $formatter->Format($value, $name, $this, $format); | ||||
} | } | ||||
return $this->GetDBField($name); | return $this->GetDBField($name); | ||||
} | } | ||||
/** | /** | ||||
Show All 32 Lines | |||||
public function UpdateFormattersSubFields($fields = null) | public function UpdateFormattersSubFields($fields = null) | ||||
{ | { | ||||
if ( !is_array($fields) ) { | if ( !is_array($fields) ) { | ||||
$fields = array_keys($this->Fields); | $fields = array_keys($this->Fields); | ||||
} | } | ||||
foreach ($fields as $field) { | foreach ($fields as $field) { | ||||
if ( isset($this->Fields[$field]['formatter']) ) { | if ( isset($this->Fields[$field]['formatter']) ) { | ||||
/** @var kFormatter $formatter */ | |||||
$formatter = $this->Application->recallObject($this->Fields[$field]['formatter']); | $formatter = $this->Application->recallObject($this->Fields[$field]['formatter']); | ||||
/* @var $formatter kFormatter */ | |||||
$formatter->UpdateSubFields($field, $this->GetDBField($field), $this->Fields[$field], $this); | $formatter->UpdateSubFields($field, $this->GetDBField($field), $this->Fields[$field], $this); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Use formatters, specified in field declarations to perform additional field initialization in unit config | * Use formatters, specified in field declarations to perform additional field initialization in unit config | ||||
* | * | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function prepareConfigOptions() | protected function prepareConfigOptions() | ||||
{ | { | ||||
$field_names = array_keys($this->Fields); | $field_names = array_keys($this->Fields); | ||||
foreach ($field_names as $field_name) { | foreach ($field_names as $field_name) { | ||||
if ( !array_key_exists('formatter', $this->Fields[$field_name]) ) { | if ( !array_key_exists('formatter', $this->Fields[$field_name]) ) { | ||||
continue; | continue; | ||||
} | } | ||||
/** @var kFormatter $formatter */ | |||||
$formatter = $this->Application->recallObject( $this->Fields[$field_name]['formatter'] ); | $formatter = $this->Application->recallObject( $this->Fields[$field_name]['formatter'] ); | ||||
/* @var $formatter kFormatter */ | |||||
$formatter->PrepareOptions($field_name, $this->Fields[$field_name], $this); | $formatter->PrepareOptions($field_name, $this->Fields[$field_name], $this); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Escapes fields only, not expressions | * Escapes fields only, not expressions | ||||
* | * | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Line(s) | |||||
if (is_array($table_info['ForeignKey'])) { | if (is_array($table_info['ForeignKey'])) { | ||||
$table_info['ForeignKey'] = getArrayValue($table_info, 'ForeignKey', $parent_prefix); | $table_info['ForeignKey'] = getArrayValue($table_info, 'ForeignKey', $parent_prefix); | ||||
} | } | ||||
if (is_array($table_info['ParentTableKey'])) { | if (is_array($table_info['ParentTableKey'])) { | ||||
$table_info['ParentTableKey'] = getArrayValue($table_info, 'ParentTableKey', $parent_prefix); | $table_info['ParentTableKey'] = getArrayValue($table_info, 'ParentTableKey', $parent_prefix); | ||||
} | } | ||||
/** @var kDBItem $main_object */ | |||||
$main_object = $this->Application->recallObject($parent_prefix.'.'.$special, null, Array ('raise_warnings' => 0)); | $main_object = $this->Application->recallObject($parent_prefix.'.'.$special, null, Array ('raise_warnings' => 0)); | ||||
/* @var $main_object kDBItem */ | |||||
if (!$main_object->isLoaded() && $guess_special) { | if (!$main_object->isLoaded() && $guess_special) { | ||||
$main_object = $this->Application->recallObject($parent_prefix); | $main_object = $this->Application->recallObject($parent_prefix); | ||||
} | } | ||||
return array_merge($table_info, Array('ParentId'=> $main_object->GetDBField( $table_info['ParentTableKey'] ) ) ); | return array_merge($table_info, Array('ParentId'=> $main_object->GetDBField( $table_info['ParentTableKey'] ) ) ); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |