Index: trunk/core/kernel/kbase.php =================================================================== diff -u -r4284 -r4758 --- trunk/core/kernel/kbase.php (.../kbase.php) (revision 4284) +++ trunk/core/kernel/kbase.php (.../kbase.php) (revision 4758) @@ -157,7 +157,7 @@ * @var Array */ var $customFields = Array(); - + /** * All virtual field names * @@ -174,14 +174,14 @@ */ var $CalculatedFields = Array(); - + /** * Calculated fields, that contain aggregated functions, e.g. COUNT, SUM, etc. * * @var Array */ var $AggregatedCalculatedFields = Array(); - + /** * Description * @@ -234,7 +234,7 @@ function SwitchToTemp() { $this->TableName = $this->Application->getUnitOption($this->Prefix, 'TableName'); - $this->SetTableName( kTempTablesHandler::GetTempName($this->TableName) ); + $this->SetTableName( $this->Application->GetTempName($this->TableName) ); $this->mode = 't'; } @@ -245,7 +245,7 @@ */ function IsTempTable() { - return kTempTablesHandler::IsTempTable($this->TableName); + return $this->Application->IsTempTable($this->TableName); } /** @@ -270,7 +270,7 @@ return $query; } - + /** * Returns required mixing of aggregated & non-aggregated calculated fields * @@ -283,23 +283,23 @@ case 0: $fields = array_merge($this->CalculatedFields, $this->AggregatedCalculatedFields); break; - + case 1: $fields = $this->CalculatedFields; break; - + case 2: $fields = $this->AggregatedCalculatedFields; break; - + default: $fields = Array(); break; } - + return $fields; } - + /** * Insert calculated fields sql into query in place of %2$s, * return processed query. @@ -332,11 +332,11 @@ */ function replaceModePrefix($query) { - $live_table = substr(kTempTablesHandler::GetLiveName($this->TableName), strlen(TABLE_PREFIX)); + $live_table = substr(GetLiveName($this->TableName), strlen(TABLE_PREFIX)); preg_match('/'.preg_quote(TABLE_PREFIX, '/').'(.*)'.preg_quote($live_table, '/').'/', $this->TableName, $rets); return str_replace('%3$s', $rets[1], $query); } - + /** * Adds calculated field declaration to object. * @@ -395,7 +395,7 @@ { $this->AggregatedCalculatedFields = isset($fields[$this->Special]) ? $fields[$this->Special] : (isset($fields['']) ? $fields[''] : Array()); } - + /** * Set's field names from table * from config @@ -407,7 +407,7 @@ { $this->customFields = $fields; } - + /** * Set's field names from table * from config @@ -481,7 +481,13 @@ function GetFieldOptions($field) { - return isset($this->Fields[$field]) ? $this->Fields[$field] : Array(); + if (isset($this->Fields[$field])) { + $this->PrepareFieldOptions($field); + return $this->Fields[$field]; + } + else { + return Array(); + } } /** @@ -527,22 +533,27 @@ { foreach (array_keys($this->Fields) as $field_name) { - $field_options =& $this->Fields[$field_name]; - if( isset($field_options['options_sql']) ) - { - // replace with query result - $select_clause = $field_options['option_title_field'].','.$field_options['option_key_field']; - $sql = sprintf($field_options['options_sql'], $select_clause, $this->Application->GetVar('m_lang')); +// $this->PrepareFieldOptions($field_name); + $this->PrepareOptions($field_name); + } + } - $options_hash = getArrayValue($field_options,'options'); - if($options_hash === false) $options_hash = Array(); + function PrepareFieldOptions($field_name) + { + $field_options =& $this->Fields[$field_name]; + if( isset($field_options['options_sql']) ) + { + // replace with query result + $select_clause = $field_options['option_title_field'].','.$field_options['option_key_field']; + $sql = sprintf($field_options['options_sql'], $select_clause, $this->Application->GetVar('m_lang')); - $dynamic_options = $this->Conn->GetCol($sql, $field_options['option_key_field']); - $field_options['options'] = array_merge_recursive2($options_hash, $dynamic_options); + $options_hash = getArrayValue($field_options,'options'); + if($options_hash === false) $options_hash = Array(); - unset($field_options['options_sql']); - } - $this->PrepareOptions($field_name); + $dynamic_options = $this->Conn->GetCol($sql, $field_options['option_key_field']); + $field_options['options'] = array_merge_recursive2($options_hash, $dynamic_options); + + unset($field_options['options_sql']); } }