/** * Overwrites the data structure of a given tt_content::pi_flexform by * by the one matching the gridelements layout. * * @param array $dataStructArray The incoming data structure. This might be the default one. * @param array $conf * @param array $row * @param string $table * @param string $fieldName * * @return void * */ public function getFlexFormDS_postProcessDS(&$dataStructArray, $conf, $row, $table, $fieldName) { if ($table === 'tt_content' && $fieldName === 'pi_flexform' && $row['CType'] === 'gridelements_pi1' && $row['tx_gridelements_backend_layout']) { $this->init($row['pid']); $dataStructArray = GeneralUtility::xml2array($this->layoutSetup->getFlexformConfiguration($row['tx_gridelements_backend_layout'])); } }
/** * Processes the items of the new content element wizard * and inserts necessary default values for items created within a grid * * @param array $wizardItems : The array containing the current status of the wizard item list before rendering * @param \TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController $parentObject : The parent object that triggered this hook * * @return void */ public function manipulateWizardItems(&$wizardItems, &$parentObject) { if (!GeneralUtility::inList($GLOBALS['BE_USER']->groupData['explicit_allowdeny'], 'tt_content:CType:gridelements_pi1:DENY')) { $pageID = $parentObject->id; $this->init($pageID); $container = (int) GeneralUtility::_GP('tx_gridelements_container'); $column = (int) GeneralUtility::_GP('tx_gridelements_columns'); $allowed_GP = GeneralUtility::_GP('tx_gridelements_allowed'); if (!empty($allowed_GP)) { $allowed = array_flip(explode(',', $allowed_GP)); $allowedGridTypes_GP = GeneralUtility::_GP('tx_gridelements_allowed_grid_types'); if (!empty($allowedGridTypes_GP)) { $allowed['gridelements_pi1'] = 1; } $this->removeDisallowedWizardItems($allowed, $wizardItems); } else { $allowed = null; } if (empty($allowed) || isset($allowed['gridelements_pi1'])) { $allowedGridTypes = array_flip(GeneralUtility::trimExplode(',', GeneralUtility::_GP('tx_gridelements_allowed_grid_types'), true)); $excludeLayouts = $this->getExcludeLayouts($container, $parentObject); $gridItems = $this->layoutSetup->getLayoutWizardItems($parentObject->colPos, $excludeLayouts, $allowedGridTypes); $this->addGridItemsToWizard($gridItems, $wizardItems); } $this->addGridValuesToWizardItems($wizardItems, $container, $column); $this->removeEmptyHeadersFromWizard($wizardItems); } }
/** * Checks if a CType is allowed in this particular page or grid column - only this one column defines the allowed CTypes regardless of any parent column * * @param array $items : The items of the current CType list * @param integer $pid : The id of the page we are currhently working on * @param integer $pageColumn : The page column the element is a child of * @param integer $gridContainerId : The ID of the current container * @param integer $gridColumn : The grid column the element is a child of * * @return array|null $backendLayout: An array containing the data of the selected backend layout as well as a parsed version of the layout configuration */ public function checkForAllowedCTypes(&$items, $pid, $pageColumn, $gridContainerId, $gridColumn) { if ((int) $pageColumn >= 0 || (int) $pageColumn === -2) { $column = $pageColumn ? $pageColumn : 0; $backendLayout = $this->getSelectedBackendLayout($pid); } else { $this->init($pid); $column = $gridColumn ? $gridColumn : 0; $gridElement = $this->layoutSetup->cacheCurrentParent($gridContainerId, TRUE); $backendLayout = $this->layoutSetup->getLayoutSetup($gridElement['tx_gridelements_backend_layout']); } if (isset($backendLayout)) { foreach ($items as $key => $item) { if (!(GeneralUtility::inList($backendLayout['columns'][$column], $item[1]) || GeneralUtility::inList($backendLayout['columns'][$column], '*'))) { unset($items[$key]); } } } }
/** * ItemProcFunc for layout items * removes items that are available for grid boxes on the first level only * and items that are excluded for a certain branch or user * * @param array $params : An array containing the items and parameters for the list of items * * @return void */ public function layoutItemsProcFunc(&$params) { $this->init($params['row']['pid']); $layoutSelectItems = $this->layoutSetup->getLayoutSelectItems($params['row']['colPos']); $params['items'] = ArrayUtility::keepItemsInArray($layoutSelectItems, $params['items'], true); }