/** * Collects the items for a select field by reading the configured * select items from the configuration and / or by collecting them * from a foreign table. * * @param string $table The table name of the record * @param string $fieldName The select field name * @param array $row The record data array where the value(s) for the field can be found * @param array $PA An array with additional configuration options. * @return array */ public static function getSelectItems($table, $fieldName, array $row, array $PA) { $config = $PA['fieldConf']['config']; // Getting the selector box items from the system $selectItems = FormEngineUtility::addSelectOptionsToItemArray(FormEngineUtility::initItemArray($PA['fieldConf']), $PA['fieldConf'], FormEngineUtility::getTSconfigForTableRow($table, $row), $fieldName); // Possibly filter some items: $selectItems = ArrayUtility::keepItemsInArray($selectItems, $PA['fieldTSConfig']['keepItems'], function ($value) { return $value[1]; }); // Possibly add some items: $selectItems = FormEngineUtility::addItems($selectItems, $PA['fieldTSConfig']['addItems.']); // Process items by a user function: if (isset($config['itemsProcFunc']) && $config['itemsProcFunc']) { $dataPreprocessor = GeneralUtility::makeInstance(DataPreprocessor::class); $selectItems = $dataPreprocessor->procItems($selectItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $fieldName); } // Possibly remove some items: $removeItems = GeneralUtility::trimExplode(',', $PA['fieldTSConfig']['removeItems'], TRUE); foreach ($selectItems as $selectItemIndex => $selectItem) { // Checking languages and authMode: $languageDeny = FALSE; $beUserAuth = static::getBackendUserAuthentication(); if (!empty($GLOBALS['TCA'][$table]['ctrl']['languageField']) && $GLOBALS['TCA'][$table]['ctrl']['languageField'] === $fieldName && !$beUserAuth->checkLanguageAccess($selectItem[1])) { $languageDeny = TRUE; } $authModeDeny = FALSE; if ($config['type'] === 'select' && $config['authMode'] && !$beUserAuth->checkAuthMode($table, $fieldName, $selectItem[1], $config['authMode'])) { $authModeDeny = TRUE; } if (in_array($selectItem[1], $removeItems) || $languageDeny || $authModeDeny) { unset($selectItems[$selectItemIndex]); } elseif (isset($PA['fieldTSConfig']['altLabels.'][$selectItem[1]])) { $selectItems[$selectItemIndex][0] = htmlspecialchars(static::getLanguageService()->sL($PA['fieldTSConfig']['altLabels.'][$selectItem[1]])); } // Removing doktypes with no access: if (($table === 'pages' || $table === 'pages_language_overlay') && $fieldName === 'doktype') { if (!($beUserAuth->isAdmin() || GeneralUtility::inList($beUserAuth->groupData['pagetypes_select'], $selectItem[1]))) { unset($selectItems[$selectItemIndex]); } } } return $selectItems; }
/** * Rendering wizards for form fields. * * @param array $itemKinds Array with the real item in the first value, and an alternative item in the second value. * @param array $wizConf The "wizard" key from the config array for the field (from TCA) * @param string $table Table name * @param array $row The record array * @param string $field The field name * @param array $PA Additional configuration array. * @param string $itemName The field name * @param array $specConf Special configuration if available. * @param bool $RTE Whether the RTE could have been loaded. * @return string The new item value. */ protected function renderWizards($itemKinds, $wizConf, $table, $row, $field, $PA, $itemName, $specConf, $RTE = FALSE) { // Return not changed main item directly if wizards are disabled if (!is_array($wizConf) || $this->isWizardsDisabled()) { return $itemKinds[0]; } $languageService = $this->getLanguageService(); $fieldChangeFunc = $PA['fieldChangeFunc']; $item = $itemKinds[0]; $fName = '[' . $table . '][' . $row['uid'] . '][' . $field . ']'; $md5ID = 'ID' . GeneralUtility::shortmd5($itemName); $fieldConfig = $PA['fieldConf']['config']; $prefixOfFormElName = 'data[' . $table . '][' . $row['uid'] . '][' . $field . ']'; $flexFormPath = ''; if (GeneralUtility::isFirstPartOfStr($PA['itemFormElName'], $prefixOfFormElName)) { $flexFormPath = str_replace('][', '/', substr($PA['itemFormElName'], strlen($prefixOfFormElName) + 1, -1)); } // Manipulate the field name (to be the TRUE form field name) and remove // a suffix-value if the item is a selector box with renderMode "singlebox": $listFlag = '_list'; if ($PA['fieldConf']['config']['type'] == 'select') { // Single select situation: if ($PA['fieldConf']['config']['maxitems'] <= 1) { $listFlag = ''; } elseif ($PA['fieldConf']['config']['renderMode'] == 'singlebox') { $itemName .= '[]'; $listFlag = ''; } } // Contains wizard identifiers enabled for this record type, see "special configuration" docs $wizardsEnabledByType = $specConf['wizards']['parameters']; $buttonWizards = array(); $otherWizards = array(); foreach ($wizConf as $wizardIdentifier => $wizardConfiguration) { // If an identifier starts with "_", this is a configuration option like _POSITION and not a wizard if ($wizardIdentifier[0] === '_') { continue; } // Sanitize wizard type $wizardConfiguration['type'] = (string) $wizardConfiguration['type']; // Wizards can be shown based on selected "type" of record. If this is the case, the wizard configuration // is set to enableByTypeConfig = 1, and the wizardIdentifier is found in $wizardsEnabledByType $wizardIsEnabled = TRUE; if (isset($wizardConfiguration['enableByTypeConfig']) && (bool) $wizardConfiguration['enableByTypeConfig'] && (!is_array($wizardsEnabledByType) || !in_array($wizardIdentifier, $wizardsEnabledByType))) { $wizardIsEnabled = FALSE; } // Disable if wizard is for RTE fields only and the handled field is no RTE field or RTE can not be loaded if (isset($wizardConfiguration['RTEonly']) && (bool) $wizardConfiguration['RTEonly'] && !$RTE) { $wizardIsEnabled = FALSE; } // Disable if wizard is for not-new records only and we're handling a new record if (isset($wizardConfiguration['notNewRecords']) && $wizardConfiguration['notNewRecords'] && !MathUtility::canBeInterpretedAsInteger($row['uid'])) { $wizardIsEnabled = FALSE; } // Wizard types script, colorbox and popup must contain a module name configuration if (!isset($wizardConfiguration['module']['name']) && in_array($wizardConfiguration['type'], array('script', 'colorbox', 'popup'), TRUE)) { $wizardIsEnabled = FALSE; } if (!$wizardIsEnabled) { continue; } // Title / icon: $iTitle = htmlspecialchars($languageService->sL($wizardConfiguration['title'])); if (isset($wizardConfiguration['icon'])) { $icon = FormEngineUtility::getIconHtml($wizardConfiguration['icon'], $iTitle, $iTitle); } else { $icon = $iTitle; } switch ($wizardConfiguration['type']) { case 'userFunc': $params = array(); $params['fieldConfig'] = $fieldConfig; $params['params'] = $wizardConfiguration['params']; $params['exampleImg'] = $wizardConfiguration['exampleImg']; $params['table'] = $table; $params['uid'] = $row['uid']; $params['pid'] = $row['pid']; $params['field'] = $field; $params['flexFormPath'] = $flexFormPath; $params['md5ID'] = $md5ID; $params['returnUrl'] = $this->getReturnUrl(); $params['formName'] = 'editform'; $params['itemName'] = $itemName; $params['hmac'] = GeneralUtility::hmac($params['formName'] . $params['itemName'], 'wizard_js'); $params['fieldChangeFunc'] = $fieldChangeFunc; $params['fieldChangeFuncHash'] = GeneralUtility::hmac(serialize($fieldChangeFunc)); $params['item'] =& $item; $params['icon'] = $icon; $params['iTitle'] = $iTitle; $params['wConf'] = $wizardConfiguration; $params['row'] = $row; $formEngineDummy = new FormEngine(); $otherWizards[] = GeneralUtility::callUserFunction($wizardConfiguration['userFunc'], $params, $formEngineDummy); break; case 'script': $params = array(); // Including the full fieldConfig from TCA may produce too long an URL if ($wizardIdentifier != 'RTE') { $params['fieldConfig'] = $fieldConfig; } $params['params'] = $wizardConfiguration['params']; $params['exampleImg'] = $wizardConfiguration['exampleImg']; $params['table'] = $table; $params['uid'] = $row['uid']; $params['pid'] = $row['pid']; $params['field'] = $field; $params['flexFormPath'] = $flexFormPath; $params['md5ID'] = $md5ID; $params['returnUrl'] = $this->getReturnUrl(); // Resolving script filename and setting URL. $urlParameters = array(); if (isset($wizardConfiguration['module']['urlParameters']) && is_array($wizardConfiguration['module']['urlParameters'])) { $urlParameters = $wizardConfiguration['module']['urlParameters']; } $wScript = BackendUtility::getModuleUrl($wizardConfiguration['module']['name'], $urlParameters, ''); $url = $wScript . (strstr($wScript, '?') ? '' : '?') . GeneralUtility::implodeArrayForUrl('', array('P' => $params)); $buttonWizards[] = '<a class="btn btn-default" href="' . htmlspecialchars($url) . '" onclick="this.blur(); return !TBE_EDITOR.isFormChanged();">' . $icon . '</a>'; break; case 'popup': $params = array(); $params['fieldConfig'] = $fieldConfig; $params['params'] = $wizardConfiguration['params']; $params['exampleImg'] = $wizardConfiguration['exampleImg']; $params['table'] = $table; $params['uid'] = $row['uid']; $params['pid'] = $row['pid']; $params['field'] = $field; $params['flexFormPath'] = $flexFormPath; $params['md5ID'] = $md5ID; $params['returnUrl'] = $this->getReturnUrl(); $params['formName'] = 'editform'; $params['itemName'] = $itemName; $params['hmac'] = GeneralUtility::hmac($params['formName'] . $params['itemName'], 'wizard_js'); $params['fieldChangeFunc'] = $fieldChangeFunc; $params['fieldChangeFuncHash'] = GeneralUtility::hmac(serialize($fieldChangeFunc)); // Resolving script filename and setting URL. $urlParameters = array(); if (isset($wizardConfiguration['module']['urlParameters']) && is_array($wizardConfiguration['module']['urlParameters'])) { $urlParameters = $wizardConfiguration['module']['urlParameters']; } $wScript = BackendUtility::getModuleUrl($wizardConfiguration['module']['name'], $urlParameters, ''); $url = $wScript . (strstr($wScript, '?') ? '' : '?') . GeneralUtility::implodeArrayForUrl('', array('P' => $params)); $onlyIfSelectedJS = ''; if (isset($wizardConfiguration['popup_onlyOpenIfSelected']) && $wizardConfiguration['popup_onlyOpenIfSelected']) { $notSelectedText = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:mess.noSelItemForEdit'); $onlyIfSelectedJS = 'if (!TBE_EDITOR.curSelected(' . GeneralUtility::quoteJSvalue($itemName . $listFlag) . ')){' . 'alert(' . GeneralUtility::quoteJSvalue($notSelectedText) . ');' . 'return false;' . '}'; } $aOnClick = 'this.blur();' . $onlyIfSelectedJS . 'vHWin=window.open(' . GeneralUtility::quoteJSvalue($url) . '+\'&P[currentValue]=\'+TBE_EDITOR.rawurlencode(' . 'document.editform[' . GeneralUtility::quoteJSvalue($itemName) . '].value,200' . ')' . '+\'&P[currentSelectedValues]=\'+TBE_EDITOR.curSelected(' . GeneralUtility::quoteJSvalue($itemName . $listFlag) . '),' . GeneralUtility::quoteJSvalue('popUp' . $md5ID) . ',' . GeneralUtility::quoteJSvalue($wizardConfiguration['JSopenParams']) . ');' . 'vHWin.focus();' . 'return false;'; $buttonWizards[] = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>'; break; case 'colorbox': $params = array(); $params['fieldConfig'] = $fieldConfig; $params['params'] = $wizardConfiguration['params']; $params['exampleImg'] = $wizardConfiguration['exampleImg']; $params['table'] = $table; $params['uid'] = $row['uid']; $params['pid'] = $row['pid']; $params['field'] = $field; $params['flexFormPath'] = $flexFormPath; $params['md5ID'] = $md5ID; $params['returnUrl'] = $this->getReturnUrl(); $params['formName'] = 'editform'; $params['itemName'] = $itemName; $params['hmac'] = GeneralUtility::hmac($params['formName'] . $params['itemName'], 'wizard_js'); $params['fieldChangeFunc'] = $fieldChangeFunc; $params['fieldChangeFuncHash'] = GeneralUtility::hmac(serialize($fieldChangeFunc)); // Resolving script filename and setting URL. $urlParameters = array(); if (isset($wizardConfiguration['module']['urlParameters']) && is_array($wizardConfiguration['module']['urlParameters'])) { $urlParameters = $wizardConfiguration['module']['urlParameters']; } $wScript = BackendUtility::getModuleUrl($wizardConfiguration['module']['name'], $urlParameters, ''); $url = $wScript . (strstr($wScript, '?') ? '' : '?') . GeneralUtility::implodeArrayForUrl('', array('P' => $params)); $aOnClick = 'this.blur();' . 'vHWin=window.open(' . GeneralUtility::quoteJSvalue($url) . '+\'&P[currentValue]=\'+TBE_EDITOR.rawurlencode(' . 'document.editform[' . GeneralUtility::quoteJSvalue($itemName) . '].value,200' . ')' . '+\'&P[currentSelectedValues]=\'+TBE_EDITOR.curSelected(' . GeneralUtility::quoteJSvalue($itemName . $listFlag) . '),' . GeneralUtility::quoteJSvalue('popUp' . $md5ID) . ',' . GeneralUtility::quoteJSvalue($wizardConfiguration['JSopenParams']) . ');' . 'vHWin.focus();' . 'return false;'; $otherWizards[] = '<a id="' . $md5ID . '" class="btn btn-default" href="#" onclick="' . htmlspecialchars($aOnClick) . '"><span class="t3-icon fa fa-eyedropper"></span></a>'; break; case 'slider': $params = array(); $params['fieldConfig'] = $fieldConfig; $params['field'] = $field; $params['flexFormPath'] = $flexFormPath; $params['md5ID'] = $md5ID; $params['itemName'] = $itemName; $params['fieldChangeFunc'] = $fieldChangeFunc; $params['wConf'] = $wizardConfiguration; $params['row'] = $row; /** @var ValueSliderWizard $wizard */ $wizard = GeneralUtility::makeInstance(ValueSliderWizard::class); $otherWizards[] = $wizard->renderWizard($params); break; case 'select': $fieldValue = array('config' => $wizardConfiguration); $TSconfig = FormEngineUtility::getTSconfigForTableRow($table, $row); $TSconfig[$field] = $TSconfig[$field]['wizards.'][$wizardIdentifier . '.']; $selItems = FormEngineUtility::addSelectOptionsToItemArray(FormEngineUtility::initItemArray($fieldValue), $fieldValue, $TSconfig, $field); // Process items by a user function: if (!empty($wizardConfiguration['itemsProcFunc'])) { $funcConfig = !empty($wizardConfiguration['itemsProcFunc.']) ? $wizardConfiguration['itemsProcFunc.'] : array(); $dataPreprocessor = GeneralUtility::makeInstance(DataPreprocessor::class); $selItems = $dataPreprocessor->procItems($selItems, $funcConfig, $wizardConfiguration, $table, $row, $field); } $options = array(); $options[] = '<option>' . $iTitle . '</option>'; foreach ($selItems as $p) { $options[] = '<option value="' . htmlspecialchars($p[1]) . '">' . htmlspecialchars($p[0]) . '</option>'; } if ($wizardConfiguration['mode'] == 'append') { $assignValue = 'document.editform[' . GeneralUtility::quoteJSvalue($itemName) . '].value=\'\'+this.options[this.selectedIndex].value+document.editform[' . GeneralUtility::quoteJSvalue($itemName) . '].value'; } elseif ($wizardConfiguration['mode'] == 'prepend') { $assignValue = 'document.editform[' . GeneralUtility::quoteJSvalue($itemName) . '].value+=\'\'+this.options[this.selectedIndex].value'; } else { $assignValue = 'document.editform[' . GeneralUtility::quoteJSvalue($itemName) . '].value=this.options[this.selectedIndex].value'; } $otherWizards[] = '<select' . ' id="' . str_replace('.', '', uniqid('tceforms-select-', TRUE)) . '"' . ' class="form-control tceforms-select tceforms-wizardselect"' . ' name="_WIZARD' . $fName . '"' . ' onchange="' . htmlspecialchars($assignValue . ';this.blur();this.selectedIndex=0;' . implode('', $fieldChangeFunc)) . '"' . '>' . implode('', $options) . '</select>'; break; case 'suggest': if (!empty($PA['fieldTSConfig']['suggest.']['default.']['hide'])) { break; } /** @var SuggestWizard $suggestWizard */ $suggestWizard = GeneralUtility::makeInstance(SuggestWizard::class); $otherWizards[] = $suggestWizard->renderSuggestSelector($PA['itemFormElName'], $table, $field, $row, $PA); break; } // Hide the real form element? if (is_array($wizardConfiguration['hideParent']) || $wizardConfiguration['hideParent']) { // Setting the item to a hidden-field. $item = $itemKinds[1]; if (is_array($wizardConfiguration['hideParent'])) { $options = $this->globalOptions; $options['parameterArray'] = array('fieldConf' => array('config' => $wizardConfiguration['hideParent']), 'itemFormElValue' => $PA['itemFormElValue']); $options['renderType'] = 'none'; /** @var NodeFactory $nodeFactory */ $nodeFactory = $this->globalOptions['nodeFactory']; $noneElementResult = $nodeFactory->create($options)->render(); $item .= $noneElementResult['html']; } } } // For each rendered wizard, put them together around the item. if (!empty($buttonWizards) || !empty($otherWizards)) { if ($wizConf['_HIDDENFIELD']) { $item = $itemKinds[1]; } $innerContent = ''; if (!empty($buttonWizards)) { $innerContent .= '<div class="btn-group' . ($wizConf['_VERTICAL'] ? ' btn-group-vertical' : '') . '">' . implode('', $buttonWizards) . '</div>'; } $innerContent .= implode(' ', $otherWizards); // Position $classes = array('form-wizards-wrap'); if ($wizConf['_POSITION'] === 'left') { $classes[] = 'form-wizards-aside'; $innerContent = '<div class="form-wizards-items">' . $innerContent . '</div><div class="form-wizards-element">' . $item . '</div>'; } elseif ($wizConf['_POSITION'] === 'top') { $classes[] = 'form-wizards-top'; $innerContent = '<div class="form-wizards-items">' . $innerContent . '</div><div class="form-wizards-element">' . $item . '</div>'; } elseif ($wizConf['_POSITION'] === 'bottom') { $classes[] = 'form-wizards-bottom'; $innerContent = '<div class="form-wizards-element">' . $item . '</div><div class="form-wizards-items">' . $innerContent . '</div>'; } else { $classes[] = 'form-wizards-aside'; $innerContent = '<div class="form-wizards-element">' . $item . '</div><div class="form-wizards-items">' . $innerContent . '</div>'; } $item = ' <div class="' . implode(' ', $classes) . '"> ' . $innerContent . ' </div>'; } return $item; }
/** * Modify a single FlexForm sheet according to given configuration * * @param array $sheet Flexform sheet to manipulate * @param string $table The table name * @param string $tableField The field name * @param array $tableRow The record data * @param array $sheetConf Sheet configuration * @param array $nonExcludeFields Non-exclude-fields for this sheet * @return array Modified sheet * @see \TYPO3\CMS\Backend\Form\FlexFormsHelper::modifyFlexFormDS() */ public function modifySingleFlexFormSheet(array $sheet, $table, $tableField, array $tableRow, array $sheetConf, array $nonExcludeFields) { if (empty($sheet) || empty($table) || empty($tableField) || empty($tableRow)) { return $sheet; } // Modify fields foreach ($sheet as $fieldName => $field) { // Remove excluded fields if (!$GLOBALS['BE_USER']->isAdmin() && !empty($field['TCEforms']['exclude']) && empty($nonExcludeFields[$fieldName])) { unset($sheet[$fieldName]); continue; } // Stop here if no TSConfig was found for this field if (empty($sheetConf[$fieldName]) || !is_array($sheetConf[$fieldName])) { continue; } // Remove disabled fields if (!empty($sheetConf[$fieldName]['disabled'])) { unset($sheet[$fieldName]); continue; } $fieldConf = $sheetConf[$fieldName]; $removeItems = !empty($fieldConf['removeItems']) ? GeneralUtility::trimExplode(',', $fieldConf['removeItems'], TRUE) : array(); $keepItems = !empty($fieldConf['keepItems']) ? GeneralUtility::trimExplode(',', $fieldConf['keepItems'], TRUE) : array(); $renameItems = !empty($fieldConf['altLabels']) && is_array($fieldConf['altLabels']) ? $fieldConf['altLabels'] : array(); $changeIcons = !empty($fieldConf['altIcons']) && is_array($fieldConf['altIcons']) ? $fieldConf['altIcons'] : array(); $addItems = !empty($fieldConf['addItems']) && is_array($fieldConf['addItems']) ? $fieldConf['addItems'] : array(); unset($fieldConf['removeItems']); unset($fieldConf['keepItems']); unset($fieldConf['altLabels']); unset($fieldConf['altIcons']); unset($fieldConf['addItems']); // Manipulate field if (!empty($field['TCEforms']) && is_array($field['TCEforms'])) { $sheet[$fieldName]['TCEforms'] = $field['TCEforms']; ArrayUtility::mergeRecursiveWithOverrule($sheet[$fieldName]['TCEforms'], $fieldConf); } // Manipulate only select fields, other field types will stop here if (empty($field['TCEforms']['config']['type']) || $field['TCEforms']['config']['type'] != 'select' || $field['TCEforms']['config']['renderMode'] === 'tree') { continue; } // Getting the selector box items from system $selItems = FormEngineUtility::addSelectOptionsToItemArray(FormEngineUtility::initItemArray($field['TCEforms']), $field['TCEforms'], FormEngineUtility::getTSconfigForTableRow($table, $tableRow), $tableField); // Possibly filter some items $selItems = ArrayUtility::keepItemsInArray($selItems, $keepItems, function ($value) { return $value[1]; }); // Possibly add some items $selItems = FormEngineUtility::addItems($selItems, $addItems); // Process items by a user function if (!empty($field['TCEforms']['config']['itemsProcFunc'])) { $dataPreprocessor = GeneralUtility::makeInstance(DataPreprocessor::class); $selItems = $dataPreprocessor->procItems($selItems, $fieldConf['config'], $field['TCEforms']['config'], $table, $tableRow, $tableField); } // Remove special configuration options after creating items to prevent double parsing foreach ($this->removeSelectConfig as $option) { unset($sheet[$fieldName]['TCEforms']['config'][$option]); } // Rename and remove items or change item icon in select if ((!empty($removeItems) || !empty($renameItems) || !empty($changeIcons)) && !empty($selItems) && is_array($selItems)) { foreach ($selItems as $itemKey => $itemConf) { // Option has no key, no manipulation possible if (!isset($itemConf[1])) { continue; } // Remove foreach ($removeItems as $removeKey => $removeValue) { if (strcasecmp($removeValue, $itemConf[1]) == 0) { unset($selItems[$itemKey]); unset($removeItems[$removeKey]); } } // Rename foreach ($renameItems as $renameKey => $renameValue) { if (strcasecmp($renameKey, $itemConf[1]) == 0) { $selItems[$itemKey][0] = htmlspecialchars($renameValue); unset($renameItems[$renameKey]); } } // Change icon foreach ($changeIcons as $iconKey => $iconValue) { if (strcasecmp($iconKey, $itemConf[1]) == 0) { $selItems[$itemKey][2] = $iconValue; unset($changeIcons[$iconKey]); } } } } $sheet[$fieldName]['TCEforms']['config']['items'] = $selItems; } return $sheet; }
/** * Get possible records. * Copied from FormEngine and modified. * * @param string $table The table name of the record * @param string $field The field name which this element is supposed to edit * @param array $row The record data array where the value(s) for the field can be found * @param array $conf An array with additional configuration options. * @param string $checkForConfField For which field in the foreign_table the possible records should be fetched * @return mixed Array of possible record items; FALSE if type is "group/db", then everything could be "possible */ protected function getPossibleRecords($table, $field, $row, $conf, $checkForConfField = 'foreign_selector') { $backendUser = $this->getBackendUserAuthentication(); $languageService = $this->getLanguageService(); // ctrl configuration from TCA: $tcaTableCtrl = $GLOBALS['TCA'][$table]['ctrl']; // Field configuration from TCA: $foreign_check = $conf[$checkForConfField]; $foreignConfig = FormEngineUtility::getInlinePossibleRecordsSelectorConfig($conf, $foreign_check); $PA = $foreignConfig['PA']; $config = $PA['fieldConf']['config']; if ($foreignConfig['type'] == 'select') { // Getting the selector box items from the system $selItems = FormEngineUtility::addSelectOptionsToItemArray(FormEngineUtility::initItemArray($PA['fieldConf']), $PA['fieldConf'], FormEngineUtility::getTSconfigForTableRow($table, $row), $field); // Possibly filter some items: $selItems = ArrayUtility::keepItemsInArray($selItems, $PA['fieldTSConfig']['keepItems'], function ($value) { return $value[1]; }); // Possibly add some items: $selItems = FormEngineUtility::addItems($selItems, $PA['fieldTSConfig']['addItems.']); if (isset($config['itemsProcFunc']) && $config['itemsProcFunc']) { $dataPreprocessor = GeneralUtility::makeInstance(DataPreprocessor::class); $selItems = $dataPreprocessor->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field); } // Possibly remove some items: $removeItems = GeneralUtility::trimExplode(',', $PA['fieldTSConfig']['removeItems'], TRUE); foreach ($selItems as $tk => $p) { // Checking languages and authMode: $languageDeny = $tcaTableCtrl['languageField'] && (string) $tcaTableCtrl['languageField'] === $field && !$backendUser->checkLanguageAccess($p[1]); $authModeDeny = $config['type'] == 'select' && $config['authMode'] && !$backendUser->checkAuthMode($table, $field, $p[1], $config['authMode']); if (in_array($p[1], $removeItems) || $languageDeny || $authModeDeny) { unset($selItems[$tk]); } else { if (isset($PA['fieldTSConfig']['altLabels.'][$p[1]])) { $selItems[$tk][0] = htmlspecialchars($languageService->sL($PA['fieldTSConfig']['altLabels.'][$p[1]])); } if (isset($PA['fieldTSConfig']['altIcons.'][$p[1]])) { $selItems[$tk][2] = $PA['fieldTSConfig']['altIcons.'][$p[1]]; } } // Removing doktypes with no access: if (($table === 'pages' || $table === 'pages_language_overlay') && $field === 'doktype') { if (!($backendUser->isAdmin() || GeneralUtility::inList($backendUser->groupData['pagetypes_select'], $p[1]))) { unset($selItems[$tk]); } } } } else { $selItems = FALSE; } return $selItems; }