Index: trunk/kernel/units/config_search/config_search_config.php =================================================================== diff -u -N -r1682 -r3999 --- trunk/kernel/units/config_search/config_search_config.php (.../config_search_config.php) (revision 1682) +++ trunk/kernel/units/config_search/config_search_config.php (.../config_search_config.php) (revision 3999) @@ -2,6 +2,31 @@ $config = Array( 'Prefix' => 'confs', + + 'Clones' => Array( + 'confs-cf' => Array( + 'Prefix' => 'confs-cf', + 'ParentPrefix' => 'cf', + 'ParentTableKey' => 'CustomFieldId', // linked field in master table + 'ForeignKey' => 'CustomFieldId', // linked field in subtable + 'AutoClone' => false, // because OnCreateCustomField hook does the stuff + 'AutoDelete' => true, + + 'Hooks' => Array( + Array( + 'Mode' => hAFTER, + 'Conditional' => false, + 'HookToPrefix' => 'cf', + 'HookToSpecial' => '*', + 'HookToEvent' => Array('OnAfterItemCreate', 'OnAfterItemUpdate'), + 'DoPrefix' => 'confs-cf', + 'DoSpecial' => '*', + 'DoEvent' => 'OnCreateCustomField', + ), + ), + ), + ), + 'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'), 'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'), 'EventHandlerClass' => Array('class'=>'ConfigSearchEventHandler','file'=>'config_search_event_handler.php','build_event'=>'OnBuild'), @@ -15,29 +40,6 @@ 4 => 'module', 5 => 'section', ), - - 'Hooks' => Array( - Array( - 'Mode' => hAFTER, - 'Conditional' => false, - 'HookToPrefix' => 'cf', - 'HookToSpecial' => '', - 'HookToEvent' => Array( 'OnSave' ), - 'DoPrefix' => 'confs', - 'DoSpecial' => '', - 'DoEvent' => 'OnCreateCustomField', - ), - Array( - 'Mode' => hAFTER, - 'Conditional' => false, - 'HookToPrefix' => 'cf', - 'HookToSpecial' => '-item', - 'HookToEvent' => Array( 'OnAfterItemDelete' ), - 'DoPrefix' => 'confs', - 'DoSpecial' => '', - 'DoEvent' => 'OnDeleteCustomField', - ), - ), 'IDField' => 'SearchConfigId', @@ -47,12 +49,18 @@ 'TableName' => TABLE_PREFIX.'SearchConfig', - 'ListSQLs' => Array(''=>'SELECT *, IF('.TABLE_PREFIX.'SearchConfig.CustomFieldId=0, 0, 1) AS IsCustom FROM '.TABLE_PREFIX.'SearchConfig'), + 'CalculatedFields' => Array( + '' => Array( + 'IsCustom' => 'IF(CustomFieldId IS NULL, 0, 1)', + ), + ), - 'ItemSQLs' => Array(''=>'SELECT * FROM '.TABLE_PREFIX.'SearchConfig'), + 'ListSQLs' => Array('' => 'SELECT %1$s.* %2$s FROM %1$s'), + + 'ItemSQLs' => Array('' => 'SELECT %1$s.* %2$s FROM %1$s'), - 'SubTables' => Array(), + 'Fields' => Array( 'TableName' => Array('type' => 'string','not_null' => '1','default' => ''), 'FieldName' => Array('type' => 'string','not_null' => '1','default' => ''), @@ -72,10 +80,12 @@ 'IsNotWhere' => Array('type' => 'string','default' => ''), 'ContainsWhere' => Array('type' => 'string','default' => ''), 'NotContainsWhere' => Array('type' => 'string','default' => ''), - 'CustomFieldId' => Array('type' => 'int','not_null' => '1','default' => '0'), + 'CustomFieldId' => Array('type' => 'int', 'default' => ''), ), - 'VirtualFields' => Array(), + 'VirtualFields' => Array( + 'IsCustom' => Array('type' => 'int', 'default' => 0), + ), 'ListSortings' => Array( '' => Array(