fbe111d687a1e7072854237ae52dace3d3616dd6
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / View / PageLayout / Extdirect / ExtdirectPageCommands.php
1 <?php
2 namespace TYPO3\CMS\Backend\View\PageLayout\ExtDirect;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Utility\GeneralUtility;
18 use TYPO3\CMS\Core\Utility\MathUtility;
19
20 /**
21 * Commands for the Page module
22 * @deprecated since TYPO3 CMS 7, this file will be removed in TYPO3 CMS 8, as Drag&Drop does this
23 * logic now directly and calls DataHandler via AJAX directly.
24 */
25 class ExtdirectPageCommands
26 {
27 /**
28 * Move content element to a position and/or column.
29 *
30 * Function is called from the Page module javascript.
31 *
32 * @param int $sourceElement Id attribute of content element which must be moved
33 * @param string $destinationColumn Column to move the content element to
34 * @param int $destinationElement Id attribute of the element it was dropped on
35 * @return array
36 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
37 */
38 public function moveContentElement($sourceElement, $destinationColumn, $destinationElement)
39 {
40 GeneralUtility::logDeprecatedFunction();
41 $moveElementUid = 0;
42 $afterElementUid = -1;
43 $targetColumn = 0;
44 $targetPage = 0;
45 list($_, $table, $uid) = GeneralUtility::trimExplode('-', $sourceElement);
46 if ($table === 'tt_content' && MathUtility::canBeInterpretedAsInteger($uid)) {
47 $moveElementUid = (int)$uid;
48 }
49 list($_, $table, $uid) = GeneralUtility::trimExplode('-', $destinationElement);
50 if ($table === 'tt_content' && MathUtility::canBeInterpretedAsInteger($uid)) {
51 $afterElementUid = (int)$uid;
52 } else {
53 // it's dropped in an empty column
54 $afterElementUid = -1;
55 }
56 list($prefix, $column, $prefix2, $page, $_) = GeneralUtility::trimExplode('-', $destinationColumn);
57 if ($prefix === 'colpos' && MathUtility::canBeInterpretedAsInteger($column) &&
58 $prefix2 === 'page' && MathUtility::canBeInterpretedAsInteger($page)
59 ) {
60 $targetColumn = (int)$column;
61 $targetPage = (int)$page;
62 }
63 // move to empty column
64 if ($afterElementUid === -1) {
65 $action['cmd']['tt_content'][$moveElementUid]['move'] = $targetPage;
66 } else {
67 $action['cmd']['tt_content'][$moveElementUid]['move'] = -$afterElementUid;
68 }
69
70 $action['data']['tt_content'][$moveElementUid]['colPos'] = $targetColumn;
71
72 GeneralUtility::devLog(
73 'Dragdrop',
74 'core',
75 -1,
76 array(
77 'action' => $action,
78 'sourceElement' => $sourceElement,
79 'destinationColumn' => $destinationColumn,
80 'destinationElement' => $destinationElement,
81 )
82 );
83 /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
84 $tce = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
85 $tce->stripslashes_values = 0;
86 $tce->start($action['data'], $action['cmd']);
87 $tce->process_datamap();
88 $tce->process_cmdmap();
89
90 return array('success' => true);
91 }
92 }