Index: branches/unlabeled/unlabeled-1.22.2/kernel/units/categories/categories_event_handler.php =================================================================== diff -u -N -r5609 -r5610 --- branches/unlabeled/unlabeled-1.22.2/kernel/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 5609) +++ branches/unlabeled/unlabeled-1.22.2/kernel/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 5610) @@ -341,6 +341,20 @@ } /** + * Controls all item paste operations. Can occur only with filled clipbord. + * + * @param kEvent $event + */ + function OnPasteClipboard(&$event) + { + $clipboard = unserialize( $this->Application->RecallVar('clipboard') ); + foreach ($clipboard as $prefix => $clipboard_data) { + $paste_event = new kEvent($prefix.':OnPaste', Array('clipboard_data' => $clipboard_data)); + $this->Application->HandleEvent($paste_event); + } + } + + /** * Paste categories with subitems from clipboard * * @param kEvent $event @@ -351,9 +365,6 @@ $event->redirect = false; -// $clipboard_prefix = $this->Application->RecallVar('clipboard_prefix'); - - /*$ids = $this->Application->RecallVar($event->getPrefixSpecial().'_clipboard'); if ($ids == '') { $event->redirect = false; @@ -381,6 +392,44 @@ } /** + * Occurs when pasting category + * + * @param kEvent $event + */ + /*function OnCatPaste(&$event) + { + $inp_clipboard = $this->Application->RecallVar('ClipBoard'); + $inp_clipboard = explode('-', $inp_clipboard, 2); + + if($inp_clipboard[0] == 'COPY') + { + $saved_cat_id = $this->Application->GetVar('m_cat_id'); + $cat_ids = $event->getEventParam('cat_ids'); + + $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); + $table = $this->Application->getUnitOption($event->Prefix, 'TableName'); + $ids_sql = 'SELECT '.$id_field.' FROM '.$table.' WHERE ResourceId IN (%s)'; + $resource_ids_sql = 'SELECT ItemResourceId FROM '.TABLE_PREFIX.'CategoryItems WHERE CategoryId = %s AND PrimaryCat = 1'; + + $object =& $this->Application->recallObject($event->Prefix.'.item', $event->Prefix, Array('skip_autoload' => true)); + + foreach($cat_ids as $source_cat => $dest_cat) + { + $item_resource_ids = $this->Conn->GetCol( sprintf($resource_ids_sql, $source_cat) ); + if(!$item_resource_ids) continue; + + $this->Application->SetVar('m_cat_id', $dest_cat); + $item_ids = $this->Conn->GetCol( sprintf($ids_sql, implode(',', $item_resource_ids) ) ); + + $temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); + if($item_ids) $temp->CloneItems($event->Prefix, $event->Special, $item_ids); + } + + $this->Application->SetVar('m_cat_id', $saved_cat_id); + } + }*/ + + /** * Cleares clipboard content * * @param kEvent $event