‪TYPO3CMS  10.4
ListController.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Http\Message\ResponseInterface;
21 use Psr\Http\Message\ServerRequestInterface;
26 
32 {
39  public function ‪mainAction(ServerRequestInterface $request): ResponseInterface
40  {
41  $this->‪getLanguageService()->‪includeLLFile('EXT:core/Resources/Private/Language/locallang_wizards.xlf');
42 
43  $parsedBody = $request->getParsedBody();
44  $queryParams = $request->getQueryParams();
45 
46  // Wizard parameters, coming from FormEngine linking to this wizard.
47  $parameters = $parsedBody['P'] ?? $queryParams['P'] ?? null;
48  $id = $parsedBody['id'] ?? $queryParams['id'] ?? null;
49  $table = $parameters['table'] ?? '';
50  $origRow = ‪BackendUtility::getRecord($table, $parameters['uid']);
51  $tsConfig = ‪BackendUtility::getTCEFORM_TSconfig($table, $origRow ?? ['pid' => $parameters['pid']]);
52 
53  if (strpos($parameters['params']['pid'], '###') === 0 && substr($parameters['params']['pid'], -3) === '###') {
54  $keyword = substr($parameters['params']['pid'], 3, -3);
55  if (strpos($keyword, 'PAGE_TSCONFIG_') === 0) {
56  $pid = (int)$tsConfig[$parameters['field']][$keyword];
57  } else {
58  $pid = (int)$tsConfig['_' . $keyword];
59  }
60  } else {
61  $pid = (int)$parameters['params']['pid'];
62  }
63 
64  if ((string)$id !== '') {
65  // If pid is blank
66  $redirectUrl = GeneralUtility::sanitizeLocalUrl($parameters['returnUrl']);
67  } else {
68  // Otherwise, show the list
69  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
70  $normalizedParams = $request->getAttribute('normalizedParams');
71  $requestUri = $normalizedParams->getRequestUri();
72  $urlParameters = [];
73  $urlParameters['id'] = $pid;
74  $urlParameters['table'] = $parameters['params']['table'];
75  $urlParameters['returnUrl'] = !empty($parameters['returnUrl'])
76  ? GeneralUtility::sanitizeLocalUrl($parameters['returnUrl'])
77  : $requestUri;
78  $redirectUrl = (string)$uriBuilder->buildUriFromRoute('web_list', $urlParameters);
79  }
80 
81  return new ‪RedirectResponse($redirectUrl);
82  }
83 }
‪TYPO3\CMS\Backend\Controller\Wizard\AbstractWizardController\getLanguageService
‪LanguageService getLanguageService()
Definition: AbstractWizardController.php:77
‪TYPO3\CMS\Core\Localization\LanguageService\includeLLFile
‪array includeLLFile($fileRef, $setGlobal=null, $mergeLocalOntoDefault=null)
Definition: LanguageService.php:297
‪TYPO3\CMS\Backend\Controller\Wizard\AbstractWizardController
Definition: AbstractWizardController.php:28
‪TYPO3\CMS\Backend\Controller\Wizard
Definition: AbstractWizardController.php:16
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:38
‪TYPO3\CMS\Backend\Controller\Wizard\ListController\mainAction
‪ResponseInterface mainAction(ServerRequestInterface $request)
Definition: ListController.php:39
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:75
‪TYPO3\CMS\Backend\Controller\Wizard\ListController
Definition: ListController.php:32
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecord
‪static array null getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
Definition: BackendUtility.php:95
‪TYPO3\CMS\Core\Http\RedirectResponse
Definition: RedirectResponse.php:28
‪TYPO3\CMS\Backend\Utility\BackendUtility\getTCEFORM_TSconfig
‪static array getTCEFORM_TSconfig($table, $row)
Definition: BackendUtility.php:3096
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46