‪TYPO3CMS  ‪main
TcaInlineExpandCollapseState.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
20 
26 {
32  public function ‪addData(array $result)
33  {
34  if (empty($result['inlineExpandCollapseStateArray'])) {
35  $fullInlineState = json_decode($this->‪getBackendUser()->uc['inlineView'] ?? '', true);
36  if (!is_array($fullInlineState)) {
37  $fullInlineState = [];
38  }
39  $inlineStateForTable = [];
40  if (!empty($result['inlineTopMostParentUid']) && !empty($result['inlineTopMostParentTableName'])) {
41  // Happens in inline ajax context, top parent uid and top parent table are set
42  if ($result['command'] !== 'new') {
43  $table = $result['inlineTopMostParentTableName'];
44  ‪$uid = $result['inlineTopMostParentUid'];
45  if (!empty($fullInlineState[$table][‪$uid])) {
46  $inlineStateForTable = $fullInlineState[$table][‪$uid];
47  }
48  }
49  } else {
50  // Default case for a single record
51  if ($result['command'] !== 'new') {
52  $table = $result['tableName'];
53  ‪$uid = $result['databaseRow']['uid'] ?? 0;
54  if (!empty($fullInlineState[$table][‪$uid])) {
55  $inlineStateForTable = $fullInlineState[$table][‪$uid];
56  }
57  }
58  }
59  $result['inlineExpandCollapseStateArray'] = $inlineStateForTable;
60  }
61 
62  if (!$result['isInlineChildExpanded']) {
63  // If the record is an inline child that is not expanded, it is not necessary to calculate all fields
64  $isExistingRecord = $result['command'] === 'edit';
65  $inlineConfig = $result['inlineParentConfig'];
66  $collapseAll = isset($inlineConfig['appearance']['collapseAll']) && $inlineConfig['appearance']['collapseAll'];
67  $expandAll = isset($inlineConfig['appearance']['collapseAll']) && !$inlineConfig['appearance']['collapseAll'];
68  $expandCollapseStateArray = $result['inlineExpandCollapseStateArray'];
69  $foreignTable = $result['inlineParentConfig']['foreign_table'] ?? null;
70  $isExpandedByUcState = isset($expandCollapseStateArray[$foreignTable])
71  && is_array($expandCollapseStateArray[$foreignTable])
72  && in_array($result['databaseRow']['uid'], $expandCollapseStateArray[$foreignTable]) !== false;
73 
74  if (!$isExistingRecord || ($isExpandedByUcState && !$collapseAll) || $expandAll || $result['isInlineAjaxOpeningContext']) {
75  $result['isInlineChildExpanded'] = true;
76  }
77  }
78 
79  return $result;
80  }
81 
83  {
84  return ‪$GLOBALS['BE_USER'];
85  }
86 }
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaInlineExpandCollapseState\addData
‪array addData(array $result)
Definition: TcaInlineExpandCollapseState.php:32
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaInlineExpandCollapseState\getBackendUser
‪getBackendUser()
Definition: TcaInlineExpandCollapseState.php:82
‪TYPO3\CMS\Backend\Form\FormDataProvider
Definition: AbstractDatabaseRecordProvider.php:16
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Webhooks\Message\$uid
‪identifier readonly int $uid
Definition: PageModificationMessage.php:35
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaInlineExpandCollapseState
Definition: TcaInlineExpandCollapseState.php:26