Index: branches/5.2.x/core/units/category_items/category_items_event_handler.php =================================================================== diff -u -N -r14244 -r14628 --- branches/5.2.x/core/units/category_items/category_items_event_handler.php (.../category_items_event_handler.php) (revision 14244) +++ branches/5.2.x/core/units/category_items/category_items_event_handler.php (.../category_items_event_handler.php) (revision 14628) @@ -1,6 +1,6 @@ getObject(); $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + /* @var $ml_formatter kMultiLanguage */ + $object->addCalculatedField('CategoryName', 'c.'.$ml_formatter->LangFieldName('CachedNavbar')); } @@ -55,8 +59,11 @@ * Apply custom processing to item * * @param kEvent $event + * @param string $type + * @return void + * @access protected */ - function customProcessing(&$event, $type) + protected function customProcessing(&$event, $type) { if($event->Name == 'OnMassDelete') { @@ -108,29 +115,36 @@ * In case if item is deleted from it's last category, then delete item too. * * @param kEvent $event + * @return void + * @access protected */ - function OnDeleteFromCategory(&$event) + protected function OnDeleteFromCategory(&$event) { $category_ids = $event->getEventParam('category_ids'); - if(!$category_ids) return false; + if ( !$category_ids ) { + return ; + } + $item_prefix = $event->getEventParam('item_prefix'); - $item =& $this->Application->recallObject($item_prefix.'.-item', null, Array('skip_autoload' => true)); + $item =& $this->Application->recallObject($item_prefix . '.-item', null, Array ('skip_autoload' => true)); + /* @var $item kCatDBItem */ $ci_table = $this->Application->getUnitOption($event->Prefix, 'TableName'); $item_table = $this->Application->getUnitOption($item_prefix, 'TableName'); - $sql = 'SELECT ItemResourceId, CategoryId FROM %1$s INNER JOIN %2$s ON (%1$s.ResourceId = %2$s.ItemResourceId) WHERE CategoryId IN (%3$s)'; - $category_items = $this->Conn->Query( sprintf($sql, $item_table, $ci_table, implode(',', $category_ids) ) ); + $sql = 'SELECT ItemResourceId, CategoryId + FROM %1$s + INNER JOIN %2$s ON (%1$s.ResourceId = %2$s.ItemResourceId) + WHERE CategoryId IN (%3$s)'; + $category_items = $this->Conn->Query( sprintf($sql, $item_table, $ci_table, implode(',', $category_ids)) ); - $item_hash = Array(); - foreach($category_items as $ci_row) - { + $item_hash = Array (); + foreach ($category_items as $ci_row) { $item_hash[ $ci_row['ItemResourceId'] ][] = $ci_row['CategoryId']; } - foreach($item_hash as $item_resource_id => $delete_category_ids) - { + foreach ($item_hash as $item_resource_id => $delete_category_ids) { $item->Load($item_resource_id, 'ResourceId'); $item->DeleteFromCategories($delete_category_ids); }