‪TYPO3CMS  9.5
TcaInlineExpandCollapseState.php
Go to the documentation of this file.
1 <?php
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 
19 
25 {
32  public function ‪addData(array $result)
33  {
34  if (empty($result['inlineExpandCollapseStateArray'])) {
35  if (!empty($result['inlineTopMostParentUid']) && !empty($result['inlineTopMostParentTableName'])) {
36  // Happens in inline ajax context, top parent uid and top parent table are set
37  if (isset($this->‪getBackendUser()->uc['inlineView'])) {
38  $fullInlineState = unserialize($this->‪getBackendUser()->uc['inlineView'], ['allowed_classes' => false]);
39  if (!is_array($fullInlineState)) {
40  $fullInlineState = [];
41  }
42  } else {
43  $fullInlineState = [];
44  }
45  $inlineStateForTable = [];
46  if ($result['command'] !== 'new') {
47  $table = $result['inlineTopMostParentTableName'];
48  $uid = $result['inlineTopMostParentUid'];
49  if (!empty($fullInlineState[$table][$uid])) {
50  $inlineStateForTable = $fullInlineState[$table][$uid];
51  }
52  }
53  $result['inlineExpandCollapseStateArray'] = $inlineStateForTable;
54  } else {
55  // Default case for a single record
56  $fullInlineState = !empty($this->‪getBackendUser()->uc['inlineView']) ? unserialize($this->‪getBackendUser()->uc['inlineView'], ['allowed_classes' => false]) : [];
57  if (!is_array($fullInlineState)) {
58  $fullInlineState = [];
59  }
60  $inlineStateForTable = [];
61  if ($result['command'] !== 'new') {
62  $table = $result['tableName'];
63  $uid = $result['databaseRow']['uid'];
64  if (!empty($fullInlineState[$table][$uid])) {
65  $inlineStateForTable = $fullInlineState[$table][$uid];
66  }
67  }
68  $result['inlineExpandCollapseStateArray'] = $inlineStateForTable;
69  }
70  }
71 
72  if (!$result['isInlineChildExpanded']) {
73  // If the record is an inline child that is not expanded, it is not necessary to calculate all fields
74  $isExistingRecord = $result['command'] === 'edit';
75  $inlineConfig = $result['inlineParentConfig'];
76  $collapseAll = isset($inlineConfig['appearance']['collapseAll']) && $inlineConfig['appearance']['collapseAll'];
77  $expandAll = isset($inlineConfig['appearance']['collapseAll']) && !$inlineConfig['appearance']['collapseAll'];
78  $expandCollapseStateArray = $result['inlineExpandCollapseStateArray'];
79  $foreignTable = $result['inlineParentConfig']['foreign_table'];
80  $isExpandedByUcState = isset($expandCollapseStateArray[$foreignTable])
81  && is_array($expandCollapseStateArray[$foreignTable])
82  && in_array($result['databaseRow']['uid'], $expandCollapseStateArray[$foreignTable]) !== false;
83 
84  if (!$isExistingRecord || ($isExpandedByUcState && !$collapseAll) || $expandAll || $result['isInlineAjaxOpeningContext']) {
85  $result['isInlineChildExpanded'] = true;
86  }
87  }
88 
89  return $result;
90  }
91 
95  protected function ‪getBackendUser()
96  {
97  return ‪$GLOBALS['BE_USER'];
98  }
99 }
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaInlineExpandCollapseState\addData
‪array addData(array $result)
Definition: TcaInlineExpandCollapseState.php:32
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪TYPO3\CMS\Backend\Form\FormDataProvider
Definition: AbstractDatabaseRecordProvider.php:2
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:22
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaInlineExpandCollapseState\getBackendUser
‪BackendUserAuthentication getBackendUser()
Definition: TcaInlineExpandCollapseState.php:95
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaInlineExpandCollapseState
Definition: TcaInlineExpandCollapseState.php:25