[CLEANUP] EXT:backend/Classes/Wizard/*.php
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Controller / Wizard / ListController.php
1 <?php
2 namespace TYPO3\CMS\Backend\Controller\Wizard;
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\Backend\Utility\BackendUtility;
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19
20 /**
21 * Script Class for redirecting the user to the Web > List module if a wizard-link has been clicked in FormEngine
22 *
23 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
24 */
25 class ListController extends AbstractWizardController {
26
27 /**
28 * @var int
29 */
30 public $pid;
31
32 /**
33 * Wizard parameters, coming from FormEngine linking to the wizard.
34 *
35 * @var array
36 */
37 public $P;
38
39 /**
40 * Table to show, if none, then all tables are listed in list module.
41 *
42 * @var string
43 */
44 public $table;
45
46 /**
47 * Page id to list.
48 *
49 * @var string
50 */
51 public $id;
52
53 /**
54 * Initialization of the class, setting GPvars.
55 */
56 public function __construct() {
57 $this->getLanguageService()->includeLLFile('EXT:lang/locallang_wizards.xlf');
58 $GLOBALS['SOBE'] = $this;
59 $this->P = GeneralUtility::_GP('P');
60 $this->table = GeneralUtility::_GP('table');
61 $this->id = GeneralUtility::_GP('id');
62 }
63
64 /**
65 * Main function
66 * Will issue a location-header, redirecting either BACK or to a new FormEngine instance...
67 *
68 * @return void
69 */
70 public function main() {
71 // Get this record
72 $origRow = BackendUtility::getRecord($this->P['table'], $this->P['uid']);
73 // Get TSconfig for it.
74 $TSconfig = BackendUtility::getTCEFORM_TSconfig($this->table, is_array($origRow) ? $origRow : array('pid' => $this->P['pid']));
75 // Set [params][pid]
76 if (substr($this->P['params']['pid'], 0, 3) === '###' && substr($this->P['params']['pid'], -3) === '###') {
77 $keyword = substr($this->P['params']['pid'], 3, -3);
78 if (strpos($keyword, 'PAGE_TSCONFIG_') === 0) {
79 $this->pid = (int)$TSconfig[$this->P['field']][$keyword];
80 } else {
81 $this->pid = (int)$TSconfig['_' . $keyword];
82 }
83 } else {
84 $this->pid = (int)$this->P['params']['pid'];
85 }
86 // Make redirect:
87 // If pid is blank OR if id is set, then return...
88 if ((string)$this->id !== '') {
89 $redirectUrl = GeneralUtility::sanitizeLocalUrl($this->P['returnUrl']);
90 } else {
91 // Otherwise, show the list:
92 $urlParameters = array();
93 $urlParameters['id'] = $this->pid;
94 $urlParameters['table'] = $this->P['params']['table'];
95 $urlParameters['returnUrl'] = GeneralUtility::getIndpEnv('REQUEST_URI');
96 $redirectUrl = BackendUtility::getModuleUrl('web_list', $urlParameters);
97 }
98 \TYPO3\CMS\Core\Utility\HttpUtility::redirect($redirectUrl);
99 }
100
101 }