Index: branches/unlabeled/unlabeled-1.64.2/kernel/units/general/cat_event_handler.php
===================================================================
diff -u -r5609 -r5610
--- branches/unlabeled/unlabeled-1.64.2/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5609)
+++ branches/unlabeled/unlabeled-1.64.2/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5610)
@@ -77,74 +77,28 @@
*/
function OnPaste(&$event)
{
- echo 'pasting categories';
- $event->redirect = false; // for debugging
+ $clipboard_data = $event->getEventParam('clipboard_data');
- /*$ids = $this->Application->RecallVar($event->getPrefixSpecial().'_clipboard');
- if ($ids == '') {
- $event->redirect = false;
- return;
+ if (!$clipboard_data['cut'] && !$clipboard_data['copy']) {
+ return false;
}
- $ids_arr = explode(',', $ids);
-
- if ($this->Application->RecallVar($event->getPrefixSpecial().'_clipboard_mode') == 'copy') {
+ if ($clipboard_data['copy']) {
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
-
- if ($ids_arr) {
- $temp->CloneItems($event->Prefix, $event->Special, $ids_arr);
- }
+ $temp->CloneItems($event->Prefix, $event->Special, $clipboard_data['copy']);
}
- else { // mode == cut
+
+ if ($clipboard_data['cut']) {
$object =& $this->Application->recallObject($event->getPrefixSpecial().'.item', $event->Prefix, Array('skip_autoload' => true));
- foreach ($ids_arr as $id) {
+ foreach ($clipboard_data['cut'] as $id) {
$object->Load($id);
$object->MoveToCat();
}
}
- $event->status = erSUCCESS;*/
}
/**
- * 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);
- }
- }*/
-
- /**
* Return type clauses for list bulding on front
*
* @param kEvent $event
Index: branches/unlabeled/unlabeled-1.22.2/core/units/categories/categories_event_handler.php
===================================================================
diff -u -r5609 -r5610
--- branches/unlabeled/unlabeled-1.22.2/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 5609)
+++ branches/unlabeled/unlabeled-1.22.2/core/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
Index: branches/unlabeled/unlabeled-1.64.2/core/units/general/cat_event_handler.php
===================================================================
diff -u -r5609 -r5610
--- branches/unlabeled/unlabeled-1.64.2/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5609)
+++ branches/unlabeled/unlabeled-1.64.2/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5610)
@@ -77,74 +77,28 @@
*/
function OnPaste(&$event)
{
- echo 'pasting categories';
- $event->redirect = false; // for debugging
+ $clipboard_data = $event->getEventParam('clipboard_data');
- /*$ids = $this->Application->RecallVar($event->getPrefixSpecial().'_clipboard');
- if ($ids == '') {
- $event->redirect = false;
- return;
+ if (!$clipboard_data['cut'] && !$clipboard_data['copy']) {
+ return false;
}
- $ids_arr = explode(',', $ids);
-
- if ($this->Application->RecallVar($event->getPrefixSpecial().'_clipboard_mode') == 'copy') {
+ if ($clipboard_data['copy']) {
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
-
- if ($ids_arr) {
- $temp->CloneItems($event->Prefix, $event->Special, $ids_arr);
- }
+ $temp->CloneItems($event->Prefix, $event->Special, $clipboard_data['copy']);
}
- else { // mode == cut
+
+ if ($clipboard_data['cut']) {
$object =& $this->Application->recallObject($event->getPrefixSpecial().'.item', $event->Prefix, Array('skip_autoload' => true));
- foreach ($ids_arr as $id) {
+ foreach ($clipboard_data['cut'] as $id) {
$object->Load($id);
$object->MoveToCat();
}
}
- $event->status = erSUCCESS;*/
}
/**
- * 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);
- }
- }*/
-
- /**
* Return type clauses for list bulding on front
*
* @param kEvent $event
Index: branches/unlabeled/unlabeled-1.23.2/kernel/admin_templates/catalog.tpl
===================================================================
diff -u -r5609 -r5610
--- branches/unlabeled/unlabeled-1.23.2/kernel/admin_templates/catalog.tpl (.../catalog.tpl) (revision 5609)
+++ branches/unlabeled/unlabeled-1.23.2/kernel/admin_templates/catalog.tpl (.../catalog.tpl) (revision 5610)
@@ -104,7 +104,7 @@
a_toolbar.AddButton( new ToolBarButton('paste', '', function() {
- $Catalog.submit_event('c', 'OnPaste');
+ $Catalog.submit_event('c', 'OnPasteClipboard');
}
) );
Index: branches/unlabeled/unlabeled-1.22.2/kernel/units/categories/categories_event_handler.php
===================================================================
diff -u -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
Index: branches/unlabeled/unlabeled-1.23.2/core/admin_templates/catalog/catalog.tpl
===================================================================
diff -u -r5609 -r5610
--- branches/unlabeled/unlabeled-1.23.2/core/admin_templates/catalog/catalog.tpl (.../catalog.tpl) (revision 5609)
+++ branches/unlabeled/unlabeled-1.23.2/core/admin_templates/catalog/catalog.tpl (.../catalog.tpl) (revision 5610)
@@ -104,7 +104,7 @@
a_toolbar.AddButton( new ToolBarButton('paste', '', function() {
- $Catalog.submit_event('c', 'OnPaste');
+ $Catalog.submit_event('c', 'OnPasteClipboard');
}
) );