/** * Get possible records. * Copied from TCEform 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 * @todo Define visibility */ public function getPossibleRecords($table, $field, $row, $conf, $checkForConfField = 'foreign_selector') { // ctrl configuration from TCA: $tcaTableCtrl = $GLOBALS['TCA'][$table]['ctrl']; // Field configuration from TCA: $foreign_table = $conf['foreign_table']; $foreign_check = $conf[$checkForConfField]; $foreignConfig = $this->getPossibleRecordsSelectorConfig($conf, $foreign_check); $PA = $foreignConfig['PA']; $config = $PA['fieldConf']['config']; if ($foreignConfig['type'] == 'select') { // Getting the selector box items from the system $selItems = $this->fObj->addSelectOptionsToItemArray($this->fObj->initItemArray($PA['fieldConf']), $PA['fieldConf'], $this->fObj->setTSconfig($table, $row), $field); // Possibly filter some items: $selItems = GeneralUtility::keepItemsInArray($selItems, $PA['fieldTSConfig']['keepItems'], function ($value) { return $value[1]; }); // Possibly add some items: $selItems = $this->fObj->addItems($selItems, $PA['fieldTSConfig']['addItems.']); if (isset($config['itemsProcFunc']) && $config['itemsProcFunc']) { $selItems = $this->fObj->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 && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]); $authModeDeny = $config['form_type'] == 'select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table, $field, $p[1], $config['authMode']); if (in_array($p[1], $removeItems) || $languageDeny || $authModeDeny) { unset($selItems[$tk]); } elseif (isset($PA['fieldTSConfig']['altLabels.'][$p[1]])) { $selItems[$tk][0] = htmlspecialchars($this->fObj->sL($PA['fieldTSConfig']['altLabels.'][$p[1]])); } // Removing doktypes with no access: if (($table === 'pages' || $table === 'pages_language_overlay') && $field === 'doktype') { if (!($GLOBALS['BE_USER']->isAdmin() || GeneralUtility::inList($GLOBALS['BE_USER']->groupData['pagetypes_select'], $p[1]))) { unset($selItems[$tk]); } } } } else { $selItems = FALSE; } return $selItems; }