public function postProcessBackendLayout(&$pageUid, &$backendLayout) { try { $record = $this->workspacesAwareRecordService->getSingle('pages', '*', $pageUid); // Stop processing if no fluidpages template configured in rootline if (null === $record) { return null; } $provider = $this->configurationService->resolvePrimaryConfigurationProvider('pages', 'tx_fed_page_flexform', $record); $action = $provider->getControllerActionFromRecord($record); if (true === empty($action)) { $this->configurationService->message('No template selected - backend layout will not be rendered', GeneralUtility::SYSLOG_SEVERITY_INFO); return null; } $grid = $provider->getGrid($record)->build(); if (false === is_array($grid) || 0 === count($grid['rows'])) { // no grid is defined; we use the "raw" BE layout as a default behavior $this->configurationService->message('The selected page template does not contain a grid but the template is itself valid.'); return null; } } catch (\RuntimeException $error) { $this->configurationService->debug($error); return null; } $config = ['backend_layout.' => ['colCount' => 0, 'rowCount' => 0, 'rows.' => []]]; $colPosList = []; $items = []; $rowIndex = 0; foreach ($grid['rows'] as $row) { $index = 0; $colCount = 0; $rowKey = $rowIndex + 1 . '.'; $columns = []; foreach ($row['columns'] as $column) { $key = $index + 1 . '.'; $columns[$key] = ['name' => $column['label'], 'colPos' => $column['colPos'] >= 0 ? $column['colPos'] : $config['backend_layout.']['colCount']]; if ($column['colspan']) { $columns[$key]['colspan'] = $column['colspan']; } if ($column['rowspan']) { $columns[$key]['rowspan'] = $column['rowspan']; } array_push($colPosList, $columns[$key]['colPos']); array_push($items, [$columns[$key]['name'], $columns[$key]['colPos'], null]); $colCount += $column['colspan'] ? $column['colspan'] : 1; ++$index; } $config['backend_layout.']['colCount'] = max($config['backend_layout.']['colCount'], $colCount); $config['backend_layout.']['rowCount']++; $config['backend_layout.']['rows.'][$rowKey] = ['columns.' => $columns]; ++$rowIndex; } unset($backendLayout['config']); $backendLayout['__config'] = $config; $backendLayout['__colPosList'] = $colPosList; $backendLayout['__items'] = $items; }
/** * Gets the selected backend layout * * @param integer $id * @return array|NULL $backendLayout */ public function getSelectedBackendLayout($id) { $this->backendLayout->preProcessBackendLayoutPageUid($id); $backendLayout = parent::getSelectedBackendLayout($id); $this->backendLayout->postProcessBackendLayout($id, $backendLayout); return array('__config' => $backendLayout['__config'], '__items' => $backendLayout['__items'], '__colPosList' => $backendLayout['__colPosList']); }