Index: branches/unlabeled/unlabeled-1.64.2/kernel/units/general/cat_event_handler.php =================================================================== diff -u -r5802 -r5820 --- branches/unlabeled/unlabeled-1.64.2/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5802) +++ branches/unlabeled/unlabeled-1.64.2/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5820) @@ -1618,25 +1618,31 @@ $event->setEventParam('pass_events', true); } - if ($dst_field == 'ItemCategory') { - $object =& $event->getObject(); // category item object (e.g. link, product, etc.) + $this->finalizePopup($event); + } - $object->assignToCategory($category_id); - - /*$ci_prefix = $object->Prefix.'-ci'; - $ci_object =& $this->Application->recallObject($ci_prefix, null, Array('skip_autoload' => true)); - - $ci_object->Load($category_id); - if (!$ci_object->isLoaded()) { - $fields_hash = Array('CategoryId' => $category_id, 'ItemResourceId' => $object->GetDBField('ResourceId')); - $ci_object->SetDBFieldsFromHash($fields_hash); - $ci_object->Create(true); - }*/ + /** + * Process items selected in item_selector + * + * @param kEvent $event + */ + function OnProcessSelected(&$event) + { + $selected_ids = $this->Application->GetVar('selected_ids'); + + $dst_field = $this->Application->RecallVar('dst_field'); + + if ($dst_field == 'ItemCategory') { + $object =& $event->getObject(); + $category_ids = explode(',', $selected_ids['c']); + foreach ($category_ids as $category_id) { + $object->assignToCategory($category_id); + } } $this->finalizePopup($event); } - + /** * Saves Import/Export settings to session * Index: branches/unlabeled/unlabeled-1.1.2/kernel/admin_templates/item_selector/item_selector_toolbar.tpl =================================================================== diff -u -r5788 -r5820 --- branches/unlabeled/unlabeled-1.1.2/kernel/admin_templates/item_selector/item_selector_toolbar.tpl (.../item_selector_toolbar.tpl) (revision 5788) +++ branches/unlabeled/unlabeled-1.1.2/kernel/admin_templates/item_selector/item_selector_toolbar.tpl (.../item_selector_toolbar.tpl) (revision 5820) @@ -7,7 +7,12 @@ a_toolbar.AddButton( new ToolBarButton('select', '', function() { - set_hidden_field('selected_ids[c]', Grids['c'].GetSelected()); + var $category_ids = Grids['c'].GetSelected(); + if ($category_ids.length == 0) { + // no categories selected, then use current category + $category_ids = get_hidden_field('m_cat_id'); + } + set_hidden_field('selected_ids[c]', $category_ids); if (Grids[$Catalog.ActivePrefix]) { set_hidden_field('selected_ids[' + $Catalog.ActivePrefix + ']', Grids[$Catalog.ActivePrefix].GetSelected()); } Index: branches/unlabeled/unlabeled-1.64.2/core/units/general/cat_event_handler.php =================================================================== diff -u -r5802 -r5820 --- branches/unlabeled/unlabeled-1.64.2/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5802) +++ branches/unlabeled/unlabeled-1.64.2/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5820) @@ -1618,25 +1618,31 @@ $event->setEventParam('pass_events', true); } - if ($dst_field == 'ItemCategory') { - $object =& $event->getObject(); // category item object (e.g. link, product, etc.) + $this->finalizePopup($event); + } - $object->assignToCategory($category_id); - - /*$ci_prefix = $object->Prefix.'-ci'; - $ci_object =& $this->Application->recallObject($ci_prefix, null, Array('skip_autoload' => true)); - - $ci_object->Load($category_id); - if (!$ci_object->isLoaded()) { - $fields_hash = Array('CategoryId' => $category_id, 'ItemResourceId' => $object->GetDBField('ResourceId')); - $ci_object->SetDBFieldsFromHash($fields_hash); - $ci_object->Create(true); - }*/ + /** + * Process items selected in item_selector + * + * @param kEvent $event + */ + function OnProcessSelected(&$event) + { + $selected_ids = $this->Application->GetVar('selected_ids'); + + $dst_field = $this->Application->RecallVar('dst_field'); + + if ($dst_field == 'ItemCategory') { + $object =& $event->getObject(); + $category_ids = explode(',', $selected_ids['c']); + foreach ($category_ids as $category_id) { + $object->assignToCategory($category_id); + } } $this->finalizePopup($event); } - + /** * Saves Import/Export settings to session * Index: branches/unlabeled/unlabeled-1.24.2/kernel/units/admin/admin_tag_processor.php =================================================================== diff -u -r5814 -r5820 --- branches/unlabeled/unlabeled-1.24.2/kernel/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 5814) +++ branches/unlabeled/unlabeled-1.24.2/kernel/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 5820) @@ -385,8 +385,14 @@ */ function SelectorLink($params) { - $params['t'] = 'item_selector/item_selector_'.$params['mode']; + $mode = 'catalog'; + if (isset($params['mode'])) { + $mode = $params['mode']; + unset($params['mode']); + } + $params['t'] = 'item_selector/item_selector_'.$mode; + $default_params = Array('no_amp' => 1, 'pass' => 'all,'.$params['prefix']); unset($params['prefix']); Index: branches/unlabeled/unlabeled-1.24.2/core/units/admin/admin_tag_processor.php =================================================================== diff -u -r5814 -r5820 --- branches/unlabeled/unlabeled-1.24.2/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 5814) +++ branches/unlabeled/unlabeled-1.24.2/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 5820) @@ -385,8 +385,14 @@ */ function SelectorLink($params) { - $params['t'] = 'item_selector/item_selector_'.$params['mode']; + $mode = 'catalog'; + if (isset($params['mode'])) { + $mode = $params['mode']; + unset($params['mode']); + } + $params['t'] = 'item_selector/item_selector_'.$mode; + $default_params = Array('no_amp' => 1, 'pass' => 'all,'.$params['prefix']); unset($params['prefix']); Index: branches/unlabeled/unlabeled-1.15.2/kernel/units/configuration/configuration_event_handler.php =================================================================== diff -u -r5787 -r5820 --- branches/unlabeled/unlabeled-1.15.2/kernel/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 5787) +++ branches/unlabeled/unlabeled-1.15.2/kernel/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 5820) @@ -180,13 +180,7 @@ function OnProcessSelected(&$event) { $selected_ids = $this->Application->GetVar('selected_ids'); - $category_id = $selected_ids['c']; - if (strlen($category_id) == 0) { - // no category selected, the use current - $category_id = $this->Application->GetVar('m_cat_id'); - } - - $this->Application->StoreVar('ModuleRootCategory', $category_id); + $this->Application->StoreVar('ModuleRootCategory', $selected_ids['c']); $this->finalizePopup($event); } Index: branches/unlabeled/unlabeled-1.32.2/core/units/general/cat_dbitem.php =================================================================== diff -u -r5635 -r5820 --- branches/unlabeled/unlabeled-1.32.2/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 5635) +++ branches/unlabeled/unlabeled-1.32.2/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 5820) @@ -70,7 +70,8 @@ if ($ret) { $table = $this->Application->IsTempTable($this->TableName) ? $this->Application->GetTempName(TABLE_PREFIX.'CategoryItems') : TABLE_PREFIX.'CategoryItems'; - $this->Conn->Query('UPDATE '.$table.' SET Filename = '.$this->Conn->qstr($this->GetDBField('Filename')).' WHERE ItemResourceId = '.$this->GetDBField('ResourceId')); + $filename = $this->useFilenames ? $this->GetDBField('Filename') : ''; + $this->Conn->Query('UPDATE '.$table.' SET Filename = '.$this->Conn->qstr($filename).' WHERE ItemResourceId = '.$this->GetDBField('ResourceId')); } unset($this->VirtualFields['ResourceId']); @@ -310,7 +311,8 @@ } else { $sql = 'INSERT INTO '.$table.' (CategoryId,ItemResourceId,PrimaryCat,ItemPrefix,Filename) VALUES (%s,%s,%s,%s,%s)'; - $this->Conn->Query( sprintf($sql, $category_id, $this->GetDBField('ResourceId'), $is_primary ? 1 : 0, $this->Conn->qstr($this->Prefix), $this->Conn->qstr($this->GetDBField('Filename'))) ); + $filename = $this->useFilenames ? $this->GetDBField('Filename') : ''; // because some prefixes does not use filenames + $this->Conn->Query( sprintf($sql, $category_id, $this->GetDBField('ResourceId'), $is_primary ? 1 : 0, $this->Conn->qstr($this->Prefix), $this->Conn->qstr($filename)) ); } // to ensure filename update after adding to another category // this is critical since there may be an item with same filename in newly added category! Index: branches/unlabeled/unlabeled-1.15.2/core/units/configuration/configuration_event_handler.php =================================================================== diff -u -r5787 -r5820 --- branches/unlabeled/unlabeled-1.15.2/core/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 5787) +++ branches/unlabeled/unlabeled-1.15.2/core/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 5820) @@ -180,13 +180,7 @@ function OnProcessSelected(&$event) { $selected_ids = $this->Application->GetVar('selected_ids'); - $category_id = $selected_ids['c']; - if (strlen($category_id) == 0) { - // no category selected, the use current - $category_id = $this->Application->GetVar('m_cat_id'); - } - - $this->Application->StoreVar('ModuleRootCategory', $category_id); + $this->Application->StoreVar('ModuleRootCategory', $selected_ids['c']); $this->finalizePopup($event); } Index: branches/unlabeled/unlabeled-1.32.2/kernel/units/general/cat_dbitem.php =================================================================== diff -u -r5635 -r5820 --- branches/unlabeled/unlabeled-1.32.2/kernel/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 5635) +++ branches/unlabeled/unlabeled-1.32.2/kernel/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 5820) @@ -70,7 +70,8 @@ if ($ret) { $table = $this->Application->IsTempTable($this->TableName) ? $this->Application->GetTempName(TABLE_PREFIX.'CategoryItems') : TABLE_PREFIX.'CategoryItems'; - $this->Conn->Query('UPDATE '.$table.' SET Filename = '.$this->Conn->qstr($this->GetDBField('Filename')).' WHERE ItemResourceId = '.$this->GetDBField('ResourceId')); + $filename = $this->useFilenames ? $this->GetDBField('Filename') : ''; + $this->Conn->Query('UPDATE '.$table.' SET Filename = '.$this->Conn->qstr($filename).' WHERE ItemResourceId = '.$this->GetDBField('ResourceId')); } unset($this->VirtualFields['ResourceId']); @@ -310,7 +311,8 @@ } else { $sql = 'INSERT INTO '.$table.' (CategoryId,ItemResourceId,PrimaryCat,ItemPrefix,Filename) VALUES (%s,%s,%s,%s,%s)'; - $this->Conn->Query( sprintf($sql, $category_id, $this->GetDBField('ResourceId'), $is_primary ? 1 : 0, $this->Conn->qstr($this->Prefix), $this->Conn->qstr($this->GetDBField('Filename'))) ); + $filename = $this->useFilenames ? $this->GetDBField('Filename') : ''; // because some prefixes does not use filenames + $this->Conn->Query( sprintf($sql, $category_id, $this->GetDBField('ResourceId'), $is_primary ? 1 : 0, $this->Conn->qstr($this->Prefix), $this->Conn->qstr($filename)) ); } // to ensure filename update after adding to another category // this is critical since there may be an item with same filename in newly added category! Index: branches/unlabeled/unlabeled-1.1.2/core/admin_templates/catalog/item_selector/item_selector_toolbar.tpl =================================================================== diff -u -r5788 -r5820 --- branches/unlabeled/unlabeled-1.1.2/core/admin_templates/catalog/item_selector/item_selector_toolbar.tpl (.../item_selector_toolbar.tpl) (revision 5788) +++ branches/unlabeled/unlabeled-1.1.2/core/admin_templates/catalog/item_selector/item_selector_toolbar.tpl (.../item_selector_toolbar.tpl) (revision 5820) @@ -7,7 +7,12 @@ a_toolbar.AddButton( new ToolBarButton('select', '', function() { - set_hidden_field('selected_ids[c]', Grids['c'].GetSelected()); + var $category_ids = Grids['c'].GetSelected(); + if ($category_ids.length == 0) { + // no categories selected, then use current category + $category_ids = get_hidden_field('m_cat_id'); + } + set_hidden_field('selected_ids[c]', $category_ids); if (Grids[$Catalog.ActivePrefix]) { set_hidden_field('selected_ids[' + $Catalog.ActivePrefix + ']', Grids[$Catalog.ActivePrefix].GetSelected()); }