TYPO3 CMS  TYPO3_7-6
ExtdirectPageCommands.php
Go to the documentation of this file.
1 <?php
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 
19 
26 {
38  public function moveContentElement($sourceElement, $destinationColumn, $destinationElement)
39  {
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 
73  'Dragdrop',
74  'core',
75  -1,
76  [
77  'action' => $action,
78  'sourceElement' => $sourceElement,
79  'destinationColumn' => $destinationColumn,
80  'destinationElement' => $destinationElement,
81  ]
82  );
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 ['success' => true];
91  }
92 }
static devLog($msg, $extKey, $severity=0, $dataVar=false)
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
$uid
Definition: server.php:38