‪TYPO3CMS  ‪main
NewContentElementController.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\EventDispatcher\EventDispatcherInterface;
21 use Psr\Http\Message\ResponseInterface;
22 use Psr\Http\Message\ServerRequestInterface;
27 use TYPO3\CMS\Backend\Utility\BackendUtility;
37 
46 #[AsController]
48 {
49  protected int ‪$id = 0;
50  protected int ‪$uid_pid = 0;
51  protected array ‪$pageInfo = [];
52  protected int ‪$sys_language = 0;
53  protected string ‪$returnUrl = '';
54 
58  protected int|null ‪$colPos = null;
59 
60  public function ‪__construct(
61  protected readonly ‪UriBuilder $uriBuilder,
62  protected readonly ‪BackendViewFactory $backendViewFactory,
63  protected readonly EventDispatcherInterface $eventDispatcher,
64  protected readonly ‪DependencyOrderingService $dependencyOrderingService,
65  ) {}
66 
70  public function ‪handleRequest(ServerRequestInterface $request): ResponseInterface
71  {
72  $parsedBody = $request->getParsedBody();
73  $queryParams = $request->getQueryParams();
74 
75  $action = (string)($parsedBody['action'] ?? $queryParams['action'] ?? 'wizard');
76  if (!in_array($action, ['wizard', 'positionMap'], true)) {
77  return new ‪HtmlResponse('Action not allowed', 400);
78  }
79 
80  // Setting internal vars:
81  $this->id = (int)($parsedBody['id'] ?? $queryParams['id'] ?? 0);
82  $this->sys_language = (int)($parsedBody['sys_language_uid'] ?? $queryParams['sys_language_uid'] ?? 0);
83  $this->returnUrl = GeneralUtility::sanitizeLocalUrl($parsedBody['returnUrl'] ?? $queryParams['returnUrl'] ?? '');
84  ‪$colPos = $parsedBody['colPos'] ?? $queryParams['colPos'] ?? null;
85  $this->colPos = ‪$colPos === null ? null : (int)‪$colPos;
86  $this->uid_pid = (int)($parsedBody['uid_pid'] ?? $queryParams['uid_pid'] ?? 0);
87 
88  // Getting the current page and receiving access information
89  $this->pageInfo = BackendUtility::readPageAccess($this->id, $this->‪getBackendUser()->getPagePermsClause(‪Permission::PAGE_SHOW)) ?: [];
90 
91  // Call action and return the response
92  return $this->{$action . 'Action'}($request);
93  }
94 
98  protected function ‪wizardAction(ServerRequestInterface $request): ResponseInterface
99  {
100  if (!$this->id || $this->pageInfo === []) {
101  // No pageId or no access.
102  return new ‪HtmlResponse('No Access');
103  }
104  // Whether position selection must be performed (no colPos was yet defined)
105  $positionSelection = $this->colPos === null;
106 
107  // Get processed and modified wizard items
108  $wizardItems = $this->eventDispatcher->dispatch(
110  $this->‪getWizards(),
111  $this->pageInfo,
112  $this->colPos,
113  $this->sys_language,
114  $this->uid_pid,
115  )
116  )->getWizardItems();
117 
118  $key = 'common';
119  $categories = [];
120  foreach ($wizardItems as $wizardKey => $wizardItem) {
121  // An item is either a header or an item rendered with title/description and icon:
122  if (isset($wizardItem['header'])) {
123  $key = $wizardKey;
124  $categories[$key] = [
125  'identifier' => $key,
126  'label' => $wizardItem['header'] ?: '-',
127  'items' => [],
128  ];
129  } else {
130  // Initialize the view variables for the item
131  $item = [
132  'identifier' => $wizardKey,
133  'icon' => $wizardItem['iconIdentifier'] ?? '',
134  'label' => $wizardItem['title'] ?? '',
135  'description' => $wizardItem['description'] ?? '',
136  ];
137 
138  // Get default values for the wizard item
139  $defaultValues = (array)($wizardItem['defaultValues'] ?? []);
140  if (!$positionSelection) {
141  // In case no position has to be selected, we can just add the target
142  if (($wizardItem['saveAndClose'] ?? false)) {
143  // Go to DataHandler directly instead of FormEngine
144  $item['url'] = (string)$this->uriBuilder->buildUriFromRoute('tce_db', [
145  'data' => [
146  'tt_content' => [
147  ‪StringUtility::getUniqueId('NEW') => array_replace($defaultValues, [
148  'colPos' => $this->colPos,
149  'pid' => $this->uid_pid,
150  'sys_language_uid' => $this->sys_language,
151  ]),
152  ],
153  ],
154  'redirect' => ‪$this->returnUrl,
155  ]);
156  } else {
157  $item['url'] = (string)$this->uriBuilder->buildUriFromRoute('record_edit', [
158  'edit' => [
159  'tt_content' => [
160  $this->uid_pid => 'new',
161  ],
162  ],
163  'returnUrl' => $this->returnUrl,
164  'defVals' => [
165  'tt_content' => array_replace($defaultValues, [
166  'colPos' => $this->colPos,
167  'sys_language_uid' => $this->sys_language,
168  ]),
169  ],
170  ]);
171  }
172  } else {
173  $item['url'] = (string)$this->uriBuilder
174  ->buildUriFromRoute(
175  'new_content_element_wizard',
176  [
177  'action' => 'positionMap',
178  'id' => $this->id,
179  'sys_language_uid' => $this->sys_language,
180  'returnUrl' => $this->returnUrl,
181  ]
182  );
183  $item['requestType'] = 'ajax';
184  $item['defaultValues'] = $defaultValues;
185  $item['saveAndClose'] = (bool)($wizardItem['saveAndClose'] ?? false);
186  }
187  $categories[$key]['items'][] = $item;
188  }
189  }
190 
191  // Unset empty categories
192  foreach ($categories as $key => $category) {
193  if ($category['items'] === []) {
194  ‪unset($categories[$key]);
195  }
196  }
197 
198  $view = $this->backendViewFactory->create($request);
199  $view->assignMultiple([
200  'positionSelection' => $positionSelection,
201  'categoriesJson' => GeneralUtility::jsonEncodeForHtmlAttribute($categories, false),
202  ]);
203  return new ‪HtmlResponse($view->render('NewContentElement/Wizard'));
204  }
205 
209  protected function ‪positionMapAction(ServerRequestInterface $request): ResponseInterface
210  {
211  $posMap = GeneralUtility::makeInstance(ContentCreationPagePositionMap::class);
212  $posMap->cur_sys_language = ‪$this->sys_language;
213  $posMap->defVals = (array)($request->getParsedBody()['defVals'] ?? []);
214  $posMap->saveAndClose = (bool)($request->getParsedBody()['saveAndClose'] ?? false);
215  $posMap->R_URI = ‪$this->returnUrl;
216  $view = $this->backendViewFactory->create($request);
217  $view->assign('posMap', $posMap->printContentElementColumns($this->id));
218  return new ‪HtmlResponse($view->render('NewContentElement/PositionMap'));
219  }
220 
225  protected function ‪getWizards(): array
226  {
227  $wizards = $this->‪loadAvailableWizardsFromContentElements();
228  $pluginWizards = $this->‪loadAvailableWizardsFromPluginSubTypes();
229  $wizards = ‪array_replace_recursive($wizards, $pluginWizards);
230  $newContentElementWizardTsConfig = BackendUtility::getPagesTSconfig($this->id)['mod.']['wizards.']['newContentElement.'] ?? [];
231  $wizardsFromPageTSConfig = $this->migrateCommonGroupToDefault($newContentElementWizardTsConfig['wizardItems.'] ?? []);
232  $wizards = ‪array_replace_recursive($wizards, $wizardsFromPageTSConfig);
233  $wizards = $this->‪removeWizardsByPageTs($wizards, $newContentElementWizardTsConfig);
234  if ($wizards === []) {
235  return [];
236  }
237  $wizardItems = [];
238  $appendWizards = $this->getAppendWizards((array)($wizards['elements.'] ?? []));
239  foreach ($wizards as $groupKey => $wizardGroup) {
240  $wizards[$groupKey] = $this->‪prepareDependencyOrdering($wizards[$groupKey], 'before');
241  $wizards[$groupKey] = $this->‪prepareDependencyOrdering($wizards[$groupKey], 'after');
242  }
243  foreach ($this->dependencyOrderingService->orderByDependencies($wizards) as $groupKey => $wizardGroup) {
244  $groupKey = rtrim($groupKey, '.');
245  $groupItems = [];
246  $appendWizardElements = $appendWizards[$groupKey . '.']['elements.'] ?? null;
247  if (is_array($appendWizardElements)) {
248  $wizardElements = array_merge((array)($wizardGroup['elements.'] ?? []), $appendWizardElements);
249  } else {
250  $wizardElements = $wizardGroup['elements.'] ?? [];
251  }
252  if (is_array($wizardElements)) {
253  foreach ($wizardElements as $itemKey => ‪$itemConf) {
254  $itemKey = rtrim($itemKey, '.');
255  if (‪$itemConf !== []) {
256  $groupItems[$groupKey . '_' . $itemKey] = $this->prepareWizardItem(‪$itemConf);
257  }
258  }
259  }
260  if (!empty($groupItems)) {
261  $wizardItems[$groupKey]['header'] = $this->‪getLanguageService()->sL($wizardGroup['header'] ?? '');
262  $wizardItems = array_merge($wizardItems, $groupItems);
263  }
264  }
265 
266  // Remove elements where preset values are not allowed:
267  return $this->‪removeInvalidWizardItems($wizardItems);
268  }
269 
270  protected function ‪loadAvailableWizardsFromContentElements(): array
271  {
272  return (($typeField = (string)(‪$GLOBALS['TCA']['tt_content']['ctrl']['type'] ?? '')) !== '')
273  ? $this->‪loadAvailableWizards($typeField)
274  : [];
275  }
276 
277  protected function ‪loadAvailableWizardsFromPluginSubTypes(): array
278  {
279  return (($pluginSubtypeValueField = (string)(‪$GLOBALS['TCA']['tt_content']['types']['list']['subtype_value_field'] ?? '')) !== '')
280  ? $this->‪loadAvailableWizards($pluginSubtypeValueField, true)
281  : [];
282  }
283 
284  protected function ‪loadAvailableWizards(string $typeField, bool $isPluginSubType = false): array
285  {
286  $fieldConfig = ‪$GLOBALS['TCA']['tt_content']['columns'][$typeField] ?? [];
287  $items = $fieldConfig['config']['items'] ?? [];
288  $groupedWizardItems = [];
289  foreach ($items as $item) {
290  $selectItem = ‪SelectItem::fromTcaItemArray($item);
291  if ($selectItem->isDivider()) {
292  continue;
293  }
294  $recordType = $selectItem->getValue();
295  $groupIdentifier = $selectItem->getGroup();
296  if (!is_array($groupedWizardItems[$groupIdentifier . '.'] ?? null)) {
297  $groupedWizardItems[$groupIdentifier . '.'] = [
298  'elements.' => [],
299  'header' => $fieldConfig['config']['itemGroups'][$groupIdentifier] ?? $groupIdentifier,
300  ];
301  }
302  $itemDescription = $selectItem->getDescription();
303  $wizardEntry = [
304  'iconIdentifier' => $selectItem->getIcon(),
305  'title' => $selectItem->getLabel(),
306  'description' => $itemDescription['description'] ?? ($itemDescription ?? ''),
307  ];
308  if ($isPluginSubType) {
309  $wizardEntry['defaultValues'] = [
310  'CType' => 'list',
311  'list_type' => $recordType,
312  ];
313  } else {
314  $wizardEntry['defaultValues'] = [
315  'CType' => $recordType,
316  ];
317  }
318  $wizardEntry = ‪array_replace_recursive($wizardEntry, ‪$GLOBALS['TCA']['tt_content']['types'][$recordType]['creationOptions'] ?? []);
319  $groupedWizardItems[$groupIdentifier . '.']['elements.'][$recordType . '.'] = $wizardEntry;
320  }
321  return $groupedWizardItems;
322  }
323 
334  protected function migrateCommonGroupToDefault(array $wizardsFromPageTs): array
335  {
336  if (!array_key_exists('common.', $wizardsFromPageTs)) {
337  // In case "common." is not defined, just return the wizards, which are still defined via Page TSconfig
338  return $wizardsFromPageTs;
339  }
340 
341  // Prepare "removeItems" to be merged
342  if ($wizardsFromPageTs['default.']['elements.']['removeItems'] ?? false) {
343  $wizardsFromPageTs['default.']['removeItems'] = ‪GeneralUtility::trimExplode(',', $wizardsFromPageTs['default.']['elements.']['removeItems'] ?? '', true);
344  } elseif ($wizardsFromPageTs['default.']['removeItems'] ?? false) {
345  $wizardsFromPageTs['default.']['removeItems'] = ‪GeneralUtility::trimExplode(',', $wizardsFromPageTs['default.']['removeItems'], true);
346  }
347 
348  if ($wizardsFromPageTs['common.']['elements.']['removeItems'] ?? false) {
349  $wizardsFromPageTs['common.']['removeItems'] = ‪GeneralUtility::trimExplode(',', $wizardsFromPageTs['common.']['elements.']['removeItems'] ?? '', true);
350  } elseif ($wizardsFromPageTs['common.']['removeItems'] ?? false) {
351  $wizardsFromPageTs['common.']['removeItems'] = ‪GeneralUtility::trimExplode(',', $wizardsFromPageTs['common.']['removeItems'], true);
352  }
353 
354  $defaultItems = array_merge_recursive($wizardsFromPageTs['default.'] ?? [], $wizardsFromPageTs['common.']);
355  ‪unset($wizardsFromPageTs['common.']);
356 
357  if ($defaultItems !== []) {
358  $wizardsFromPageTs['default.'] = $defaultItems;
359  }
360 
361  return $wizardsFromPageTs;
362  }
363 
364  protected function getAppendWizards(array $wizardElements): array
365  {
366  $returnElements = [];
367  foreach ($wizardElements as $key => $wizardItem) {
368  preg_match('/^[a-zA-Z0-9]+_/', $key, $group);
369  $wizardGroup = $group[0] ? substr($group[0], 0, -1) . '.' : $key;
370  $returnElements[$wizardGroup]['elements.'][substr($key, strlen($wizardGroup)) . '.'] = $wizardItem;
371  }
372  return $returnElements;
373  }
374 
375  protected function prepareWizardItem(array ‪$itemConf): array
376  {
377  // Just replace the "known" keys of $itemConf. This way extensions are able to set custom keys, which are not
378  // used by the controller, but might be evaluated by listeners of the ModifyNewContentElementWizardItemsEvent.
380  ‪$itemConf,
381  [
382  'title' => trim($this->‪getLanguageService()->sL(‪$itemConf['title'] ?? '')),
383  'description' => trim($this->‪getLanguageService()->sL(‪$itemConf['description'] ?? '')),
384  'iconIdentifier' => ‪$itemConf['iconIdentifier'] ?? null,
385  'saveAndClose' => (bool)(‪$itemConf['saveAndClose'] ?? false),
386  'defaultValues' => ‪array_replace_recursive(
387  ‪$itemConf['tt_content_defValues'] ?? [],
388  ‪$itemConf['tt_content_defValues.'] ?? [],
389  ‪$itemConf['defaultValues'] ?? []
390  ),
391  ]
392  );
393  ‪unset(‪$itemConf['tt_content_defValues'], ‪$itemConf['tt_content_defValues.']);
394  return ‪$itemConf;
395  }
396 
397  protected function ‪removeWizardsByPageTs(array $wizards, mixed $wizardsItemsPageTs): array
398  {
399  $removeWizardItems = $wizardsItemsPageTs['wizardItems.']['removeItems'] ?? [];
400  if (is_string($removeWizardItems)) {
401  $removeWizardItems = ‪GeneralUtility::trimExplode(',', $removeWizardItems, true);
402  }
403 
404  foreach ($wizards as $key => &$wizard) {
405  // Leave out removeItems etc.
406  if (is_string($wizard)) {
407  ‪unset($wizards[$key]);
408  continue;
409  }
410  if (in_array(rtrim((string)$key, '.'), $removeWizardItems, true)) {
411  ‪unset($wizards[$key]);
412  continue;
413  }
414  $removeWizardElements = $wizardsItemsPageTs['wizardItems.'][$key]['removeItems'] ?? [];
415  if (is_string($removeWizardElements)) {
416  $removeWizardElements = ‪GeneralUtility::trimExplode(',', $removeWizardElements, true);
417  }
418  foreach ($wizard['elements.'] ?? [] as ‪$identifier => $element) {
419  if (in_array(rtrim((string)‪$identifier, '.'), $removeWizardElements, true)) {
420  ‪unset($wizard['elements.'][‪$identifier]);
421  }
422  }
423  }
424 
425  return $wizards;
426  }
427 
433  protected function ‪removeInvalidWizardItems(array $wizardItems): array
434  {
435  $removeItems = [];
436  $keepItems = [];
437  // Get TCEFORM from TSconfig of current page
438  $TCEFORM_TSconfig = BackendUtility::getTCEFORM_TSconfig('tt_content', ['pid' => $this->id]);
439  // Traverse wizard items:
440  foreach ($wizardItems as $key => $cfg) {
441  if (!is_array($cfg['defaultValues'] ?? false)) {
442  continue;
443  }
444  // If defaultValues are defined, check access by traversing all fields with default values:
445  $backendUser = $this->‪getBackendUser();
446  foreach ($cfg['defaultValues'] as $fieldName => $value) {
447  if (!is_array(‪$GLOBALS['TCA']['tt_content']['columns'][$fieldName])) {
448  continue;
449  }
450  // Get information about if the field value is OK:
451  $config = ‪$GLOBALS['TCA']['tt_content']['columns'][$fieldName]['config'] ?? [];
452  $userNotAllowedToAccess = ($config['type'] ?? '') === 'select' && ($config['authMode'] ?? false)
453  && !$backendUser->checkAuthMode('tt_content', $fieldName, $value);
454  // Check removeItems
455  if (!isset($removeItems[$fieldName]) && ($TCEFORM_TSconfig[$fieldName]['removeItems'] ?? false)) {
456  $removeItems[$fieldName] = array_flip(‪GeneralUtility::trimExplode(
457  ',',
458  $TCEFORM_TSconfig[$fieldName]['removeItems'],
459  true
460  ));
461  }
462  // Check keepItems
463  if (!isset($keepItems[$fieldName]) && ($TCEFORM_TSconfig[$fieldName]['keepItems'] ?? false)) {
464  $keepItems[$fieldName] = array_flip(‪GeneralUtility::trimExplode(
465  ',',
466  $TCEFORM_TSconfig[$fieldName]['keepItems'],
467  true
468  ));
469  }
470  $isNotInKeepItems = !empty($keepItems[$fieldName]) && !isset($keepItems[$fieldName][$value]);
471  if ($userNotAllowedToAccess || ($fieldName === 'CType' && (isset($removeItems[$fieldName][$value]) || $isNotInKeepItems))) {
472  // Remove element all together:
473  ‪unset($wizardItems[$key]);
474  break;
475  }
476  // Add the parameter:
477  $wizardItems[$key]['defaultValues'][$fieldName] = $this->‪getLanguageService()->sL($value);
478  }
479  }
480  return $wizardItems;
481  }
482 
486  protected function ‪prepareDependencyOrdering(array $wizardGroup, string $key): array
487  {
488  if (isset($wizardGroup[$key])) {
489  $wizardGroup[$key] = ‪GeneralUtility::trimExplode(',', $wizardGroup[$key]);
490  $wizardGroup[$key] = array_map(static fn(string|int $s): string => $s . '.', $wizardGroup[$key]);
491  }
492  return $wizardGroup;
493  }
494 
496  {
497  return ‪$GLOBALS['LANG'];
498  }
499 
501  {
502  return ‪$GLOBALS['BE_USER'];
503  }
504 }
‪TYPO3\CMS\Backend\Controller\Event\ModifyNewContentElementWizardItemsEvent
Definition: ModifyNewContentElementWizardItemsEvent.php:24
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\removeInvalidWizardItems
‪removeInvalidWizardItems(array $wizardItems)
Definition: NewContentElementController.php:433
‪TYPO3\CMS\Backend\View\BackendViewFactory
Definition: BackendViewFactory.php:35
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\$uid_pid
‪int $uid_pid
Definition: NewContentElementController.php:50
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\prepareDependencyOrdering
‪prepareDependencyOrdering(array $wizardGroup, string $key)
Definition: NewContentElementController.php:486
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\loadAvailableWizardsFromPluginSubTypes
‪loadAvailableWizardsFromPluginSubTypes()
Definition: NewContentElementController.php:277
‪TYPO3\CMS\Backend\Controller\ContentElement
Definition: ElementHistoryController.php:18
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController
Definition: NewContentElementController.php:48
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\positionMapAction
‪positionMapAction(ServerRequestInterface $request)
Definition: NewContentElementController.php:209
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\loadAvailableWizardsFromContentElements
‪loadAvailableWizardsFromContentElements()
Definition: NewContentElementController.php:270
‪TYPO3\CMS\Backend\Tree\View\ContentCreationPagePositionMap
Definition: ContentCreationPagePositionMap.php:33
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:26
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\removeWizardsByPageTs
‪removeWizardsByPageTs(array $wizards, mixed $wizardsItemsPageTs)
Definition: NewContentElementController.php:397
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\getWizards
‪getWizards()
Definition: NewContentElementController.php:225
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\handleRequest
‪handleRequest(ServerRequestInterface $request)
Definition: NewContentElementController.php:70
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\$sys_language
‪int $sys_language
Definition: NewContentElementController.php:52
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\unset
‪array< string, migrateCommonGroupToDefault(array $wizardsFromPageTs):array { if(!array_key_exists( 'common.', $wizardsFromPageTs)) { return $wizardsFromPageTs;} if( $wizardsFromPageTs[ 'default.'][ 'elements.'][ 'removeItems'] ?? false) { $wizardsFromPageTs[ 'default.'][ 'removeItems']=GeneralUtility::trimExplode(',', $wizardsFromPageTs[ 'default.'][ 'elements.'][ 'removeItems'] ?? '', true);} elseif( $wizardsFromPageTs[ 'default.'][ 'removeItems'] ?? false) { $wizardsFromPageTs[ 'default.'][ 'removeItems']=GeneralUtility::trimExplode(',', $wizardsFromPageTs[ 'default.'][ 'removeItems'], true);} if( $wizardsFromPageTs[ 'common.'][ 'elements.'][ 'removeItems'] ?? false) { $wizardsFromPageTs[ 'common.'][ 'removeItems']=GeneralUtility::trimExplode(',', $wizardsFromPageTs[ 'common.'][ 'elements.'][ 'removeItems'] ?? '', true);} elseif( $wizardsFromPageTs[ 'common.'][ 'removeItems'] ?? false) { $wizardsFromPageTs[ 'common.'][ 'removeItems']=GeneralUtility::trimExplode(',', $wizardsFromPageTs[ 'common.'][ 'removeItems'], true);} $defaultItems=array_merge_recursive( $wizardsFromPageTs[ 'default.'] ??[], $wizardsFromPageTs[ 'common.']);unset( $wizardsFromPageTs[ 'common.']);if( $defaultItems !==[]) { $wizardsFromPageTs[ 'default.']=$defaultItems;} return $wizardsFromPageTs;} protected getAppendWizards(array $wizardElements):array { $returnElements=[];foreach( $wizardElements as $key=> $wizardItem) { preg_match('/^[a-zA-Z0-9]+_/', $key, $group);$wizardGroup=$group[0] ? substr( $group[0], 0, -1) . '.' :$key;$returnElements[ $wizardGroup][ 'elements.'][substr( $key, strlen( $wizardGroup)) . '.']=$wizardItem;} return $returnElements;} protected function prepareWizardItem(array $itemConf):array { $itemConf=array_replace_recursive($itemConf,['title'=> trim( $this->getLanguageService() ->sL( $itemConf[ 'title'] ?? '')), 'description'=> trim( $this->getLanguageService() ->sL( $itemConf[ 'description'] ?? '')), 'iconIdentifier'=> $itemConf[ 'iconIdentifier'] ?? null, 'saveAndClose'=>bool)( $itemConf[ 'saveAndClose'] ?? false), 'defaultValues'=> unset($itemConf['tt_content_defValues'], $itemConf['tt_content_defValues.'])
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\wizardAction
‪wizardAction(ServerRequestInterface $request)
Definition: NewContentElementController.php:98
‪TYPO3\CMS\Core\Schema\Struct\SelectItem
Definition: SelectItem.php:21
‪TYPO3\CMS\Core\Schema\Struct\SelectItem\fromTcaItemArray
‪static fromTcaItemArray(array $item, string $type='select')
Definition: SelectItem.php:45
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:44
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\$itemConf
‪return $itemConf
Definition: NewContentElementController.php:394
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\$pageInfo
‪array $pageInfo
Definition: NewContentElementController.php:51
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\$returnUrl
‪string $returnUrl
Definition: NewContentElementController.php:53
‪TYPO3\CMS\Core\Service\DependencyOrderingService
Definition: DependencyOrderingService.php:32
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\loadAvailableWizards
‪loadAvailableWizards(string $typeField, bool $isPluginSubType=false)
Definition: NewContentElementController.php:284
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW
‪const PAGE_SHOW
Definition: Permission.php:35
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\getBackendUser
‪getBackendUser()
Definition: NewContentElementController.php:500
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\array_replace_recursive
‪array< string, migrateCommonGroupToDefault(array $wizardsFromPageTs):array { if(!array_key_exists( 'common.', $wizardsFromPageTs)) { return $wizardsFromPageTs;} if( $wizardsFromPageTs[ 'default.'][ 'elements.'][ 'removeItems'] ?? false) { $wizardsFromPageTs[ 'default.'][ 'removeItems']=GeneralUtility::trimExplode(',', $wizardsFromPageTs[ 'default.'][ 'elements.'][ 'removeItems'] ?? '', true);} elseif( $wizardsFromPageTs[ 'default.'][ 'removeItems'] ?? false) { $wizardsFromPageTs[ 'default.'][ 'removeItems']=GeneralUtility::trimExplode(',', $wizardsFromPageTs[ 'default.'][ 'removeItems'], true);} if( $wizardsFromPageTs[ 'common.'][ 'elements.'][ 'removeItems'] ?? false) { $wizardsFromPageTs[ 'common.'][ 'removeItems']=GeneralUtility::trimExplode(',', $wizardsFromPageTs[ 'common.'][ 'elements.'][ 'removeItems'] ?? '', true);} elseif( $wizardsFromPageTs[ 'common.'][ 'removeItems'] ?? false) { $wizardsFromPageTs[ 'common.'][ 'removeItems']=GeneralUtility::trimExplode(',', $wizardsFromPageTs[ 'common.'][ 'removeItems'], true);} $defaultItems=array_merge_recursive( $wizardsFromPageTs[ 'default.'] ??[], $wizardsFromPageTs[ 'common.']);unset( $wizardsFromPageTs[ 'common.']);if( $defaultItems !==[]) { $wizardsFromPageTs[ 'default.']=$defaultItems;} return $wizardsFromPageTs;} protected function getAppendWizards(array $wizardElements):array { $returnElements=[];foreach( $wizardElements as $key=> $wizardItem) { preg_match('/^[a-zA-Z0-9]+_/', $key, $group);$wizardGroup=$group[0] ? substr( $group[0], 0, -1) . '.' :$key;$returnElements[ $wizardGroup][ 'elements.'][substr( $key, strlen( $wizardGroup)) . '.']=$wizardItem;} return $returnElements;} protected function prepareWizardItem(array $itemConf):array { $itemConf=array_replace_recursive($itemConf,['title'=> trim( $this->getLanguageService() ->sL( $itemConf[ 'title'] ?? '')), 'description'=> trim( $this->getLanguageService() ->sL( $itemConf[ 'description'] ?? '')), 'iconIdentifier'=> $itemConf[ 'iconIdentifier'] ?? null, 'saveAndClose'=>bool)( $itemConf[ 'saveAndClose'] ?? false), 'defaultValues'=> array_replace_recursive( $itemConf['tt_content_defValues'] ??[], $itemConf['tt_content_defValues.'] ??[], $itemConf['defaultValues'] ??[])
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\getLanguageService
‪getLanguageService()
Definition: NewContentElementController.php:495
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\$colPos
‪int null $colPos
Definition: NewContentElementController.php:58
‪TYPO3\CMS\Backend\Attribute\AsController
Definition: AsController.php:25
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\$id
‪int $id
Definition: NewContentElementController.php:49
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:24
‪TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController\__construct
‪__construct(protected readonly UriBuilder $uriBuilder, protected readonly BackendViewFactory $backendViewFactory, protected readonly EventDispatcherInterface $eventDispatcher, protected readonly DependencyOrderingService $dependencyOrderingService,)
Definition: NewContentElementController.php:60
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static list< string > trimExplode(string $delim, string $string, bool $removeEmptyValues=false, int $limit=0)
Definition: GeneralUtility.php:822
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static getUniqueId(string $prefix='')
Definition: StringUtility.php:57
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:28