Index: branches/unlabeled/unlabeled-1.1.2/kernel/admin_templates/advanced_view.tpl =================================================================== diff -u -r5787 -r5795 --- branches/unlabeled/unlabeled-1.1.2/kernel/admin_templates/advanced_view.tpl (.../advanced_view.tpl) (revision 5787) +++ branches/unlabeled/unlabeled-1.1.2/kernel/admin_templates/advanced_view.tpl (.../advanced_view.tpl) (revision 5795) @@ -66,8 +66,14 @@ function edit() { $form_name = $Catalog.queryTabRegistry('prefix', $Catalog.ActivePrefix, 'tab_id') + '_form'; + var $kf = document.getElementById($form_name); + var $prev_action = $kf.action; + $kf.action = ''; + set_hidden_field('remove_specials[' + $Catalog.ActivePrefix + ']', 1); std_edit_item($Catalog.ActivePrefix, $Catalog.queryTabRegistry('prefix', $Catalog.ActivePrefix, 'edit_template')); + + $kf.action = $prev_action; } Index: branches/unlabeled/unlabeled-1.28.2/kernel/units/categories/categories_tag_processor.php =================================================================== diff -u -r5787 -r5795 --- branches/unlabeled/unlabeled-1.28.2/kernel/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 5787) +++ branches/unlabeled/unlabeled-1.28.2/kernel/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 5795) @@ -309,7 +309,7 @@ $category_id = $this->Application->GetVar('m_cat_id'); list($index_file, $env) = explode('|', $this->Application->RecallVar('last_template'), 2); - $this->Application->SetVar(ENV_VAR_NAME, $env); + $this->Application->SetVar(ENV_VAR_NAME, str_replace('%5C', '\\', $env)); $this->Application->HttpQuery->processQueryString(); // update required fields Index: branches/unlabeled/unlabeled-1.58.2/core/kernel/utility/unit_config_reader.php =================================================================== diff -u -r5730 -r5795 --- branches/unlabeled/unlabeled-1.58.2/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 5730) +++ branches/unlabeled/unlabeled-1.58.2/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 5795) @@ -449,6 +449,11 @@ preg_match('/\/(.*)\//U', $filename, $rets); $config['ModuleFolder'] = $rets[1]; $config['BasePath'] = dirname(FULL_PATH.$filename); + if (isset($config['AdminTemplatePath'])) { + // append template base folder for admin templates path of this prefix + $module_templates = $rets[1] == 'kernel' ? '' : $rets[1].'/'; + $config['AdminTemplatePath'] = $module_templates.$config['AdminTemplatePath']; + } $this->configData[$prefix] = $config; $this->prefixFiles[$prefix] = $filename; return $prefix; Index: branches/unlabeled/unlabeled-1.28.2/core/units/categories/categories_tag_processor.php =================================================================== diff -u -r5787 -r5795 --- branches/unlabeled/unlabeled-1.28.2/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 5787) +++ branches/unlabeled/unlabeled-1.28.2/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 5795) @@ -309,7 +309,7 @@ $category_id = $this->Application->GetVar('m_cat_id'); list($index_file, $env) = explode('|', $this->Application->RecallVar('last_template'), 2); - $this->Application->SetVar(ENV_VAR_NAME, $env); + $this->Application->SetVar(ENV_VAR_NAME, str_replace('%5C', '\\', $env)); $this->Application->HttpQuery->processQueryString(); // update required fields Index: branches/unlabeled/unlabeled-1.37.2/core/kernel/event_manager.php =================================================================== diff -u -r5726 -r5795 --- branches/unlabeled/unlabeled-1.37.2/core/kernel/event_manager.php (.../event_manager.php) (revision 5726) +++ branches/unlabeled/unlabeled-1.37.2/core/kernel/event_manager.php (.../event_manager.php) (revision 5795) @@ -334,6 +334,18 @@ $this->Application->StoreVar('opener_stack', serialize($opener_stack)); } + + function openerStackPush($t, $params, $pass = 'all') + { + $opener_stack = $this->Application->RecallVar('opener_stack'); + $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.'=') ); + $this->Application->StoreVar('opener_stack', serialize($opener_stack)); + } + function registerHook($hookto_prefix, $hookto_special, $hookto_event, $mode, $do_prefix, $do_special, $do_event, $conditional) { if( !$this->Application->prefixRegistred($hookto_prefix) ) Index: branches/unlabeled/unlabeled-1.1.2/kernel/admin_templates/categories/relations_edit.tpl =================================================================== diff -u -r5417 -r5795 --- branches/unlabeled/unlabeled-1.1.2/kernel/admin_templates/categories/relations_edit.tpl (.../relations_edit.tpl) (revision 5417) +++ branches/unlabeled/unlabeled-1.1.2/kernel/admin_templates/categories/relations_edit.tpl (.../relations_edit.tpl) (revision 5795) @@ -45,32 +45,20 @@ + + - - - - "> - - - - - - - - - - - + + + + +
- "/> - () - -  
\ No newline at end of file Index: branches/unlabeled/unlabeled-1.155.2/core/kernel/application.php =================================================================== diff -u -r5779 -r5795 --- branches/unlabeled/unlabeled-1.155.2/core/kernel/application.php (.../application.php) (revision 5779) +++ branches/unlabeled/unlabeled-1.155.2/core/kernel/application.php (.../application.php) (revision 5795) @@ -1070,7 +1070,7 @@ } // append pass through variables to each link to be build - $params = array_merge_recursive2($this->getPassThroughVariables(), $params); + $params = array_merge_recursive2($this->getPassThroughVariables($params), $params); if ($this->RewriteURLs($ssl) && !$no_rewrite) { @@ -1091,12 +1091,18 @@ /** * Returns variables with values that should be passed throught with this link + variable list * - * @return unknown + * @param Array $params + * @return Array */ - function getPassThroughVariables() + function getPassThroughVariables(&$params) { static $cached_pass_through = null; - + + if (isset($params['no_pass_through']) && $params['no_pass_through']) { + unset($params['no_pass_through']); + return Array(); + } + // because pass through is not changed during script run, then we can cache it if (is_null($cached_pass_through)) { Index: branches/unlabeled/unlabeled-1.1.2/core/admin_templates/categories/relations_edit.tpl =================================================================== diff -u -r5417 -r5795 --- branches/unlabeled/unlabeled-1.1.2/core/admin_templates/categories/relations_edit.tpl (.../relations_edit.tpl) (revision 5417) +++ branches/unlabeled/unlabeled-1.1.2/core/admin_templates/categories/relations_edit.tpl (.../relations_edit.tpl) (revision 5795) @@ -45,32 +45,20 @@ + + - - - - "> - - - - - - - - - - - + + + + +
- "/> - () - -  
\ No newline at end of file Index: branches/unlabeled/unlabeled-1.2.50/kernel/admin_templates/incs/close_popup.tpl =================================================================== diff -u -r4229 -r5795 --- branches/unlabeled/unlabeled-1.2.50/kernel/admin_templates/incs/close_popup.tpl (.../close_popup.tpl) (revision 4229) +++ branches/unlabeled/unlabeled-1.2.50/kernel/admin_templates/incs/close_popup.tpl (.../close_popup.tpl) (revision 5795) @@ -1,15 +1,14 @@ - - - - - - - - + + + + + + \ No newline at end of file Index: branches/unlabeled/unlabeled-1.73.2/core/kernel/db/db_event_handler.php =================================================================== diff -u -r5727 -r5795 --- branches/unlabeled/unlabeled-1.73.2/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 5727) +++ branches/unlabeled/unlabeled-1.73.2/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 5795) @@ -106,6 +106,7 @@ 'OnMassClone' => Array('self' => 'add', 'subitem' => 'add|edit'), 'OnSelectItems' => Array('self' => 'add|edit', 'subitem' => 'add|edit'), + 'OnProcessSelected' => Array('self' => 'add|edit', 'subitem' => 'add|edit'), 'OnSelectUser' => Array('self' => 'add|edit', 'subitem' => 'add|edit'), 'OnMassApprove' => Array('self' => 'advanced:approve|add|edit', 'subitem' => 'advanced:approve|add|edit'), Index: branches/unlabeled/unlabeled-1.1.2/core/admin_templates/catalog/advanced_view.tpl =================================================================== diff -u -r5787 -r5795 --- branches/unlabeled/unlabeled-1.1.2/core/admin_templates/catalog/advanced_view.tpl (.../advanced_view.tpl) (revision 5787) +++ branches/unlabeled/unlabeled-1.1.2/core/admin_templates/catalog/advanced_view.tpl (.../advanced_view.tpl) (revision 5795) @@ -66,8 +66,14 @@ function edit() { $form_name = $Catalog.queryTabRegistry('prefix', $Catalog.ActivePrefix, 'tab_id') + '_form'; + var $kf = document.getElementById($form_name); + var $prev_action = $kf.action; + $kf.action = ''; + set_hidden_field('remove_specials[' + $Catalog.ActivePrefix + ']', 1); std_edit_item($Catalog.ActivePrefix, $Catalog.queryTabRegistry('prefix', $Catalog.ActivePrefix, 'edit_template')); + + $kf.action = $prev_action; } Index: branches/unlabeled/unlabeled-1.9.2/core/units/general/inp_db_event_handler.php =================================================================== diff -u -r5450 -r5795 --- branches/unlabeled/unlabeled-1.9.2/core/units/general/inp_db_event_handler.php (.../inp_db_event_handler.php) (revision 5450) +++ branches/unlabeled/unlabeled-1.9.2/core/units/general/inp_db_event_handler.php (.../inp_db_event_handler.php) (revision 5795) @@ -28,19 +28,15 @@ } $object =& $event->getObject( Array('skip_autoload' => true) ); - $this->StoreSelectedIDs($event); - $ids=$this->getSelectedIDs($event); + $ids = $this->StoreSelectedIDs($event); - if($ids) - { + if ($ids) { $status_field = array_shift( $this->Application->getUnitOption($event->Prefix,'StatusField') ); - foreach($ids as $id) - { + foreach ($ids as $id) { $object->Load($id); - switch ($event->Name) - { + switch ($event->Name) { case 'OnMassApprove': $object->SetDBField($status_field, 1); break; @@ -58,15 +54,12 @@ break; } - if( $object->Update() ) - { - $event->status=erSUCCESS; - $event->redirect_params = Array('opener' => 's', 'pass_events' => true); //stay! + if ($object->Update()) { + $event->status = erSUCCESS; } - else - { - $event->status=erFAIL; - $event->redirect=false; + else { + $event->status = erFAIL; + $event->redirect = false; break; } } @@ -84,25 +77,23 @@ return; } - $event->status=erSUCCESS; + $event->status = erSUCCESS; $temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); - $this->StoreSelectedIDs($event); - $ids=$this->getSelectedIDs($event); + $ids = $this->StoreSelectedIDs($event); - if($ids) - { + if ($ids) { $temp->CloneItems($event->Prefix, $event->Special, $ids); } + + $this->clearSelectedIDs($event); } function check_array($records, $field, $value) { - foreach ($records as $record) - { - if ($record[$field] == $value) - { + foreach ($records as $record) { + if ($record[$field] == $value) { return true; } } Index: branches/unlabeled/unlabeled-1.9.2/kernel/units/general/inp_db_event_handler.php =================================================================== diff -u -r5450 -r5795 --- branches/unlabeled/unlabeled-1.9.2/kernel/units/general/inp_db_event_handler.php (.../inp_db_event_handler.php) (revision 5450) +++ branches/unlabeled/unlabeled-1.9.2/kernel/units/general/inp_db_event_handler.php (.../inp_db_event_handler.php) (revision 5795) @@ -28,19 +28,15 @@ } $object =& $event->getObject( Array('skip_autoload' => true) ); - $this->StoreSelectedIDs($event); - $ids=$this->getSelectedIDs($event); + $ids = $this->StoreSelectedIDs($event); - if($ids) - { + if ($ids) { $status_field = array_shift( $this->Application->getUnitOption($event->Prefix,'StatusField') ); - foreach($ids as $id) - { + foreach ($ids as $id) { $object->Load($id); - switch ($event->Name) - { + switch ($event->Name) { case 'OnMassApprove': $object->SetDBField($status_field, 1); break; @@ -58,15 +54,12 @@ break; } - if( $object->Update() ) - { - $event->status=erSUCCESS; - $event->redirect_params = Array('opener' => 's', 'pass_events' => true); //stay! + if ($object->Update()) { + $event->status = erSUCCESS; } - else - { - $event->status=erFAIL; - $event->redirect=false; + else { + $event->status = erFAIL; + $event->redirect = false; break; } } @@ -84,25 +77,23 @@ return; } - $event->status=erSUCCESS; + $event->status = erSUCCESS; $temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); - $this->StoreSelectedIDs($event); - $ids=$this->getSelectedIDs($event); + $ids = $this->StoreSelectedIDs($event); - if($ids) - { + if ($ids) { $temp->CloneItems($event->Prefix, $event->Special, $ids); } + + $this->clearSelectedIDs($event); } function check_array($records, $field, $value) { - foreach ($records as $record) - { - if ($record[$field] == $value) - { + foreach ($records as $record) { + if ($record[$field] == $value) { return true; } } Index: branches/unlabeled/unlabeled-1.1.2/core/admin_templates/catalog/item_selector/item_selector_tabs.tpl =================================================================== diff -u -r5787 -r5795 --- branches/unlabeled/unlabeled-1.1.2/core/admin_templates/catalog/item_selector/item_selector_tabs.tpl (.../item_selector_tabs.tpl) (revision 5787) +++ branches/unlabeled/unlabeled-1.1.2/core/admin_templates/catalog/item_selector/item_selector_tabs.tpl (.../item_selector_tabs.tpl) (revision 5795) @@ -3,8 +3,8 @@ - - + +
Index: branches/unlabeled/unlabeled-1.3.2/core/admin_templates/categories/ci_blocks.tpl =================================================================== diff -u -r5440 -r5795 --- branches/unlabeled/unlabeled-1.3.2/core/admin_templates/categories/ci_blocks.tpl (.../ci_blocks.tpl) (revision 5440) +++ branches/unlabeled/unlabeled-1.3.2/core/admin_templates/categories/ci_blocks.tpl (.../ci_blocks.tpl) (revision 5795) @@ -25,4 +25,17 @@ + + + + "> + + + + " align="absmiddle"/> + () + + +   + \ No newline at end of file Index: branches/unlabeled/unlabeled-1.3.2/kernel/admin_templates/categories/ci_blocks.tpl =================================================================== diff -u -r5440 -r5795 --- branches/unlabeled/unlabeled-1.3.2/kernel/admin_templates/categories/ci_blocks.tpl (.../ci_blocks.tpl) (revision 5440) +++ branches/unlabeled/unlabeled-1.3.2/kernel/admin_templates/categories/ci_blocks.tpl (.../ci_blocks.tpl) (revision 5795) @@ -25,4 +25,17 @@ + + + + "> + + + + " align="absmiddle"/> + () + + +   + \ No newline at end of file Index: branches/unlabeled/unlabeled-1.4.50/kernel/admin_templates/incs/tab_blocks.tpl =================================================================== diff -u -r1737 -r5795 --- branches/unlabeled/unlabeled-1.4.50/kernel/admin_templates/incs/tab_blocks.tpl (.../tab_blocks.tpl) (revision 1737) +++ branches/unlabeled/unlabeled-1.4.50/kernel/admin_templates/incs/tab_blocks.tpl (.../tab_blocks.tpl) (revision 5795) @@ -27,14 +27,14 @@ - + url(img/tab_back3.jpg) no-repeat top left;" cellpadding="0" cellspacing="0" border="0"> Index: branches/unlabeled/unlabeled-1.1.2/core/admin_templates/categories/categories_edit_relations.tpl =================================================================== diff -u -r5417 -r5795 --- branches/unlabeled/unlabeled-1.1.2/core/admin_templates/categories/categories_edit_relations.tpl (.../categories_edit_relations.tpl) (revision 5417) +++ branches/unlabeled/unlabeled-1.1.2/core/admin_templates/categories/categories_edit_relations.tpl (.../categories_edit_relations.tpl) (revision 5795) @@ -40,10 +40,7 @@ //Relations related: a_toolbar.AddButton( new ToolBarButton('new_relation', '', function() { - document.getElementById('events[c-rel]').value = 'OnAddRelation'; - document.getElementById('t').value = 'categories/relations_edit'; - opener_action('d'); - OpenItemSelector('&CatId='+''+'&Selector=radio&main_prefix=c&dst_field=&return_template=','kernel_form'); + openSelector('c-rel', '', 'TargetId', '950x600'); } ) ); function edit() Index: branches/unlabeled/unlabeled-1.50.2/core/units/categories/categories_config.php =================================================================== diff -u -r5715 -r5795 --- branches/unlabeled/unlabeled-1.50.2/core/units/categories/categories_config.php (.../categories_config.php) (revision 5715) +++ branches/unlabeled/unlabeled-1.50.2/core/units/categories/categories_config.php (.../categories_config.php) (revision 5795) @@ -11,7 +11,11 @@ Array('pseudo' => 'kPermCacheUpdater','class' => 'kPermCacheUpdater', 'file' => 'cache_updater.php','build_event'=>''), ), - 'AutoLoad' => true, + 'AutoLoad' => true, + 'CatalogItem' => true, + 'AdminTemplatePath' => 'categories', + 'AdminTemplatePrefix' => 'categories_', + 'QueryString' => Array( 1 => 'id', 2 => 'page', @@ -30,6 +34,7 @@ 'StatusField' => Array('Status'), 'TitleField' => 'Name', // field, used in bluebar when editing existing item + 'TitlePhrase' => 'la_Text_Category', 'ItemType' => 1, // used for custom fields only 'StatisticsInfo' => Array( Index: branches/unlabeled/unlabeled-1.1.2/kernel/admin_templates/categories/categories_edit_relations.tpl =================================================================== diff -u -r5417 -r5795 --- branches/unlabeled/unlabeled-1.1.2/kernel/admin_templates/categories/categories_edit_relations.tpl (.../categories_edit_relations.tpl) (revision 5417) +++ branches/unlabeled/unlabeled-1.1.2/kernel/admin_templates/categories/categories_edit_relations.tpl (.../categories_edit_relations.tpl) (revision 5795) @@ -40,10 +40,7 @@ //Relations related: a_toolbar.AddButton( new ToolBarButton('new_relation', '', function() { - document.getElementById('events[c-rel]').value = 'OnAddRelation'; - document.getElementById('t').value = 'categories/relations_edit'; - opener_action('d'); - OpenItemSelector('&CatId='+''+'&Selector=radio&main_prefix=c&dst_field=&return_template=','kernel_form'); + openSelector('c-rel', '', 'TargetId', '950x600'); } ) ); function edit() Index: branches/unlabeled/unlabeled-1.50.2/kernel/units/categories/categories_config.php =================================================================== diff -u -r5715 -r5795 --- branches/unlabeled/unlabeled-1.50.2/kernel/units/categories/categories_config.php (.../categories_config.php) (revision 5715) +++ branches/unlabeled/unlabeled-1.50.2/kernel/units/categories/categories_config.php (.../categories_config.php) (revision 5795) @@ -11,7 +11,11 @@ Array('pseudo' => 'kPermCacheUpdater','class' => 'kPermCacheUpdater', 'file' => 'cache_updater.php','build_event'=>''), ), - 'AutoLoad' => true, + 'AutoLoad' => true, + 'CatalogItem' => true, + 'AdminTemplatePath' => 'categories', + 'AdminTemplatePrefix' => 'categories_', + 'QueryString' => Array( 1 => 'id', 2 => 'page', @@ -30,6 +34,7 @@ 'StatusField' => Array('Status'), 'TitleField' => 'Name', // field, used in bluebar when editing existing item + 'TitlePhrase' => 'la_Text_Category', 'ItemType' => 1, // used for custom fields only 'StatisticsInfo' => Array( Index: branches/unlabeled/unlabeled-1.1.2/kernel/admin_templates/img/icons/icon46_advanced_view.gif =================================================================== diff -u Binary files differ Index: branches/unlabeled/unlabeled-1.4.2/core/units/relationship/relationship_config.php =================================================================== diff -u -r5560 -r5795 --- branches/unlabeled/unlabeled-1.4.2/core/units/relationship/relationship_config.php (.../relationship_config.php) (revision 5560) +++ branches/unlabeled/unlabeled-1.4.2/core/units/relationship/relationship_config.php (.../relationship_config.php) (revision 5795) @@ -77,14 +77,14 @@ 'ItemSQLs' => Array( '' => 'SELECT %1$s.* %2$s FROM %1$s #ITEM_JOIN#',), 'Fields' => Array( - 'RelationshipId' => Array(), - 'SourceId' => Array('type'=>'int'), - 'TargetId' => Array('type'=>'int'), - 'SourceType' => Array('type'=>'int','not_null'=>1,'default'=>0), - 'TargetType' => Array('type'=>'int','not_null'=>1,'default'=>0), - 'Type' => Array('type'=>'int','formatter'=>'kOptionsFormatter','options'=>Array(1=>'la_Reciprocal',0=>'la_OneWay'),'not_null'=>1,'default'=>0,'use_phrases'=>1), - 'Enabled' => Array('type'=>'int','formatter'=>'kOptionsFormatter','options'=>Array(0=>'la_Disabled',1=>'la_Enabled'),'not_null'=>1,'default'=>1,'use_phrases'=>1), - 'Priority' => Array('type'=>'int','not_null'=>1,'default'=>0), + 'RelationshipId' => Array(), + 'SourceId' => Array('type'=>'int', 'required' => 1, 'default' => 0), + 'TargetId' => Array('type'=>'int', 'required' => 1, 'default' => ''), + 'SourceType' => Array('type'=>'int','not_null'=>1,'default'=>0), + 'TargetType' => Array('type'=>'int','not_null'=>1,'default'=>0), + 'Type' => Array('type'=>'int','formatter'=>'kOptionsFormatter', 'required' => 1, 'options'=>Array(1=>'la_Reciprocal',0=>'la_OneWay'),'not_null'=>1,'default'=>0,'use_phrases'=>1), + 'Enabled' => Array('type'=>'int','formatter'=>'kOptionsFormatter','options'=>Array(0=>'la_Disabled',1=>'la_Enabled'),'not_null'=>1,'default'=>1,'use_phrases'=>1), + 'Priority' => Array('type'=>'int','not_null'=>1,'default'=>0), ), 'VirtualFields' => Array( 'ItemName' => Array(), 'ItemType' => Array(), Index: branches/unlabeled/unlabeled-1.1.2/kernel/admin_templates/item_selector/item_selector_tabs.tpl =================================================================== diff -u -r5787 -r5795 --- branches/unlabeled/unlabeled-1.1.2/kernel/admin_templates/item_selector/item_selector_tabs.tpl (.../item_selector_tabs.tpl) (revision 5787) +++ branches/unlabeled/unlabeled-1.1.2/kernel/admin_templates/item_selector/item_selector_tabs.tpl (.../item_selector_tabs.tpl) (revision 5795) @@ -3,8 +3,8 @@ Index: branches/unlabeled/unlabeled-1.6.2/kernel/units/relationship/relationship_event_handler.php =================================================================== diff -u -r5757 -r5795 --- branches/unlabeled/unlabeled-1.6.2/kernel/units/relationship/relationship_event_handler.php (.../relationship_event_handler.php) (revision 5757) +++ branches/unlabeled/unlabeled-1.6.2/kernel/units/relationship/relationship_event_handler.php (.../relationship_event_handler.php) (revision 5795) @@ -10,71 +10,108 @@ { parent::mapPermissions(); $permissions = Array( - 'OnAddRelation' => Array('subitem' => 'add|edit'), + 'OnProcessSelected' => Array('subitem' => 'add|edit'), ); $this->permMapping = array_merge($this->permMapping, $permissions); } /** - * Add new relation + * Initializes new relation * * @param kEvent $event */ - function OnAddRelation(&$event) + function OnNew(&$event) { - $object =& $event->getObject( Array('skip_autoload' => true) ); - + parent::OnNew(&$event); + + $object =& $event->getObject(); $table_info = $object->getLinkedInfo(); - $main_item_type = $this->Application->getUnitOption($table_info['ParentPrefix'],'ItemType'); - - $target['id'] = $this->Application->GetVar('TargetId'); - $target['type'] = $this->Application->GetVar('TargetType'); - - - $object->SetDBField($table_info['ForeignKey'], $table_info['ParentId']); - $object->SetDBField('SourceType', $main_item_type); - $object->SetDBField('TargetId', $target['id']); - $object->SetDBField('TargetType', $target['type']); - - // 1. get item info used in relation - $configs = $this->extractModulesInfo(); - foreach($configs as $prefix => $config_data) - { - if ($config_data['ItemType'] == $target['type']) { - if ($prefix == 'm') $prefix = 'c'; - break; + + $object->SetDBField('SourceId', $table_info['ParentId']); + $source_itemtype = $this->Application->getUnitOption($table_info['ParentPrefix'], 'ItemType'); + $object->SetDBField('SourceType', $source_itemtype); + + $object->SetDBField('TargetId', $this->Application->GetVar('target_id')); + $object->SetDBField('TargetType', $this->Application->GetVar('target_type')); + + $this->OnAfterItemLoad($event); + } + + /** + * Add new relation + * + * @param kEvent $event + */ + function OnProcessSelected(&$event) + { + $dst_field = $this->Application->RecallVar('dst_field'); + if ($dst_field == 'TargetId') { + // prepare target_id & target_type + $object =& $event->getObject( Array('skip_autoload' => true) ); + + $selected_ids = $this->Application->GetVar('selected_ids'); + $target_prefix = false; + foreach ($selected_ids as $selected_prefix => $target_id) { + if ($target_id > 0) { + $target_prefix = $selected_prefix; + break; + } } + + $sql = 'SELECT ResourceId + FROM '.$this->Application->getUnitOption($target_prefix, 'TableName').' + WHERE '.$this->Application->getUnitOption($target_prefix, 'IDField').' = '.$target_id; + $target_id = $this->Conn->GetOne($sql); + $target_type = $this->Application->getUnitOption($target_prefix, 'ItemType'); + + // don't add same relation twice + $table_info = $object->getLinkedInfo(); + $sql = 'SELECT TargetId + FROM '.$object->TableName.' + WHERE (SourceId = '.$table_info['ParentId'].') AND (TargetId = '.$target_id.')'; + $duplicate_relation = $this->Conn->GetOne($sql) == $target_id; + + $this->finalizePopup($event); + + if (!$duplicate_relation) { + // place correct template in opener stack + $source_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix'); + $template = $this->Application->getUnitOption($source_prefix, 'AdminTemplatePath').'/relations_edit'; + $redirect_params = Array($event->Prefix.'_event' => 'OnNew', 'target_id' => $target_id, 'target_type' => $target_type); + $this->Application->EventManager->openerStackPush($template, $redirect_params, 'all,'.$event->Prefix); + } } - - // 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']); - - $object->setID(0); - - $event->redirect = false; - - // 2. substitute opener - $opener_stack = $this->Application->RecallVar('opener_stack'); - $opener_stack = $opener_stack ? unserialize($opener_stack) : Array(); - array_pop($opener_stack); - - $return_template = $this->Application->RecallVar('return_template'); - $new_level = 'index.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)); - - $this->Application->SetVar($event->Prefix_Special.'_SaveEvent','OnCreate'); + else { + $this->finalizePopup($event); + } } /** + * Set ItemName & ItemType virtual fields based on loaded item data + * + * @param kEvent $event + */ + function OnAfterItemLoad(&$event) + { + $object =& $event->getObject(); + + $sql = 'SELECT Prefix + FROM '.TABLE_PREFIX.'ItemTypes + WHERE ItemType = '.$object->GetDBField('TargetType'); + $target_prefix = $this->Conn->GetOne($sql); + + $title_field = $this->getTitleField($target_prefix); + $title_phrase = $this->Application->getUnitOption($target_prefix, 'TitlePhrase'); + + $sql = 'SELECT '.$title_field.' + FROM '.$this->Application->getUnitOption($target_prefix, 'TableName').' + WHERE ResourceId = '.$object->GetDBField('TargetId'); + + $object->SetDBField('ItemName', $this->Conn->GetOne($sql)); + $object->SetDBField('ItemType', $this->Application->Phrase($title_phrase)); + } + + /** * Creates needed sql query to load list, * if no query is defined in config for * special requested, then use default @@ -85,7 +122,7 @@ */ function ListPrepareQuery(&$event) { - return $this->BaseQuery($event,'ListSQLs'); + return $this->BaseQuery($event, 'ListSQLs'); } /** @@ -99,7 +136,7 @@ */ function ItemPrepareQuery(&$event) { - return $this->BaseQuery($event,'ItemSQLs'); + return $this->BaseQuery($event, 'ItemSQLs'); } @@ -124,14 +161,7 @@ $sql_parts = Array(); $sql_parts['TargetName'] = "''"; foreach ($configs as $prefix => $config_data) { - // convert TitleField field of kMultiLanguage formatter used for it: begin - $title_field = $config_data['TitleField']; - $formatter_class = isset($config_data['Fields'][$title_field]['formatter']) ? $config_data['Fields'][$title_field]['formatter'] : ''; - if ($formatter_class == 'kMultiLanguage') { - $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); - $title_field = $ml_formatter->LangFieldName($title_field); - } - // convert TitleField field of kMultiLanguage formatter used for it: end + $title_field = $this->getTitleField($prefix); $sql_parts['ItemName'][] = sprintf($sql_templates['ItemName'], $config_data['TableName'], $title_field); $sql_parts['TableJoin'][] = sprintf($sql_templates['TableJoin'], $config_data['TableName']); @@ -162,6 +192,26 @@ } /** + * Convert TitleField field of kMultiLanguage formatter used for it + * + * @param string $prefix + * @return string + */ + function getTitleField($prefix) + { + $lang_prefix = 'l'.$this->Application->GetVar('m_lang').'_'; + + $title_field = $this->Application->getUnitOption($prefix, 'TitleField'); + $field_options = $this->Application->getUnitOption($prefix.'.'.$title_field, 'Fields'); + + $formatter_class = isset($field_options['formatter']) ? $field_options['formatter'] : ''; + if ($formatter_class == 'kMultiLanguage' && !isset($field_options['master_field'])) { + $title_field = $lang_prefix.$title_field; + } + return $title_field; + } + + /** * Get configs from modules installed * * @return Array @@ -174,14 +224,16 @@ $configs = Array(); foreach ($this->Application->ModuleInfo as $module_name => $module_data) { $prefix = $module_data['Var']; + if ($prefix == 'm') { + $prefix = 'c'; + } $configs[$prefix] = $this->Application->getUnitOptions($prefix); if($configs[$prefix] === false) unset($configs[$prefix]); if(!isset($configs[$prefix]['CatalogItem']) || !$configs[$prefix]['CatalogItem']) unset($configs[$prefix]); } return $configs; } - /** * Deletes relations to hooked item from other items * Index: branches/unlabeled/unlabeled-1.4.2/kernel/units/relationship/relationship_config.php =================================================================== diff -u -r5560 -r5795 --- branches/unlabeled/unlabeled-1.4.2/kernel/units/relationship/relationship_config.php (.../relationship_config.php) (revision 5560) +++ branches/unlabeled/unlabeled-1.4.2/kernel/units/relationship/relationship_config.php (.../relationship_config.php) (revision 5795) @@ -77,14 +77,14 @@ 'ItemSQLs' => Array( '' => 'SELECT %1$s.* %2$s FROM %1$s #ITEM_JOIN#',), 'Fields' => Array( - 'RelationshipId' => Array(), - 'SourceId' => Array('type'=>'int'), - 'TargetId' => Array('type'=>'int'), - 'SourceType' => Array('type'=>'int','not_null'=>1,'default'=>0), - 'TargetType' => Array('type'=>'int','not_null'=>1,'default'=>0), - 'Type' => Array('type'=>'int','formatter'=>'kOptionsFormatter','options'=>Array(1=>'la_Reciprocal',0=>'la_OneWay'),'not_null'=>1,'default'=>0,'use_phrases'=>1), - 'Enabled' => Array('type'=>'int','formatter'=>'kOptionsFormatter','options'=>Array(0=>'la_Disabled',1=>'la_Enabled'),'not_null'=>1,'default'=>1,'use_phrases'=>1), - 'Priority' => Array('type'=>'int','not_null'=>1,'default'=>0), + 'RelationshipId' => Array(), + 'SourceId' => Array('type'=>'int', 'required' => 1, 'default' => 0), + 'TargetId' => Array('type'=>'int', 'required' => 1, 'default' => ''), + 'SourceType' => Array('type'=>'int','not_null'=>1,'default'=>0), + 'TargetType' => Array('type'=>'int','not_null'=>1,'default'=>0), + 'Type' => Array('type'=>'int','formatter'=>'kOptionsFormatter', 'required' => 1, 'options'=>Array(1=>'la_Reciprocal',0=>'la_OneWay'),'not_null'=>1,'default'=>0,'use_phrases'=>1), + 'Enabled' => Array('type'=>'int','formatter'=>'kOptionsFormatter','options'=>Array(0=>'la_Disabled',1=>'la_Enabled'),'not_null'=>1,'default'=>1,'use_phrases'=>1), + 'Priority' => Array('type'=>'int','not_null'=>1,'default'=>0), ), 'VirtualFields' => Array( 'ItemName' => Array(), 'ItemType' => Array(), Index: branches/unlabeled/unlabeled-1.6.2/core/units/relationship/relationship_event_handler.php =================================================================== diff -u -r5757 -r5795 --- branches/unlabeled/unlabeled-1.6.2/core/units/relationship/relationship_event_handler.php (.../relationship_event_handler.php) (revision 5757) +++ branches/unlabeled/unlabeled-1.6.2/core/units/relationship/relationship_event_handler.php (.../relationship_event_handler.php) (revision 5795) @@ -10,71 +10,108 @@ { parent::mapPermissions(); $permissions = Array( - 'OnAddRelation' => Array('subitem' => 'add|edit'), + 'OnProcessSelected' => Array('subitem' => 'add|edit'), ); $this->permMapping = array_merge($this->permMapping, $permissions); } /** - * Add new relation + * Initializes new relation * * @param kEvent $event */ - function OnAddRelation(&$event) + function OnNew(&$event) { - $object =& $event->getObject( Array('skip_autoload' => true) ); - + parent::OnNew(&$event); + + $object =& $event->getObject(); $table_info = $object->getLinkedInfo(); - $main_item_type = $this->Application->getUnitOption($table_info['ParentPrefix'],'ItemType'); - - $target['id'] = $this->Application->GetVar('TargetId'); - $target['type'] = $this->Application->GetVar('TargetType'); - - - $object->SetDBField($table_info['ForeignKey'], $table_info['ParentId']); - $object->SetDBField('SourceType', $main_item_type); - $object->SetDBField('TargetId', $target['id']); - $object->SetDBField('TargetType', $target['type']); - - // 1. get item info used in relation - $configs = $this->extractModulesInfo(); - foreach($configs as $prefix => $config_data) - { - if ($config_data['ItemType'] == $target['type']) { - if ($prefix == 'm') $prefix = 'c'; - break; + + $object->SetDBField('SourceId', $table_info['ParentId']); + $source_itemtype = $this->Application->getUnitOption($table_info['ParentPrefix'], 'ItemType'); + $object->SetDBField('SourceType', $source_itemtype); + + $object->SetDBField('TargetId', $this->Application->GetVar('target_id')); + $object->SetDBField('TargetType', $this->Application->GetVar('target_type')); + + $this->OnAfterItemLoad($event); + } + + /** + * Add new relation + * + * @param kEvent $event + */ + function OnProcessSelected(&$event) + { + $dst_field = $this->Application->RecallVar('dst_field'); + if ($dst_field == 'TargetId') { + // prepare target_id & target_type + $object =& $event->getObject( Array('skip_autoload' => true) ); + + $selected_ids = $this->Application->GetVar('selected_ids'); + $target_prefix = false; + foreach ($selected_ids as $selected_prefix => $target_id) { + if ($target_id > 0) { + $target_prefix = $selected_prefix; + break; + } } + + $sql = 'SELECT ResourceId + FROM '.$this->Application->getUnitOption($target_prefix, 'TableName').' + WHERE '.$this->Application->getUnitOption($target_prefix, 'IDField').' = '.$target_id; + $target_id = $this->Conn->GetOne($sql); + $target_type = $this->Application->getUnitOption($target_prefix, 'ItemType'); + + // don't add same relation twice + $table_info = $object->getLinkedInfo(); + $sql = 'SELECT TargetId + FROM '.$object->TableName.' + WHERE (SourceId = '.$table_info['ParentId'].') AND (TargetId = '.$target_id.')'; + $duplicate_relation = $this->Conn->GetOne($sql) == $target_id; + + $this->finalizePopup($event); + + if (!$duplicate_relation) { + // place correct template in opener stack + $source_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix'); + $template = $this->Application->getUnitOption($source_prefix, 'AdminTemplatePath').'/relations_edit'; + $redirect_params = Array($event->Prefix.'_event' => 'OnNew', 'target_id' => $target_id, 'target_type' => $target_type); + $this->Application->EventManager->openerStackPush($template, $redirect_params, 'all,'.$event->Prefix); + } } - - // 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']); - - $object->setID(0); - - $event->redirect = false; - - // 2. substitute opener - $opener_stack = $this->Application->RecallVar('opener_stack'); - $opener_stack = $opener_stack ? unserialize($opener_stack) : Array(); - array_pop($opener_stack); - - $return_template = $this->Application->RecallVar('return_template'); - $new_level = 'index.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)); - - $this->Application->SetVar($event->Prefix_Special.'_SaveEvent','OnCreate'); + else { + $this->finalizePopup($event); + } } /** + * Set ItemName & ItemType virtual fields based on loaded item data + * + * @param kEvent $event + */ + function OnAfterItemLoad(&$event) + { + $object =& $event->getObject(); + + $sql = 'SELECT Prefix + FROM '.TABLE_PREFIX.'ItemTypes + WHERE ItemType = '.$object->GetDBField('TargetType'); + $target_prefix = $this->Conn->GetOne($sql); + + $title_field = $this->getTitleField($target_prefix); + $title_phrase = $this->Application->getUnitOption($target_prefix, 'TitlePhrase'); + + $sql = 'SELECT '.$title_field.' + FROM '.$this->Application->getUnitOption($target_prefix, 'TableName').' + WHERE ResourceId = '.$object->GetDBField('TargetId'); + + $object->SetDBField('ItemName', $this->Conn->GetOne($sql)); + $object->SetDBField('ItemType', $this->Application->Phrase($title_phrase)); + } + + /** * Creates needed sql query to load list, * if no query is defined in config for * special requested, then use default @@ -85,7 +122,7 @@ */ function ListPrepareQuery(&$event) { - return $this->BaseQuery($event,'ListSQLs'); + return $this->BaseQuery($event, 'ListSQLs'); } /** @@ -99,7 +136,7 @@ */ function ItemPrepareQuery(&$event) { - return $this->BaseQuery($event,'ItemSQLs'); + return $this->BaseQuery($event, 'ItemSQLs'); } @@ -124,14 +161,7 @@ $sql_parts = Array(); $sql_parts['TargetName'] = "''"; foreach ($configs as $prefix => $config_data) { - // convert TitleField field of kMultiLanguage formatter used for it: begin - $title_field = $config_data['TitleField']; - $formatter_class = isset($config_data['Fields'][$title_field]['formatter']) ? $config_data['Fields'][$title_field]['formatter'] : ''; - if ($formatter_class == 'kMultiLanguage') { - $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); - $title_field = $ml_formatter->LangFieldName($title_field); - } - // convert TitleField field of kMultiLanguage formatter used for it: end + $title_field = $this->getTitleField($prefix); $sql_parts['ItemName'][] = sprintf($sql_templates['ItemName'], $config_data['TableName'], $title_field); $sql_parts['TableJoin'][] = sprintf($sql_templates['TableJoin'], $config_data['TableName']); @@ -162,6 +192,26 @@ } /** + * Convert TitleField field of kMultiLanguage formatter used for it + * + * @param string $prefix + * @return string + */ + function getTitleField($prefix) + { + $lang_prefix = 'l'.$this->Application->GetVar('m_lang').'_'; + + $title_field = $this->Application->getUnitOption($prefix, 'TitleField'); + $field_options = $this->Application->getUnitOption($prefix.'.'.$title_field, 'Fields'); + + $formatter_class = isset($field_options['formatter']) ? $field_options['formatter'] : ''; + if ($formatter_class == 'kMultiLanguage' && !isset($field_options['master_field'])) { + $title_field = $lang_prefix.$title_field; + } + return $title_field; + } + + /** * Get configs from modules installed * * @return Array @@ -174,14 +224,16 @@ $configs = Array(); foreach ($this->Application->ModuleInfo as $module_name => $module_data) { $prefix = $module_data['Var']; + if ($prefix == 'm') { + $prefix = 'c'; + } $configs[$prefix] = $this->Application->getUnitOptions($prefix); if($configs[$prefix] === false) unset($configs[$prefix]); if(!isset($configs[$prefix]['CatalogItem']) || !$configs[$prefix]['CatalogItem']) unset($configs[$prefix]); } return $configs; } - /** * Deletes relations to hooked item from other items *
left.gif" width="15" height="23"> - " class="" onClick="">
+ " class="" onClick="">
right.gif" width="15" height="23">
- - + +