Index: branches/RC/core/kernel/event_manager.php =================================================================== diff -u -N -r11538 -r11665 --- branches/RC/core/kernel/event_manager.php (.../event_manager.php) (revision 11538) +++ branches/RC/core/kernel/event_manager.php (.../event_manager.php) (revision 11665) @@ -469,12 +469,33 @@ $last_template = '../'.$last_template; } else { - $last_template = $this->Application->RecallVar(rtrim('last_template_popup_'.$parent_wid, '_')); + if ($this->Application->GetVar('merge_opener_stack')) { + // get last template from parent (that was closed) window opener stack + $parent_opener_stack_name = rtrim('opener_stack_' . $parent_wid, '_'); + $parent_opener_stack = unserialize( $this->Application->RecallVar($parent_opener_stack_name) ); + $last_template = array_pop($parent_opener_stack); + + if ($parent_opener_stack) { + $this->Application->StoreVar($parent_opener_stack_name, serialize($parent_opener_stack)); + } + else { + $this->Application->RemoveVar($parent_opener_stack_name); + } + } + else { + $last_template = $this->Application->RecallVar(rtrim('last_template_popup_'.$parent_wid, '_')); + } } $opener_stack = Array ( $last_template ); $this->Application->SetVar('m_opener', 's'); $wid = $popup_wid; + + /*// store window relations + $window_relations = $this->Application->RecallVar('window_relations'); + $window_relations = $window_relations ? unserialize($window_relations) : Array (); + $window_relations[$popup_wid] = $parent_wid; + $this->Application->StoreVar('window_relations', serialize($window_relations));*/ break; default: // "s/0," stay on same deep level @@ -489,21 +510,31 @@ /** * Used from relationship event handler * - * @param string $t + * @param string $template * @param Array $params * @param string $pass */ - function openerStackPush($t, $params, $pass = 'all', $wid=null) + function openerStackPush($template, $params, $pass = 'all', $wid = null) { - if (!isset($wid)) $wid = $this->Application->GetVar('m_wid'); - $stack_name = rtrim('opener_stack_'.$wid, '_'); + if (!isset($wid)) { + $wid = $this->Application->GetVar('m_wid'); + } + /*// get parent window wid, when this was popup + $window_relations = $this->Application->RecallVar('window_relations'); + $window_relations = $window_relations ? unserialize($window_relations) : Array (); + $wid = array_key_exists($wid, $window_relations) ? $window_relations[$wid] : false;*/ + + // get opener stack + $stack_name = rtrim('opener_stack_' . $wid, '_'); $opener_stack = $this->Application->RecallVar($stack_name); - $opener_stack = $opener_stack ? unserialize($opener_stack) : Array(); + $opener_stack = $opener_stack ? unserialize($opener_stack) : Array (); - $redirect_params = array_merge_recursive2(Array('m_opener' => 'u', '__URLENCODE__' => 1), $params); - $new_level = $this->Application->BuildEnv($t, $redirect_params, $pass, true); - array_push($opener_stack, 'index.php|'.ltrim($new_level, ENV_VAR_NAME.'=') ); + // change opener stack + $default_params = Array ('m_opener' => 'u', '__URLENCODE__' => 1); + $redirect_params = array_merge_recursive2($default_params, $params); + $new_level = $this->Application->BuildEnv($template, $redirect_params, $pass, true); + array_push($opener_stack, 'index.php|' . ltrim($new_level, ENV_VAR_NAME . '=') ); $this->Application->StoreVar($stack_name, serialize($opener_stack)); }