|
@@ 458-502 (lines=45) @@
|
| 455 |
|
* @throws \Exception |
| 456 |
|
* @return string |
| 457 |
|
*/ |
| 458 |
|
public function copyClipboardAction($target) |
| 459 |
|
{ |
| 460 |
|
|
| 461 |
|
// Retrieve matcher object from clipboard. |
| 462 |
|
$matcher = $this->getClipboardService()->getMatcher(); |
| 463 |
|
|
| 464 |
|
// Fetch objects via the Content Service. |
| 465 |
|
$contentService = $this->getContentService()->findBy($matcher); |
| 466 |
|
|
| 467 |
|
// Compute the label field name of the table. |
| 468 |
|
$tableTitleField = Tca::table()->getLabelField(); |
| 469 |
|
|
| 470 |
|
// Get result object for storing data along the processing. |
| 471 |
|
$result = $this->getJsonResult(); |
| 472 |
|
$result->setNumberOfObjects($contentService->getNumberOfObjects()); |
| 473 |
|
|
| 474 |
|
foreach ($contentService->getObjects() as $object) { |
| 475 |
|
|
| 476 |
|
// Store the first object, so that the "action" message can be more explicit when deleting only one record. |
| 477 |
|
if ($contentService->getNumberOfObjects() === 1) { |
| 478 |
|
$tableTitleValue = $object[$tableTitleField]; |
| 479 |
|
$processedObjectData = array( |
| 480 |
|
'uid' => $object->getUid(), |
| 481 |
|
'name' => $tableTitleValue, |
| 482 |
|
); |
| 483 |
|
$result->setProcessedObject($processedObjectData); |
| 484 |
|
} |
| 485 |
|
|
| 486 |
|
// Work out the object. |
| 487 |
|
ContentRepositoryFactory::getInstance()->copy($object, $target); |
| 488 |
|
|
| 489 |
|
// Get the possible error messages and store them. |
| 490 |
|
$errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
| 491 |
|
$result->addErrorMessages($errorMessages); |
| 492 |
|
} |
| 493 |
|
|
| 494 |
|
// Flush Clipboard if told so. |
| 495 |
|
if (GeneralUtility::_GP('flushClipboard')) { |
| 496 |
|
$this->getClipboardService()->flush(); |
| 497 |
|
} |
| 498 |
|
|
| 499 |
|
// Set the result and render the JSON view. |
| 500 |
|
$this->getJsonView()->setResult($result); |
| 501 |
|
return $this->getJsonView()->render(); |
| 502 |
|
} |
| 503 |
|
|
| 504 |
|
/** |
| 505 |
|
* Retrieve Content objects first according to matching criteria and then "move" them. |
|
@@ 559-603 (lines=45) @@
|
| 556 |
|
* @param string $target |
| 557 |
|
* @return string |
| 558 |
|
*/ |
| 559 |
|
public function moveClipboardAction($target) |
| 560 |
|
{ |
| 561 |
|
|
| 562 |
|
// Retrieve matcher object from clipboard. |
| 563 |
|
$matcher = $this->getClipboardService()->getMatcher(); |
| 564 |
|
|
| 565 |
|
// Fetch objects via the Content Service. |
| 566 |
|
$contentService = $this->getContentService()->findBy($matcher); |
| 567 |
|
|
| 568 |
|
// Compute the label field name of the table. |
| 569 |
|
$tableTitleField = Tca::table()->getLabelField(); |
| 570 |
|
|
| 571 |
|
// Get result object for storing data along the processing. |
| 572 |
|
$result = $this->getJsonResult(); |
| 573 |
|
$result->setNumberOfObjects($contentService->getNumberOfObjects()); |
| 574 |
|
|
| 575 |
|
foreach ($contentService->getObjects() as $object) { |
| 576 |
|
|
| 577 |
|
// Store the first object, so that the "action" message can be more explicit when deleting only one record. |
| 578 |
|
if ($contentService->getNumberOfObjects() === 1) { |
| 579 |
|
$tableTitleValue = $object[$tableTitleField]; |
| 580 |
|
$processedObjectData = array( |
| 581 |
|
'uid' => $object->getUid(), |
| 582 |
|
'name' => $tableTitleValue, |
| 583 |
|
); |
| 584 |
|
$result->setProcessedObject($processedObjectData); |
| 585 |
|
} |
| 586 |
|
|
| 587 |
|
// Work out the object. |
| 588 |
|
ContentRepositoryFactory::getInstance()->move($object, $target); |
| 589 |
|
|
| 590 |
|
// Get the possible error messages and store them. |
| 591 |
|
$errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
| 592 |
|
$result->addErrorMessages($errorMessages); |
| 593 |
|
} |
| 594 |
|
|
| 595 |
|
// Flush Clipboard if told so. |
| 596 |
|
if (GeneralUtility::_GP('flushClipboard')) { |
| 597 |
|
$this->getClipboardService()->flush(); |
| 598 |
|
} |
| 599 |
|
|
| 600 |
|
// Set the result and render the JSON view. |
| 601 |
|
$this->getJsonView()->setResult($result); |
| 602 |
|
return $this->getJsonView()->render(); |
| 603 |
|
} |
| 604 |
|
|
| 605 |
|
/** |
| 606 |
|
* Retrieve Content objects first according to matching criteria and then "localize" them. |