Index: branches/5.2.x/core/units/admin/admin_events_handler.php =================================================================== diff -u -N -r13840 -r14092 --- branches/5.2.x/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 13840) +++ branches/5.2.x/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 14092) @@ -1,6 +1,6 @@ Application->isCachingType(CACHING_TYPE_MEMORY)) { $this->Application->deleteCache('master:config_files'); - $this->Application->deleteCache('master:configs_parsed'); - $this->Application->deleteCache('master:sections_parsed'); } else { $this->Application->deleteDBCache('config_files'); - $this->Application->deleteDBCache('configs_parsed'); - $this->Application->deleteDBCache('sections_parsed'); } + $this->OnResetParsedData($event); + $skin_helper =& $this->Application->recallObject('SkinHelper'); /* @var $skin_helper SkinHelper */ $skin_helper->deleteCompiled(); + } - $event->SetRedirectParam('refresh_tree', 1); + /** + * Resets parsed data from unit configs + * + * @param kEvent $event + */ + function OnResetParsedData(&$event) + { + if ($this->Application->GetVar('ajax') == 'yes') { + $event->status = erSTOP; + } + + $this->Application->UnitConfigReader->ResetParsedData(); + + if ( $this->Application->GetVar('validate_configs') ) { + $event->SetRedirectParam('validate_configs', 1); + } } function OnResetMemcache(&$event) @@ -270,24 +284,35 @@ } } + // 2. get field default value $default_value = $field_info['Default']; - if (in_array($php_type, $float_types)) { + $not_null = $field_info['Null'] != 'YES'; + + if (is_numeric($default_value)) { + $default_value = preg_match('/[\.,]/', $default_value) ? (float)$default_value : (int)$default_value; + } + + if ( is_null($default_value) && $not_null ) { + $default_value = $field_options['type'] == 'string' ? '' : 0; + } + + if ( in_array($php_type, $float_types) ) { // this is float number if (preg_match('/'.$db_types.'\([\d]+,([\d]+)\)/i', $field_info['Type'], $regs)) { // size is described in structure -> add formatter $field_options['formatter'] = 'kFormatter'; $field_options['format'] = '%01.'.$regs[1].'f'; - if ($field_info['Null'] != 'YES') { + + if ($not_null) { // null fields, will most likely have NULL as default value $default_value = 0; } } - else { + elseif ($not_null) { // no size information, just convert to float - if ($field_info['Null'] != 'YES') { - // null fields, will most likely have NULL as default value - $default_value = (float)$default_value; - } + // null fields, will most likely have NULL as default value + $default_value = (float)$default_value; + } } @@ -302,7 +327,7 @@ $grid_col_options['filter_block'] = 'grid_options_filter'; } - if ($field_info['Null'] != 'YES') { + if ($not_null) { $field_options['not_null'] = 1; } @@ -311,15 +336,15 @@ $id_field = $field_info['Field']; } - if ($php_type == 'int' && !array_key_exists('not_null', $field_options)) { + if ($php_type == 'int' && !$not_null) { // numeric null field if (preg_match('/(On|Date)$/', $field_info['Field']) || $field_info['Field'] == 'Modified') { $field_options['formatter'] = 'kDateFormatter'; $grid_col_options['filter_block'] = 'grid_date_rage_filter'; } } - if ($php_type == 'int' && ($field_info['Null'] != 'YES' || is_numeric($default_value))) { + if ($php_type == 'int' && ($not_null || is_numeric($default_value))) { // is integer field AND not null $field_options['default'] = (int)$default_value; }