예제 #1
0
 /**
  * Save the expanded/collapsed state of a child record in the BE_USER->uc.
  *
  * @param string $expand Whether this record is expanded.
  * @param string $collapse Whether this record is collapsed.
  * @return void
  */
 protected function setInlineExpandedCollapsedState($expand, $collapse)
 {
     $backendUser = $this->getBackendUserAuthentication();
     // The current table - for this table we should add/import records
     $currentTable = $this->inlineStackProcessor->getUnstableStructure();
     $currentTable = $currentTable['table'];
     // The top parent table - this table embeds the current table
     $top = $this->inlineStackProcessor->getStructureLevel(0);
     $topTable = $top['table'];
     $topUid = $top['uid'];
     $inlineView = $this->getInlineExpandCollapseStateArray();
     // Only do some action if the top record and the current record were saved before
     if (MathUtility::canBeInterpretedAsInteger($topUid)) {
         $expandUids = GeneralUtility::trimExplode(',', $expand);
         $collapseUids = GeneralUtility::trimExplode(',', $collapse);
         // Set records to be expanded
         foreach ($expandUids as $uid) {
             $inlineView[$topTable][$topUid][$currentTable][] = $uid;
         }
         // Set records to be collapsed
         foreach ($collapseUids as $uid) {
             $inlineView[$topTable][$topUid][$currentTable] = $this->removeFromArray($uid, $inlineView[$topTable][$topUid][$currentTable]);
         }
         // Save states back to database
         if (is_array($inlineView[$topTable][$topUid][$currentTable])) {
             $inlineView[$topTable][$topUid][$currentTable] = array_unique($inlineView[$topTable][$topUid][$currentTable]);
             $backendUser->uc['inlineView'] = serialize($inlineView);
             $backendUser->writeUC();
         }
     }
 }