/** * Postprocesses a selected backend layout * * @param integer $pageUid Starting page UID in the rootline (this current page) * @param array $backendLayout The backend layout which was detected from page id * @return NULL|void */ 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 = array('backend_layout.' => array('colCount' => 0, 'rowCount' => 0, 'rows.' => array())); $colPosList = array(); $items = array(); $rowIndex = 0; foreach ($grid['rows'] as $row) { $index = 0; $colCount = 0; $rowKey = $rowIndex + 1 . '.'; $columns = array(); foreach ($row['columns'] as $column) { $key = $index + 1 . '.'; $columns[$key] = array('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, array($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] = array('columns.' => $columns); ++$rowIndex; } unset($backendLayout['config']); $backendLayout['__config'] = $config; $backendLayout['__colPosList'] = $colPosList; $backendLayout['__items'] = $items; }
/** * @param array $row * @return array */ protected function getInheritedConfiguration(array $row) { $tableName = $this->getTableName($row); $tableFieldName = $this->getFieldName($row); $cacheKey = $tableName . $tableFieldName . $row['uid']; if (false === isset(self::$cache[$cacheKey])) { $tree = $this->getInheritanceTree($row); $data = []; foreach ($tree as $branch) { /** @var SubPageProvider $provider */ $provider = $this->pageConfigurationService->resolvePrimaryConfigurationProvider($this->tableName, self::FIELD_NAME_SUB, $branch); $form = $provider->getForm($branch); if (null === $form) { continue; } $fields = $form->getFields(); $values = $provider->getFlexFormValuesSingle($branch); foreach ($fields as $field) { $values = $this->unsetInheritedValues($field, $values); } $data = RecursiveArrayUtility::merge($data, $values); } self::$cache[$cacheKey] = $data; } return self::$cache[$cacheKey]; }
/** * @param array $row * @return array */ protected function getInheritedConfiguration(array $row) { $tableName = $this->getTableName($row); $tableFieldName = $this->getFieldName($row); $cacheKey = $tableName . $tableFieldName . $row['uid']; if (TRUE === empty(self::$cache[$cacheKey])) { $tree = $this->getInheritanceTree($row); $data = array(); foreach ($tree as $branch) { $provider = $this->configurationService->resolvePrimaryConfigurationProvider($this->tableName, self::FIELD_NAME_SUB, $branch); $form = $provider->getForm($branch); if (NULL === $form) { break; } $fields = $form->getFields(); $values = $provider->getFlexFormValuesSingle($branch); foreach ($fields as $field) { $values = $this->unsetInheritedValues($field, $values); } $data = RecursiveArrayUtility::merge($data, $values); } self::$cache[$cacheKey] = $data; } return self::$cache[$cacheKey]; }
/** * @param integer $pageUid Starting page UID in the rootline (this current page) * @return array */ protected function getBackendLayoutConfiguration($pageUid) { try { $record = $this->recordService->getSingle('pages', '*', $pageUid); // Stop processing if no fluidpages template configured in rootline if (NULL === $record) { return array(); } $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 array(); } $paths = $provider->getTemplatePaths($record); if (0 === count($paths)) { $this->configurationService->message('Unable to detect a configuration. If it is not intentional, check that you ' . 'have included the TypoScript for the desired template collection.', GeneralUtility::SYSLOG_SEVERITY_NOTICE); return array(); } $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 array(); } } catch (\Exception $error) { $this->configurationService->debug($error); return array(); } $config = array('colCount' => 0, 'rowCount' => 0, 'rows.' => array()); $rowIndex = 0; foreach ($grid['rows'] as $row) { $index = 0; $colCount = 0; $rowKey = $rowIndex + 1 . '.'; $columns = array(); foreach ($row['columns'] as $column) { $key = $index + 1 . '.'; $columnName = $GLOBALS['LANG']->sL($column['label']); if (TRUE === empty($columnName)) { $columnName = $column['name']; } $columns[$key] = array('name' => $columnName, 'colPos' => $column['colPos'] >= 0 ? $column['colPos'] : $config['colCount']); if ($column['colspan']) { $columns[$key]['colspan'] = $column['colspan']; } if ($column['rowspan']) { $columns[$key]['rowspan'] = $column['rowspan']; } $colCount += $column['colspan'] ? $column['colspan'] : 1; ++$index; } $config['colCount'] = max($config['colCount'], $colCount); $config['rowCount']++; $config['rows.'][$rowKey] = array('columns.' => $columns); ++$rowIndex; } return $config; }
/** * Postprocesses a selected backend layout * * @param integer $pageUid Starting page UID in the rootline (this current page) * @param array $backendLayout The backend layout which was detected from page id * @return NULL|void */ public function postProcessBackendLayout(&$pageUid, &$backendLayout) { try { $record = $this->pageService->getPage($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; } $paths = $provider->getTemplatePaths($record); if (0 === count($paths)) { if (VersionUtility::assertCoreVersionIsAtLeastSixPointZero()) { if (FALSE === (bool) GeneralUtility::_GET('redirected')) { // BUG: TYPO3 6.0 exhibits an odd behavior in some circumstances; reloading the page seems to completely avoid problems $get = GeneralUtility::_GET(); unset($get['id']); $get['redirected'] = 1; $params = GeneralUtility::implodeArrayForUrl('', $get); header('Location: ?id=' . $pageUid . $params); exit; } return NULL; } $this->configurationService->message('Unable to detect a configuration. If it is not intentional, check that you ' . 'have included the TypoScript for the desired template collection.', GeneralUtility::SYSLOG_SEVERITY_NOTICE); 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 (\Exception $error) { $this->configurationService->debug($error); return NULL; } $config = array('backend_layout.' => array('colCount' => 0, 'rowCount' => 0, 'rows.' => array())); $colPosList = array(); $items = array(); $rowIndex = 0; foreach ($grid['rows'] as $row) { $index = 0; $colCount = 0; $rowKey = $rowIndex + 1 . '.'; $columns = array(); foreach ($row['columns'] as $column) { $key = $index + 1 . '.'; $columnName = $GLOBALS['LANG']->sL($column['label']); if (TRUE === empty($columnName)) { $columnName = $column['name']; } $columns[$key] = array('name' => $columnName, '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, array($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] = array('columns.' => $columns); ++$rowIndex; } unset($backendLayout['config']); $backendLayout['__config'] = $config; $backendLayout['__colPosList'] = $colPosList; $backendLayout['__items'] = $items; }