Index: trunk/core/units/categories/categories_config.php =================================================================== diff -u -r1566 -r2011 --- trunk/core/units/categories/categories_config.php (.../categories_config.php) (revision 1566) +++ trunk/core/units/categories/categories_config.php (.../categories_config.php) (revision 2011) @@ -62,7 +62,7 @@ 'ParentId' => Array('type' => 'int','not_null' => '1','default' => '0'), 'Name' => Array('type' => 'string','not_null' => '1','default' => ''), 'Description' => Array('type' => 'string','not_null' => '1','default' => ''), - 'CreatedOn' => Array('formatter' => 'kDateFormatter', 'default'=>mktime(), 'not_null' => '1'), + 'CreatedOn' => Array('formatter' => 'kDateFormatter', 'default'=>'#NOW#', 'not_null' => '1'), 'EditorsPick' => Array('type' => 'int','default' => ''), 'Status' => Array('type' => 'int','not_null' => '1','default' => '0'), 'Pop' => Array('type' => 'int','default' => ''), Index: trunk/core/kernel/db/db_event_handler.php =================================================================== diff -u -r1906 -r2011 --- trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 1906) +++ trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 2011) @@ -203,6 +203,7 @@ function dbBuild(&$object,&$event) { $object->Configure(); + $this->PrepareObject($event); $live_table = $event->getEventParam('live_table'); @@ -222,6 +223,17 @@ } /** + * Apply custom object modifications + * after it's initialization + * + * @param kEvent $event + */ + function PrepareObject(&$event) + { + + } + + /** * Builds item (loads if needed) * * @param kEvent $event Index: trunk/kernel/units/categories/categories_config.php =================================================================== diff -u -r1566 -r2011 --- trunk/kernel/units/categories/categories_config.php (.../categories_config.php) (revision 1566) +++ trunk/kernel/units/categories/categories_config.php (.../categories_config.php) (revision 2011) @@ -62,7 +62,7 @@ 'ParentId' => Array('type' => 'int','not_null' => '1','default' => '0'), 'Name' => Array('type' => 'string','not_null' => '1','default' => ''), 'Description' => Array('type' => 'string','not_null' => '1','default' => ''), - 'CreatedOn' => Array('formatter' => 'kDateFormatter', 'default'=>mktime(), 'not_null' => '1'), + 'CreatedOn' => Array('formatter' => 'kDateFormatter', 'default'=>'#NOW#', 'not_null' => '1'), 'EditorsPick' => Array('type' => 'int','default' => ''), 'Status' => Array('type' => 'int','not_null' => '1','default' => '0'), 'Pop' => Array('type' => 'int','default' => ''), Index: trunk/core/kernel/kbase.php =================================================================== diff -u -r1560 -r2011 --- trunk/core/kernel/kbase.php (.../kbase.php) (revision 1560) +++ trunk/core/kernel/kbase.php (.../kbase.php) (revision 2011) @@ -259,6 +259,17 @@ } /** + * Adds calculated field declaration to object. + * + * @param string $name + * @param string $sql_clause + */ + function addCalculatedField($name, $sql_clause) + { + $this->CalculatedFields[$name] = $sql_clause; + } + + /** * Sets ID Field name used as primary key for loading items * * @access public @@ -316,7 +327,13 @@ function SetDefaultValues() { - + foreach($this->Fields as $field => $options) + { + if($options['default'] == '#NOW#') + { + $this->Fields[$field]['default'] = mktime(); + } + } } function SetFieldOptions($field, $options) @@ -381,7 +398,7 @@ $options_hash = getArrayValue($field_options,'options'); if($options_hash === false) $options_hash = Array(); - + $dynamic_options = $this->Conn->GetCol($sql, $field_options['option_key_field']); $field_options['options'] = array_merge_recursive2($options_hash, $dynamic_options);