49 trigger_error(__CLASS__ .
' will be removed in TYPO3 v10.0. Functionality has been moved to EXT:feedit, FrontendBackendUserAuthentication and ContentObjectRenderer.', E_USER_DEPRECATED);
57 $this->TSFE_EDIT = GeneralUtility::_GP(
'TSFE_EDIT');
78 public function displayEditPanel($content, array $conf, $currentRecord, array $dataArray)
80 if ($conf[
'newRecordFromTable']) {
81 $currentRecord = $conf[
'newRecordFromTable'] .
':NEW';
82 $conf[
'allow'] =
'new';
83 $checkEditAccessInternals =
false;
85 $checkEditAccessInternals =
true;
87 list($table, $uid) = explode(
':', $currentRecord);
89 $newRecordPid = (int)$conf[
'newRecordInPid'];
92 if ($table ===
'pages') {
95 if ($conf[
'newRecordFromTable']) {
98 $newUid = $newRecordPid;
106 $editClass =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'typo3/classes/class.frontendedit.php'][
'edit'];
108 $edit = GeneralUtility::makeInstance($editClass);
110 $content = $edit->editPanel($content, $conf, $currentRecord, $dataArray, $table, $allowedActions, $newUid, $this->
getHiddenFields($dataArray));
128 public function displayEditIcons($content, $params, array $conf = [], $currentRecord =
'', array $dataArray = [], $addUrlParamStr =
'')
131 list($currentRecordTable, $currentRecordUID) = explode(
':', $currentRecord);
132 list($fieldList, $table) = array_reverse(GeneralUtility::trimExplode(
':', $params,
true));
135 $table = $currentRecordTable;
136 } elseif ($table != $currentRecordTable) {
140 $editUid = $dataArray[
'_LOCALIZED_UID'] ?: $currentRecordUID;
142 if (!array_key_exists(
'allow', $conf)) {
143 $conf[
'allow'] =
'edit';
146 $editClass =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'typo3/classes/class.frontendedit.php'][
'edit'];
148 $edit = GeneralUtility::makeInstance($editClass);
149 $content = $edit->editIcons($content, $params, $conf, $currentRecord, $dataArray, $addUrlParamStr, $table, $editUid, $fieldList);
167 if (is_array($this->TSFE_EDIT)) {
168 if ($this->TSFE_EDIT[
'cancel']) {
169 unset($this->TSFE_EDIT[
'cmd']);
171 $cmd = (string)$this->TSFE_EDIT[
'cmd'];
172 if (($cmd !==
'edit' || is_array($this->TSFE_EDIT[
'data']) && ($this->TSFE_EDIT[
'doSave'] || $this->TSFE_EDIT[
'update'] || $this->TSFE_EDIT[
'update_close'])) && $cmd !==
'new') {
188 if (is_array($this->TSFE_EDIT)) {
189 $cmd = (string)$this->TSFE_EDIT[
'cmd'];
190 if ($cmd ===
'edit' || $cmd ===
'new') {
205 list($table, $uid) = explode(
':', $this->TSFE_EDIT[
'record']);
207 $cmd = $this->TSFE_EDIT[
'cmd'];
209 if (($this->TSFE_EDIT[
'doSave'] || $this->TSFE_EDIT[
'update'] || $this->TSFE_EDIT[
'update_close']) && is_array($this->TSFE_EDIT[
'data'])) {
212 if ($cmd ===
'save' || $cmd && $table && $uid && isset(
$GLOBALS[
'TCA'][$table])) {
215 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tsfebeuserauth.php'][
'extEditAction'] ?? [] as $_funcRef) {
216 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
219 $cmdAction =
'do' . ucwords($cmd);
220 if (is_callable([$this, $cmdAction])) {
221 $this->{$cmdAction}($table, $uid);
223 throw new \UnexpectedValueException(
'The specified frontend edit command (' . $cmd .
') is not valid.', 1225818120);
234 public function doHide($table, $uid)
236 $hideField =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'disabled'];
239 $recData[$table][$uid][$hideField] = 1;
240 $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
241 $dataHandler->start($recData, []);
242 $dataHandler->process_datamap();
254 $hideField =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'disabled'];
257 $recData[$table][$uid][$hideField] = 0;
258 $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
259 $dataHandler->start($recData, []);
260 $dataHandler->process_datamap();
270 public function doUp($table, $uid)
272 $this->
move($table, $uid,
'up');
281 public function doDown($table, $uid)
283 $this->
move($table, $uid,
'down');
294 $afterUID = $this->TSFE_EDIT[
'moveAfter'];
295 $this->
move($table, $uid,
'', $afterUID);
306 protected function move($table, $uid, $direction =
'', $afterUID = 0)
308 $dataHandlerCommands = [];
309 $sortField =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'];
313 if (isset(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'copyAfterDuplFields'])) {
314 $copyAfterDuplicateFields = GeneralUtility::trimExplode(
',',
$GLOBALS[
'TCA'][$table][
'ctrl'][
'copyAfterDuplFields'],
true);
316 $copyAfterDuplicateFields = [];
319 $fields = $copyAfterDuplicateFields;
325 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
326 ->getQueryBuilderForTable($table);
327 $queryBuilder->getRestrictions()->removeAll();
329 $currentRecord = $queryBuilder
332 ->where($queryBuilder->expr()->eq(
334 $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
339 if (is_array($currentRecord)) {
342 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
343 ->getQueryBuilderForTable($table);
346 ->select(
'uid',
'pid')
348 ->where($queryBuilder->expr()->eq(
350 $queryBuilder->createNamedParameter($currentRecord[
'pid'], \PDO::PARAM_INT)
356 $queryBuilder->getRestrictions()
357 ->removeByType(StartTimeRestriction::class)
358 ->removeByType(EndTimeRestriction::class)
359 ->removeByType(HiddenRestriction::class)
360 ->removeByType(FrontendGroupRestriction::class);
363 if (!empty($copyAfterDuplicateFields)) {
364 foreach ($copyAfterDuplicateFields as $fieldName) {
365 $queryBuilder->andWhere($queryBuilder->expr()->eq(
367 $queryBuilder->createNamedParameter($currentRecord[$fieldName], \PDO::PARAM_STR)
371 if (!empty($direction)) {
372 if ($direction ===
'up') {
373 $queryBuilder->andWhere(
374 $queryBuilder->expr()->lt(
376 $queryBuilder->createNamedParameter($currentRecord[$sortField], \PDO::PARAM_INT)
379 $queryBuilder->orderBy($sortField,
'DESC');
381 $queryBuilder->andWhere(
382 $queryBuilder->expr()->gt(
384 $queryBuilder->createNamedParameter($currentRecord[$sortField], \PDO::PARAM_INT)
387 $queryBuilder->orderBy($sortField,
'ASC');
391 $result = $queryBuilder->execute();
392 if ($recordBefore = $result->fetch()) {
394 $dataHandlerCommands[$table][$uid][
'move'] = -$afterUID;
395 } elseif ($direction ===
'down') {
396 $dataHandlerCommands[$table][$uid][
'move'] = -$recordBefore[
'uid'];
397 } elseif ($recordAfter = $result->fetch()) {
399 $dataHandlerCommands[$table][$uid][
'move'] = -$recordAfter[
'uid'];
402 $dataHandlerCommands[$table][$uid][
'move'] = $currentRecord[
'pid'];
404 } elseif ($direction ===
'up') {
405 $dataHandlerCommands[$table][$uid][
'move'] = $currentRecord[
'pid'];
410 if (!empty($dataHandlerCommands)) {
411 $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
412 $dataHandler->start([], $dataHandlerCommands);
413 $dataHandler->process_cmdmap();
426 $cmdData[$table][$uid][
'delete'] = 1;
427 if (!empty($cmdData)) {
428 $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
429 $dataHandler->start([], $cmdData);
430 $dataHandler->process_cmdmap();
440 public function doSave($table, $uid)
442 $data = $this->TSFE_EDIT[
'data'];
444 $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
445 $dataHandler->start($data, []);
446 $dataHandler->process_uploads($_FILES);
447 $dataHandler->process_datamap();
449 $newUID = $dataHandler->substNEWwithIDs[
'NEW'];
451 $this->TSFE_EDIT[
'newUID'] = $newUID;
475 public function doClose($table, $uid)
491 $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect(
'language');
492 if ($table ===
'pages') {
493 $lang = $languageAspect->getId();
494 } elseif ($table ===
'tt_content') {
495 $lang = $languageAspect->getContentId();
496 } elseif (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']) {
497 $lang = $currentRecord[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']];
513 protected function allowedToEdit($table, array $dataArray, array $conf, $checkEditAccessInternals =
true)
517 if ($checkEditAccessInternals) {
520 $editAccessInternals =
true;
522 if ($editAccessInternals) {
523 if ($table ===
'pages') {
534 $types = GeneralUtility::trimExplode(
',', strtolower($conf[
'allow']),
true);
535 $allow = array_flip($types);
537 if ($table ===
'pages') {
540 if (!empty($allow)) {
563 $types = GeneralUtility::trimExplode(
',', strtolower($conf[
'allow']),
true);
564 $allow = array_flip($types);
568 $types = GeneralUtility::trimExplode(
',', strtolower($conf[
'allow']),
true);
569 $allow = array_flip($types);
571 if ($table ===
'pages') {
574 unset($allow[
'move']);
575 unset($allow[
'hide']);
576 unset($allow[
'delete']);
579 unset($allow[
'edit']);
580 unset($allow[
'move']);
581 unset($allow[
'hide']);
584 unset($allow[
'delete']);
587 unset($allow[
'new']);
621 protected function getBackendUser(): ?FrontendBackendUserAuthentication
623 return $GLOBALS[
'BE_USER'] instanceof FrontendBackendUserAuthentication ?
$GLOBALS[
'BE_USER'] :
null;