‪TYPO3CMS  9.5
ListController.php
Go to the documentation of this file.
1 <?php
2 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 
18 use Psr\Http\Message\ResponseInterface;
19 use Psr\Http\Message\ServerRequestInterface;
26 
32 {
34 
40  protected ‪$deprecatedPublicProperties = [
41  'pid' => 'Using $pid of class ListController from the outside is discouraged, as this variable is only used for internal storage.',
42  'P' => 'Using $P of class ListController from the outside is discouraged, as this variable is only used for internal storage.',
43  'table' => 'Using $table of class ListController from the outside is discouraged, as this variable is only used for internal storage.',
44  'id' => 'Using $id of class ListController from the outside is discouraged, as this variable is only used for internal storage.',
45  ];
49  protected ‪$pid;
50 
56  protected ‪$P;
57 
63  protected ‪$table;
64 
70  protected ‪$id;
71 
75  public function ‪__construct()
76  {
77  $this->‪getLanguageService()->‪includeLLFile('EXT:core/Resources/Private/Language/locallang_wizards.xlf');
78 
79  // @deprecated since TYPO3 v9, will be obsolete in TYPO3 v10.0
80  $request = ‪$GLOBALS['TYPO3_REQUEST'];
81  $parsedBody = $request->getParsedBody();
82  $queryParams = $request->getQueryParams();
83 
84  $this->P = $parsedBody['P'] ?? $queryParams['P'] ?? null;
85  $this->table = $parsedBody['table'] ?? $queryParams['table'] ?? null;
86  $this->id = $parsedBody['id'] ?? $queryParams['id'] ?? null;
87  }
88 
96  public function ‪mainAction(ServerRequestInterface $request): ResponseInterface
97  {
98  $this->‪processRequest($request);
99  return new ‪HtmlResponse('');
100  }
101 
107  public function ‪main(): void
108  {
109  trigger_error('ListController->main() will be replaced by protected method processRequest() in TYPO3 v10.0. Do not call from other extension.', E_USER_DEPRECATED);
110  $this->‪processRequest(‪$GLOBALS['TYPO3_REQUEST']);
111  }
117  protected function ‪processRequest(ServerRequestInterface $request): void
118  {
119  // Get this record
120  $origRow = ‪BackendUtility::getRecord($this->P['table'], $this->P['uid']);
121  // Get TSconfig for it.
123  $this->table,
124  is_array($origRow) ? $origRow : ['pid' => $this->P['pid']]
125  );
126  // Set [params][pid]
127  if (strpos($this->P['params']['pid'], '###') === 0 && substr($this->P['params']['pid'], -3) === '###') {
128  $keyword = substr($this->P['params']['pid'], 3, -3);
129  if (strpos($keyword, 'PAGE_TSCONFIG_') === 0) {
130  $this->pid = (int)$TSconfig[$this->P['field']][$keyword];
131  } else {
132  $this->pid = (int)$TSconfig['_' . $keyword];
133  }
134  } else {
135  $this->pid = (int)$this->P['params']['pid'];
136  }
137  // Make redirect:
138  // If pid is blank OR if id is set, then return...
139  if ((string)$this->id !== '') {
140  $redirectUrl = GeneralUtility::sanitizeLocalUrl($this->P['returnUrl']);
141  } else {
143  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
144  $normalizedParams = $request->getAttribute('normalizedParams');
145  $requestUri = $normalizedParams->getRequestUri();
146  // Otherwise, show the list:
147  $urlParameters = [];
148  $urlParameters['id'] = ‪$this->pid;
149  $urlParameters['table'] = $this->P['params']['table'];
150  $urlParameters['returnUrl'] = !empty($this->P['returnUrl'])
151  ? GeneralUtility::sanitizeLocalUrl($this->P['returnUrl'])
152  : $requestUri;
153  $redirectUrl = (string)$uriBuilder->buildUriFromRoute('web_list', $urlParameters);
154  }
155  ‪HttpUtility::redirect($redirectUrl);
156  }
157 }
‪TYPO3\CMS\Core\Localization\LanguageService\includeLLFile
‪mixed includeLLFile($fileRef, $setGlobal=true, $mergeLocalOntoDefault=false)
Definition: LanguageService.php:260
‪TYPO3\CMS\Backend\Controller\Wizard\AbstractWizardController\getLanguageService
‪LanguageService getLanguageService()
Definition: AbstractWizardController.php:77
‪TYPO3\CMS\Backend\Controller\Wizard\AbstractWizardController
Definition: AbstractWizardController.php:28
‪TYPO3\CMS\Backend\Controller\Wizard\ListController\$id
‪string $id
Definition: ListController.php:64
‪TYPO3\CMS\Backend\Controller\Wizard\ListController\$deprecatedPublicProperties
‪array $deprecatedPublicProperties
Definition: ListController.php:38
‪TYPO3\CMS\Backend\Controller\Wizard\ListController\main
‪main()
Definition: ListController.php:101
‪TYPO3\CMS\Backend\Controller\Wizard
Definition: AbstractWizardController.php:2
‪TYPO3\CMS\Backend\Controller\Wizard\ListController\__construct
‪__construct()
Definition: ListController.php:69
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:35
‪TYPO3\CMS\Backend\Controller\Wizard\ListController\mainAction
‪ResponseInterface mainAction(ServerRequestInterface $request)
Definition: ListController.php:90
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:72
‪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:130
‪TYPO3\CMS\Backend\Controller\Wizard\ListController\$P
‪array $P
Definition: ListController.php:52
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Backend\Controller\Wizard\ListController\$table
‪string $table
Definition: ListController.php:58
‪TYPO3\CMS\Core\Utility\HttpUtility
Definition: HttpUtility.php:21
‪TYPO3\CMS\Core\Compatibility\PublicPropertyDeprecationTrait
Definition: PublicPropertyDeprecationTrait.php:66
‪TYPO3\CMS\Backend\Utility\BackendUtility\getTCEFORM_TSconfig
‪static array getTCEFORM_TSconfig($table, $row)
Definition: BackendUtility.php:3482
‪TYPO3\CMS\Backend\Controller\Wizard\ListController\processRequest
‪processRequest(ServerRequestInterface $request)
Definition: ListController.php:111
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Utility\HttpUtility\redirect
‪static redirect($url, $httpStatus=self::HTTP_STATUS_303)
Definition: HttpUtility.php:103
‪TYPO3\CMS\Backend\Controller\Wizard\ListController\$pid
‪int $pid
Definition: ListController.php:46
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:25