Index: branches/unlabeled/unlabeled-1.79.4/core/kernel/db/db_event_handler.php =================================================================== diff -u -r6849 -r6862 --- branches/unlabeled/unlabeled-1.79.4/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 6849) +++ branches/unlabeled/unlabeled-1.79.4/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 6862) @@ -1514,8 +1514,9 @@ */ function finalizePopup(&$event) { - $event->redirect = 'incs/close_popup'; - + $event->SetRedirectParam('opener', 'u'); + return ; + // 2. substitute opener $opener_stack = $this->Application->RecallVar('opener_stack'); $opener_stack = $opener_stack ? unserialize($opener_stack) : Array(); Index: branches/unlabeled/unlabeled-1.52.4/core/kernel/session/session.php =================================================================== diff -u -r6852 -r6862 --- branches/unlabeled/unlabeled-1.52.4/core/kernel/session/session.php (.../session.php) (revision 6852) +++ branches/unlabeled/unlabeled-1.52.4/core/kernel/session/session.php (.../session.php) (revision 6862) @@ -766,14 +766,28 @@ function SaveLastTemplate($t) { - $last_env = $this->Application->BuildEnv($t, Array('m_opener' => 'u', '__URLENCODE__' => 1), 'all'); + // save last_template + $wid = $this->Application->GetVar('m_wid'); + + $last_env = $this->getLastTemplateENV($t, Array('m_opener' => 'u')); $last_template = basename($_SERVER['PHP_SELF']).'|'.substr($last_env, strlen(ENV_VAR_NAME) + 1); - $this->StoreVar('last_template', $last_template); + $this->StoreVar(rtrim('last_template_'.$wid, '_'), $last_template); + + $last_env = $this->getLastTemplateENV($t, Array()); + $last_template = basename($_SERVER['PHP_SELF']).'|'.substr($last_env, strlen(ENV_VAR_NAME) + 1); + $this->StoreVar(rtrim('last_template_popup_'.$wid, '_'), $last_template); + + // save other last... variables for mistical purposes (customizations may be) $this->StoreVar('last_url', $_SERVER['REQUEST_URI']); - - $this->StoreVar('last_env', substr($this->Application->BuildEnv($t, Array('__URLENCODE__' => 1), 'all'), strlen(ENV_VAR_NAME)+1)); + $this->StoreVar('last_env', substr($last_env, strlen(ENV_VAR_NAME)+1)); } + function getLastTemplateENV($t, $params) + { + $params['__URLENCODE__'] = 1; + return $this->Application->BuildEnv($t, $params, 'all'); + } + function StoreVar($name, $value) { $this->Data->Set($name, $value); Index: branches/unlabeled/unlabeled-1.166.4/core/kernel/application.php =================================================================== diff -u -r6849 -r6862 --- branches/unlabeled/unlabeled-1.166.4/core/kernel/application.php (.../application.php) (revision 6849) +++ branches/unlabeled/unlabeled-1.166.4/core/kernel/application.php (.../application.php) (revision 6862) @@ -1036,15 +1036,15 @@ { if(!$t) $t = $this->GetVar('t'); // moved from kMainTagProcessor->T() - if ($this->GetVar('skip_last_template')) { + /*if ($this->GetVar('skip_last_template')) { $params['opener'] = 'p'; $this->SetVar('m_opener', 'p'); } if ($t == 'incs/close_popup') { // because this template closes the popup and we don't need popup mark here anymore $params['m_opener'] = 's'; - } + }*/ if( substr($t, -4) == '.tpl' ) $t = substr($t, 0, strlen($t) - 4 ); @@ -1074,19 +1074,15 @@ } if (getArrayValue($params, 'opener') == 'u') { - $opener_stack=$this->RecallVar('opener_stack'); - if($opener_stack) { - $opener_stack=unserialize($opener_stack); - if (count($opener_stack) > 0) { - list($index_file, $env) = explode('|', $opener_stack[count($opener_stack)-1]); - $ret = $this->BaseURL($prefix, $ssl).$index_file.'?'.ENV_VAR_NAME.'='.$env; - if( getArrayValue($params,'escape') ) $ret = addslashes($ret); - return $ret; - } - else { - //define('DBG_REDIRECT', 1); - $t = $this->GetVar('t'); - } + $wid = $this->Application->GetVar('m_wid'); + $opener_stack = $this->RecallVar(rtrim('opener_stack_'.$wid, '_')); + + if ($opener_stack && $opener_stack != serialize(Array())) { + $opener_stack = unserialize($opener_stack); + list($index_file, $env) = explode('|', $opener_stack[count($opener_stack) - 1]); + $ret = $this->BaseURL($prefix, $ssl).$index_file.'?'.ENV_VAR_NAME.'='.$env; + if ( getArrayValue($params,'escape') ) $ret = addslashes($ret); + return $ret; } else { //define('DBG_REDIRECT', 1); Index: branches/unlabeled/unlabeled-1.10.2/core/units/general/general_config.php =================================================================== diff -u -r6670 -r6862 --- branches/unlabeled/unlabeled-1.10.2/core/units/general/general_config.php (.../general_config.php) (revision 6670) +++ branches/unlabeled/unlabeled-1.10.2/core/units/general/general_config.php (.../general_config.php) (revision 6862) @@ -11,6 +11,7 @@ 3 => 'lang', 4 => 'theme', 5 => 'opener', + 6 => 'wid', ), 'TitleField' => 'CachedNavbar', 'TitlePhrase' => 'la_Text_Category', Index: branches/unlabeled/unlabeled-1.39.8/core/kernel/event_manager.php =================================================================== diff -u -r6842 -r6862 --- branches/unlabeled/unlabeled-1.39.8/core/kernel/event_manager.php (.../event_manager.php) (revision 6842) +++ branches/unlabeled/unlabeled-1.39.8/core/kernel/event_manager.php (.../event_manager.php) (revision 6862) @@ -282,7 +282,8 @@ $event->redirect_params['m_cat_id'] = 0; // restore stuff, that processOpener() changed - $this->Application->RestoreVar('opener_stack'); + $wid = $this->Application->GetVar('m_wid'); + $this->Application->RestoreVar(rtrim('opener_stack_'.$wid, '_')); // don't save last_template, because no_permission template does js history.back and could cause invalid opener_stack content $this->Application->SetVar('skip_last_template', 1); } @@ -294,6 +295,13 @@ if ($event->redirect === true && !isset($event->redirect_params['pass_category']) && $this->Application->GetVar('m_cat_id')) { $event->redirect_params['pass_category'] = 1; } + + $wid = $this->Application->GetVar('m_wid'); + if ($wid && $event->redirect_params['opener'] == 'u') { + $event->redirect_params['opener'] = 's'; // because Application->HREF will react differently when 'opener' = 'u' + $event->redirect = 'incs/close_popup'; + } + $this->Application->Redirect($event->redirect, $event->redirect_params, null, $event->redirect_script); } } @@ -304,9 +312,12 @@ function processOpener() { - $opener_action = $this->Application->GetVar('m_opener'); - $opener_stack = $this->Application->RecallVar('opener_stack'); + $wid = $this->Application->GetVar('m_wid'); + + $opener_stack = $this->Application->RecallVar(rtrim('opener_stack_'.$wid, '_')); $opener_stack = $opener_stack ? unserialize($opener_stack) : Array(); + + $opener_action = $this->Application->GetVar('m_opener'); switch ($opener_action) { case 'r': // "reset" opener stack $opener_stack = Array(); @@ -327,17 +338,23 @@ break; case 'p': //pop-up - do not store last template - $this->Application->SetVar('skip_last_template', 1); + $parent_wid = $this->Application->GetVar('m_wid'); // window_id of popup's parent window + $popup_wid = (int)$this->Application->RecallVar('last_wid') + 1; + $this->Application->StoreVar('last_wid', $popup_wid); + $this->Application->SetVar('m_wid', $popup_wid); + $opener_stack = Array ( $this->Application->RecallVar(rtrim('last_template_popup_'.$parent_wid, '_')) ); + $this->Application->SetVar('m_opener', 's'); + $wid = $popup_wid; +// $this->Application->SetVar('skip_last_template', 1); break; default: // "s/0," stay on same deep level break; } - if (!$this->Application->GetVar('skip_last_template')) { - $this->Application->SetVar('m_opener', 's'); - } - $this->Application->StoreVar('opener_stack', serialize($opener_stack)); + + $this->Application->SetVar('m_opener', 's'); + $this->Application->StoreVar(rtrim('opener_stack_'.$wid, '_'), serialize($opener_stack)); } Index: branches/unlabeled/unlabeled-1.25.2/core/units/categories/categories_event_handler.php =================================================================== diff -u -r6842 -r6862 --- branches/unlabeled/unlabeled-1.25.2/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 6842) +++ branches/unlabeled/unlabeled-1.25.2/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 6862) @@ -345,9 +345,12 @@ parent::OnSave($event); if ($event->status == erSUCCESS && $this->Application->RecallVar('PermCache_UpdateRequired')) { // "catalog" should be in opener stack by now - $opener_stack = unserialize($this->Application->RecallVar('opener_stack')); + $wid = $this->Application->GetVar('m_wid'); + $stack_name = rtrim('opener_stack_'.$wid, '_'); + + $opener_stack = unserialize($this->Application->RecallVar($stack_name)); $opener_stack[0] = str_replace('catalog', 'categories/cache_updater', $opener_stack[0]); - $this->Application->StoreVar('opener_stack', serialize($opener_stack)); + $this->Application->StoreVar($stack_name, serialize($opener_stack)); $this->Application->RemoveVar('PermCache_UpdateRequired'); } }