Index: trunk/admin/relation_select.php
===================================================================
diff -u -N -r3184 -r4309
--- trunk/admin/relation_select.php (.../relation_select.php) (revision 3184)
+++ trunk/admin/relation_select.php (.../relation_select.php) (revision 4309)
@@ -33,6 +33,9 @@
$application->Init();
$application->ProcessRequest();
+$main_processor =& $application->recallTagProcessor('m');
+$main_processor->StoreMainPrefix(Array());
+
if( $application->GetVar('CatId') ) $application->SetVar('m_cat_id', $application->GetVar('CatId') );
//KERNEL4 END
Index: trunk/core/units/relationship/relationship_config.php
===================================================================
diff -u -N -r4303 -r4309
--- trunk/core/units/relationship/relationship_config.php (.../relationship_config.php) (revision 4303)
+++ trunk/core/units/relationship/relationship_config.php (.../relationship_config.php) (revision 4309)
@@ -2,6 +2,15 @@
$config = Array(
'Prefix' => 'rel',
+
+ 'Clones' => Array(
+
+ 'l-rel' => Array('ParentPrefix' => 'l'),
+ 'n-rel' => Array('ParentPrefix' => 'n'),
+ 'bb-rel'=> Array('ParentPrefix' => 'bb'),
+ /*'p-rel' => Array('ParentPrefix' => 'p'),*/
+ ),
+
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'RelationshipEventHandler','file'=>'relationship_event_handler.php','build_event'=>'OnBuild'),
@@ -11,8 +20,8 @@
Array(
'Mode' => hAFTER,
'Conditional' => false,
- 'HookToPrefix' => 'p',
- 'HookToSpecial' => '-item',
+ 'HookToPrefix' => '#PARENT#',
+ 'HookToSpecial' => '*',
'HookToEvent' => Array('OnAfterItemDelete'),
'DoPrefix' => '',
'DoSpecial' => '',
Index: trunk/kernel/units/relationship/relationship_config.php
===================================================================
diff -u -N -r4303 -r4309
--- trunk/kernel/units/relationship/relationship_config.php (.../relationship_config.php) (revision 4303)
+++ trunk/kernel/units/relationship/relationship_config.php (.../relationship_config.php) (revision 4309)
@@ -2,6 +2,15 @@
$config = Array(
'Prefix' => 'rel',
+
+ 'Clones' => Array(
+
+ 'l-rel' => Array('ParentPrefix' => 'l'),
+ 'n-rel' => Array('ParentPrefix' => 'n'),
+ 'bb-rel'=> Array('ParentPrefix' => 'bb'),
+ /*'p-rel' => Array('ParentPrefix' => 'p'),*/
+ ),
+
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'RelationshipEventHandler','file'=>'relationship_event_handler.php','build_event'=>'OnBuild'),
@@ -11,8 +20,8 @@
Array(
'Mode' => hAFTER,
'Conditional' => false,
- 'HookToPrefix' => 'p',
- 'HookToSpecial' => '-item',
+ 'HookToPrefix' => '#PARENT#',
+ 'HookToSpecial' => '*',
'HookToEvent' => Array('OnAfterItemDelete'),
'DoPrefix' => '',
'DoSpecial' => '',
Index: trunk/core/units/reviews/reviews_config.php
===================================================================
diff -u -N -r4303 -r4309
--- trunk/core/units/reviews/reviews_config.php (.../reviews_config.php) (revision 4303)
+++ trunk/core/units/reviews/reviews_config.php (.../reviews_config.php) (revision 4309)
@@ -8,7 +8,7 @@
'l-rev' => Array('ParentPrefix' => 'l'),
'n-rev' => Array('ParentPrefix' => 'n'),
'bb-rev'=> Array('ParentPrefix' => 'bb'),
- 'p-rev' => Array('ParentPrefix' => 'p'),
+ /*'p-rev' => Array('ParentPrefix' => 'p'),*/
),
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
@@ -33,7 +33,7 @@
'ForeignKey' => 'ItemId', // linked field in subtable
'AutoDelete' => true,
- 'AutoClone' => true,
+ 'AutoClone' => true,
'TitlePresets' => Array(
'reviews_edit' => Array('format' => "!la_title_Editing_Review!"),
Index: trunk/kernel/units/reviews/reviews_config.php
===================================================================
diff -u -N -r4303 -r4309
--- trunk/kernel/units/reviews/reviews_config.php (.../reviews_config.php) (revision 4303)
+++ trunk/kernel/units/reviews/reviews_config.php (.../reviews_config.php) (revision 4309)
@@ -8,7 +8,7 @@
'l-rev' => Array('ParentPrefix' => 'l'),
'n-rev' => Array('ParentPrefix' => 'n'),
'bb-rev'=> Array('ParentPrefix' => 'bb'),
- 'p-rev' => Array('ParentPrefix' => 'p'),
+ /*'p-rev' => Array('ParentPrefix' => 'p'),*/
),
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
@@ -33,7 +33,7 @@
'ForeignKey' => 'ItemId', // linked field in subtable
'AutoDelete' => true,
- 'AutoClone' => true,
+ 'AutoClone' => true,
'TitlePresets' => Array(
'reviews_edit' => Array('format' => "!la_title_Editing_Review!"),
Index: trunk/kernel/units/general/cat_event_handler.php
===================================================================
diff -u -N -r4287 -r4309
--- trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 4287)
+++ trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 4309)
@@ -1702,25 +1702,6 @@
/* === RELATED TO IMPORT/EXPORT: END === */
- /**
- * Saves selected user in needed field
- *
- * @param kEvent $event
- */
- function OnSelectUser(&$event)
- {
- $items_info = $this->Application->GetVar('u');
- if ($items_info) {
- $user_id = array_shift( array_keys($items_info) );
-
- $object =& $event->getObject();
- $object->SetDBField($this->Application->RecallVar('dst_field'), $user_id);
- $object->Update();
- }
-
- $this->finalizePopup($event);
- }
-
}
?>
\ No newline at end of file
Index: trunk/kernel/units/relationship/relationship_event_handler.php
===================================================================
diff -u -N -r4303 -r4309
--- trunk/kernel/units/relationship/relationship_event_handler.php (.../relationship_event_handler.php) (revision 4303)
+++ trunk/kernel/units/relationship/relationship_event_handler.php (.../relationship_event_handler.php) (revision 4309)
@@ -31,8 +31,13 @@
if($config_data['ItemType'] == $target['type']) break;
}
- $db =& $this->Application->GetADODBConnection();
- $item['name'] = $db->GetOne('SELECT '.$config_data['TitleField'].' FROM '.$config_data['TableName'].' WHERE ResourceId = '.$target['id']);
+ // this forces prepareOptions of kMultiLanguge formatter to substiture title field (if multilingual) of target item
+ // BUT this is not the solution, find out another way to get correct title field here
+
+ $target_object =& $this->Application->recallObject($prefix, null, Array('skip_autoload' => true));
+ $title_field = $this->Application->getUnitOption($prefix, 'TitleField');
+
+ $item['name'] = $this->Conn->GetOne('SELECT '.$title_field.' FROM '.$config_data['TableName'].' WHERE ResourceId = '.$target['id']);
$item['type'] = $this->Application->Phrase($config_data['TitlePhrase']);
$object->SetDBField('ItemName', $item['name']);
$object->SetDBField('ItemType', $item['type']);
@@ -46,7 +51,8 @@
$opener_stack = $opener_stack ? unserialize($opener_stack) : Array();
array_pop($opener_stack);
- $new_level = 'index4.php|'.ltrim($this->Application->BuildEnv('in-commerce/products/products_relations',Array('m_opener'=>'u'),'all'),ENV_VAR_NAME.'=');
+ $return_template = $this->Application->RecallVar('return_template');
+ $new_level = 'index4.php|'.ltrim($this->Application->BuildEnv($return_template, Array('m_opener'=>'u'),'all'),ENV_VAR_NAME.'=');
array_push($opener_stack,$new_level);
$this->Application->StoreVar('opener_stack',serialize($opener_stack));
Index: trunk/kernel/units/reviews/reviews_tag_processor.php
===================================================================
diff -u -N -r4303 -r4309
--- trunk/kernel/units/reviews/reviews_tag_processor.php (.../reviews_tag_processor.php) (revision 4303)
+++ trunk/kernel/units/reviews/reviews_tag_processor.php (.../reviews_tag_processor.php) (revision 4309)
@@ -19,11 +19,12 @@
$item_id = $object->GetDBField($id_field);
return $this->Application->HREF($params['edit_template'],'', Array(
- 'm_opener'=>'d',
- $item_prefix.'_event'=>'OnEdit',
- $item_prefix.'_id'=>$item_id,
- 'pass'=>'all,'.$item_prefix
- ),'index4.php' );
+ 'm_opener' => 'd',
+ $item_prefix.'_mode' => 't',
+ $item_prefix.'_event' => 'OnEdit',
+ $item_prefix.'_id' => $item_id,
+ 'pass' => 'all,'.$item_prefix
+ ), 'index4.php');
}
/**
@@ -38,14 +39,11 @@
$field = $this->SelectParam($params, 'name,field');
$object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params);
- if($field == 'ReviewText')
- {
- if( $object->GetDBField('TextFormat') == 1 )
- {
+ if ($field == 'ReviewText') {
+ if ($object->GetDBField('TextFormat') == 1) {
$params['no_special'] = 'no_special';
}
- else
- {
+ else {
unset($params['no_special']);
}
}
@@ -87,12 +85,10 @@
function HasError($params)
{
$object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params);
- if(method_exists($object, 'GetErrorMsg'))
- {
+ if (method_exists($object, 'GetErrorMsg')) {
return parent::HasError($params);
}
- else
- {
+ else {
return 0;
}
}
Index: trunk/core/units/general/cat_event_handler.php
===================================================================
diff -u -N -r4287 -r4309
--- trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 4287)
+++ trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 4309)
@@ -1702,25 +1702,6 @@
/* === RELATED TO IMPORT/EXPORT: END === */
- /**
- * Saves selected user in needed field
- *
- * @param kEvent $event
- */
- function OnSelectUser(&$event)
- {
- $items_info = $this->Application->GetVar('u');
- if ($items_info) {
- $user_id = array_shift( array_keys($items_info) );
-
- $object =& $event->getObject();
- $object->SetDBField($this->Application->RecallVar('dst_field'), $user_id);
- $object->Update();
- }
-
- $this->finalizePopup($event);
- }
-
}
?>
\ No newline at end of file
Index: trunk/core/units/relationship/relationship_event_handler.php
===================================================================
diff -u -N -r4303 -r4309
--- trunk/core/units/relationship/relationship_event_handler.php (.../relationship_event_handler.php) (revision 4303)
+++ trunk/core/units/relationship/relationship_event_handler.php (.../relationship_event_handler.php) (revision 4309)
@@ -31,8 +31,13 @@
if($config_data['ItemType'] == $target['type']) break;
}
- $db =& $this->Application->GetADODBConnection();
- $item['name'] = $db->GetOne('SELECT '.$config_data['TitleField'].' FROM '.$config_data['TableName'].' WHERE ResourceId = '.$target['id']);
+ // this forces prepareOptions of kMultiLanguge formatter to substiture title field (if multilingual) of target item
+ // BUT this is not the solution, find out another way to get correct title field here
+
+ $target_object =& $this->Application->recallObject($prefix, null, Array('skip_autoload' => true));
+ $title_field = $this->Application->getUnitOption($prefix, 'TitleField');
+
+ $item['name'] = $this->Conn->GetOne('SELECT '.$title_field.' FROM '.$config_data['TableName'].' WHERE ResourceId = '.$target['id']);
$item['type'] = $this->Application->Phrase($config_data['TitlePhrase']);
$object->SetDBField('ItemName', $item['name']);
$object->SetDBField('ItemType', $item['type']);
@@ -46,7 +51,8 @@
$opener_stack = $opener_stack ? unserialize($opener_stack) : Array();
array_pop($opener_stack);
- $new_level = 'index4.php|'.ltrim($this->Application->BuildEnv('in-commerce/products/products_relations',Array('m_opener'=>'u'),'all'),ENV_VAR_NAME.'=');
+ $return_template = $this->Application->RecallVar('return_template');
+ $new_level = 'index4.php|'.ltrim($this->Application->BuildEnv($return_template, Array('m_opener'=>'u'),'all'),ENV_VAR_NAME.'=');
array_push($opener_stack,$new_level);
$this->Application->StoreVar('opener_stack',serialize($opener_stack));
Index: trunk/core/units/reviews/reviews_tag_processor.php
===================================================================
diff -u -N -r4303 -r4309
--- trunk/core/units/reviews/reviews_tag_processor.php (.../reviews_tag_processor.php) (revision 4303)
+++ trunk/core/units/reviews/reviews_tag_processor.php (.../reviews_tag_processor.php) (revision 4309)
@@ -19,11 +19,12 @@
$item_id = $object->GetDBField($id_field);
return $this->Application->HREF($params['edit_template'],'', Array(
- 'm_opener'=>'d',
- $item_prefix.'_event'=>'OnEdit',
- $item_prefix.'_id'=>$item_id,
- 'pass'=>'all,'.$item_prefix
- ),'index4.php' );
+ 'm_opener' => 'd',
+ $item_prefix.'_mode' => 't',
+ $item_prefix.'_event' => 'OnEdit',
+ $item_prefix.'_id' => $item_id,
+ 'pass' => 'all,'.$item_prefix
+ ), 'index4.php');
}
/**
@@ -38,14 +39,11 @@
$field = $this->SelectParam($params, 'name,field');
$object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params);
- if($field == 'ReviewText')
- {
- if( $object->GetDBField('TextFormat') == 1 )
- {
+ if ($field == 'ReviewText') {
+ if ($object->GetDBField('TextFormat') == 1) {
$params['no_special'] = 'no_special';
}
- else
- {
+ else {
unset($params['no_special']);
}
}
@@ -87,12 +85,10 @@
function HasError($params)
{
$object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params);
- if(method_exists($object, 'GetErrorMsg'))
- {
+ if (method_exists($object, 'GetErrorMsg')) {
return parent::HasError($params);
}
- else
- {
+ else {
return 0;
}
}
Index: trunk/core/kernel/utility/debugger.php
===================================================================
diff -u -N -r3858 -r4309
--- trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 3858)
+++ trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 4309)
@@ -975,12 +975,10 @@
if( dbg_ConstOn('DBG_IGNORE_STRICT_ERRORS') && defined('E_STRICT') && ($errno == E_STRICT) ) return;
- $long_id_pos=strrpos($errstr,'#');
- if($long_id_pos!==false)
- {
+ if (preg_match('/(.*)#([\d]+)$/', $errstr, $rets) ) {
// replace short message with long one (due triger_error limitations on message size)
- $long_id=substr($errstr,$long_id_pos+1,strlen($errstr));
- $errstr=$this->longErrors[$long_id];
+ $long_id = $rets[2];
+ $errstr = $this->longErrors[$long_id];
unset($this->longErrors[$long_id]);
}
Index: trunk/core/kernel/db/db_event_handler.php
===================================================================
diff -u -N -r4287 -r4309
--- trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 4287)
+++ trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 4309)
@@ -817,6 +817,25 @@
*/
function OnCancel(&$event)
{
+ $object =& $event->getObject(Array('skip_autoload' => true));
+
+ $items_info = $this->Application->GetVar($event->getPrefixSpecial(true));
+ if ($items_info) {
+ $delete_ids = Array();
+ $temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
+ foreach ($items_info as $id => $field_values) {
+ $object->Load($id);
+ // record created for using with selector (e.g. Reviews->Select User), and not validated => Delete it
+ if ($object->isLoaded() && !$object->Validate()) {
+ $delete_ids[] = $id;
+ }
+ }
+
+ if ($delete_ids) {
+ $temp->DeleteItems($event->Prefix, $event->Special, $delete_ids);
+ }
+ }
+
$event->redirect_params = Array('opener'=>'u');
}
@@ -1297,8 +1316,10 @@
}
$pass_events = $event->getEventParam('pass_events');
- $new_level = 'index4.php|'.ltrim($this->Application->BuildEnv($t, Array('m_opener' => 'u'), 'all', $pass_events), ENV_VAR_NAME.'=');
- array_push($opener_stack,$new_level);
+ $redirect_params = array_merge_recursive2($event->redirect_params, Array('m_opener' => 'u', '__URLENCODE__' => 1));
+
+ $new_level = 'index4.php|'.ltrim($this->Application->BuildEnv($t, $redirect_params, 'all', $pass_events), ENV_VAR_NAME.'=');
+ array_push($opener_stack, $new_level);
$this->Application->StoreVar('opener_stack',serialize($opener_stack));
}
@@ -1619,6 +1640,42 @@
$this->Application->setUnitOption($main_prefix.'.', 'CalculatedFields', $calculated_fields);
$this->Application->setUnitOption($main_prefix, 'VirtualFields', $virtual_fields);
}
+
+ /**
+ * Saves selected user in needed field
+ *
+ * @param kEvent $event
+ */
+ function OnSelectUser(&$event)
+ {
+ $items_info = $this->Application->GetVar('u');
+ if ($items_info) {
+ $user_id = array_shift( array_keys($items_info) );
+
+ $object =& $event->getObject();
+ $this->RemoveRequiredFields($object);
+
+ $is_new = !$object->isLoaded();
+
+ if ($is_new) {
+ $new_event = $this->Application->GetVar($event->Prefix.'_mode' == 't') ? 'OnPreCreate' : 'OnNew';
+ $event->CallSubEvent($new_event);
+ }
+
+ $object->SetDBField($this->Application->RecallVar('dst_field'), $user_id);
+
+ if ($is_new) {
+ $object->Create();
+ if ($object->IsTempTable()) $object->setTempID();
+ }
+ else {
+ $object->Update();
+ }
+ }
+
+ $event->SetRedirectParam($event->getPrefixSpecial().'_id', $object->GetID());
+ $this->finalizePopup($event);
+ }
}
Index: trunk/core/kernel/utility/unit_config_reader.php
===================================================================
diff -u -N -r4016 -r4309
--- trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 4016)
+++ trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 4309)
@@ -326,8 +326,22 @@
}
}
- if ( is_array(getArrayValue($config, 'Hooks')) ) {
- foreach ($config['Hooks'] as $hook) {
+ $hooks = getArrayValue($config, 'Hooks');
+ if (is_array($hooks) && count($hooks) > 0) {
+ foreach ($hooks as $hook) {
+ if (isset($config['ParentPrefix']) && $hook['HookToPrefix'] == $config['ParentPrefix']) {
+ trigger_error('Depricated Hook Usage [prefix: '.$config['Prefix'].'; do_prefix: '.$hook['DoPrefix'].'] use #PARENT# and HookToPrefix value where HookToPrefix is same as ParentPrefix', E_USER_NOTICE);
+ }
+
+ if ($hook['HookToPrefix'] == '') {
+ $hook['HookToPrefix'] = $config['Prefix']; // new: set hooktoprefix to current prefix if not set
+ }
+
+ if (isset($config['ParentPrefix']) && $hook['HookToPrefix'] == '#PARENT#') {
+ // new: allow to set hook to parent prefix what ever it is
+ $hook['HookToPrefix'] = $config['ParentPrefix'];
+ }
+
$do_prefix = $hook['DoPrefix'] == '' ? $config['Prefix'] : $hook['DoPrefix'];
if ( !is_array($hook['HookToEvent']) ) {
Index: trunk/core/units/config_search/config_search_config.php
===================================================================
diff -u -N -r4043 -r4309
--- trunk/core/units/config_search/config_search_config.php (.../config_search_config.php) (revision 4043)
+++ trunk/core/units/config_search/config_search_config.php (.../config_search_config.php) (revision 4309)
@@ -16,10 +16,10 @@
Array(
'Mode' => hAFTER,
'Conditional' => false,
- 'HookToPrefix' => 'cf',
+ 'HookToPrefix' => '#PARENT#',
'HookToSpecial' => '*',
'HookToEvent' => Array('OnAfterItemCreate', 'OnAfterItemUpdate'),
- 'DoPrefix' => 'confs-cf',
+ 'DoPrefix' => '',
'DoSpecial' => '*',
'DoEvent' => 'OnCreateCustomField',
),
Index: trunk/kernel/admin_templates/incs/form_blocks.tpl
===================================================================
diff -u -N -r4287 -r4309
--- trunk/kernel/admin_templates/incs/form_blocks.tpl (.../form_blocks.tpl) (revision 4287)
+++ trunk/kernel/admin_templates/incs/form_blocks.tpl (.../form_blocks.tpl) (revision 4309)
@@ -176,7 +176,7 @@