TYPO3  7.6
TcaInlineExpandCollapseState.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\Form\FormDataProvider;
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  // Early return if a parent record has already set this, happens for existing inline children
36  // when opening a parent record.
37  return $result;
38  } elseif (!empty($result['inlineTopMostParentUid']) && !empty($result['inlineTopMostParentTableName'])) {
39  // Happens in inline ajax context, top parent uid and top parent table are set
40  $fullInlineState = unserialize($this->getBackendUser()->uc['inlineView']);
41  if (!is_array($fullInlineState)) {
42  $fullInlineState = [];
43  }
44  $inlineStateForTable = [];
45  if ($result['command'] !== 'new') {
46  $table = $result['inlineTopMostParentTableName'];
47  $uid = $result['inlineTopMostParentUid'];
48  if (!empty($fullInlineState[$table][$uid])) {
49  $inlineStateForTable = $fullInlineState[$table][$uid];
50  }
51  }
52  $result['inlineExpandCollapseStateArray'] = $inlineStateForTable;
53  } else {
54  // Default case for a single record
55  $fullInlineState = unserialize($this->getBackendUser()->uc['inlineView']);
56  if (!is_array($fullInlineState)) {
57  $fullInlineState = [];
58  }
59  $inlineStateForTable = [];
60  if ($result['command'] !== 'new') {
61  $table = $result['tableName'];
62  $uid = $result['databaseRow']['uid'];
63  if (!empty($fullInlineState[$table][$uid])) {
64  $inlineStateForTable = $fullInlineState[$table][$uid];
65  }
66  }
67  $result['inlineExpandCollapseStateArray'] = $inlineStateForTable;
68  }
69 
70  return $result;
71  }
72 
76  protected function getBackendUser()
77  {
78  return $GLOBALS['BE_USER'];
79  }
80 }