TYPO3 CMS  TYPO3_7-6
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  $fullInlineState = unserialize($this->getBackendUser()->uc['inlineView']);
38  if (!is_array($fullInlineState)) {
39  $fullInlineState = [];
40  }
41  $inlineStateForTable = [];
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  $result['inlineExpandCollapseStateArray'] = $inlineStateForTable;
50  } else {
51  // Default case for a single record
52  $fullInlineState = unserialize($this->getBackendUser()->uc['inlineView']);
53  if (!is_array($fullInlineState)) {
54  $fullInlineState = [];
55  }
56  $inlineStateForTable = [];
57  if ($result['command'] !== 'new') {
58  $table = $result['tableName'];
59  $uid = $result['databaseRow']['uid'];
60  if (!empty($fullInlineState[$table][$uid])) {
61  $inlineStateForTable = $fullInlineState[$table][$uid];
62  }
63  }
64  $result['inlineExpandCollapseStateArray'] = $inlineStateForTable;
65  }
66  }
67 
68  if (!$result['isInlineChildExpanded']) {
69  // If the record is an inline child that is not expanded, it is not necessary to calculate all fields
70  $isExistingRecord = $result['command'] === 'edit';
71  $inlineConfig = $result['inlineParentConfig'];
72  $collapseAll = isset($inlineConfig['appearance']['collapseAll']) && $inlineConfig['appearance']['collapseAll'];
73  $expandAll = isset($inlineConfig['appearance']['collapseAll']) && !$inlineConfig['appearance']['collapseAll'];
74  $expandCollapseStateArray = $result['inlineExpandCollapseStateArray'];
75  $foreignTable = $result['inlineParentConfig']['foreign_table'];
76  $isExpandedByUcState = isset($expandCollapseStateArray[$foreignTable])
77  && is_array($expandCollapseStateArray[$foreignTable])
78  && in_array($result['databaseRow']['uid'], $expandCollapseStateArray[$foreignTable]) !== false;
79 
80  if (!$isExistingRecord || ($isExpandedByUcState && !$collapseAll) || $expandAll || $result['isInlineAjaxOpeningContext']) {
81  $result['isInlineChildExpanded'] = true;
82  }
83  }
84 
85  return $result;
86  }
87 
91  protected function getBackendUser()
92  {
93  return $GLOBALS['BE_USER'];
94  }
95 }
$uid
Definition: server.php:38
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']