2 namespace TYPO3\CMS\Backend\Form\Wizard;
42 public function renderSuggestSelector($fieldname, $table, $field, array $row, array $config)
47 $isFlexFormField =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'][
'type'] ===
'flex';
48 if ($isFlexFormField) {
49 $fieldPattern =
'data[' . $table .
'][' . $row[
'uid'] .
'][';
50 $flexformField = str_replace($fieldPattern,
'', $fieldname);
51 $flexformField = substr($flexformField, 0, -1);
52 $field = str_replace(array(
']['),
'|', $flexformField);
57 if (isset($config[
'fieldConf'][
'config'][
'wizards'][
'suggest'][
'default'][
'minimumCharacters'])) {
58 $minChars = (int)$config[
'fieldConf'][
'config'][
'wizards'][
'suggest'][
'default'][
'minimumCharacters'];
61 if (isset($config[
'fieldTSConfig'][
'suggest.'][
'default.'][
'minimumCharacters'])) {
62 $minChars = (int)$config[
'fieldTSConfig'][
'suggest.'][
'default.'][
'minimumCharacters'];
64 $minChars = $minChars > 0 ? $minChars : 2;
68 if (isset($config[
'fieldConf'][
'config'][
'type'])) {
69 $type = $config[
'fieldConf'][
'config'][
'type'];
77 $jsRow = serialize($row);
81 <div class="autocomplete t3-form-suggest-container">
82 <div class="input-group">
83 <span class="input-group-addon">' . $iconFactory->getIcon(
'actions-search',
Icon::SIZE_SMALL)->render() .
'</span>
84 <input type="search" class="t3-form-suggest form-control"
85 placeholder="' . $languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.findRecord') .
'"
86 data-fieldname="' . $fieldname .
'"
87 data-table="' . $table .
'"
88 data-field="' . $field .
'"
89 data-uid="' . $row[
'uid'] .
'"
90 data-pid="' . $row[
'pid'] .
'"
91 data-fieldtype="' . $type .
'"
92 data-minchars="' . $minChars .
'"
93 data-recorddata="' . htmlspecialchars($jsRow) .
'"
111 $fieldConfig = array();
112 $elements = $dataStructure[
'ROOT'][
'el'] ? $dataStructure[
'ROOT'][
'el'] : $dataStructure[
'el'];
113 if (is_array($elements)) {
114 foreach ($elements as $k => $ds) {
115 if ($k === $fieldName) {
116 $fieldConfig = $ds[
'TCEforms'][
'config'];
118 }
elseif (isset($ds[
'el'][$fieldName][
'TCEforms'][
'config'])) {
119 $fieldConfig = $ds[
'el'][$fieldName][
'TCEforms'][
'config'];
142 $search = isset($parsedBody[
'value']) ? $parsedBody[
'value'] : $queryParams[
'value'];
143 $table = isset($parsedBody[
'table']) ? $parsedBody[
'table'] : $queryParams[
'table'];
144 $field = isset($parsedBody[
'field']) ? $parsedBody[
'field'] : $queryParams[
'field'];
145 $uid = isset($parsedBody[
'uid']) ? $parsedBody[
'uid'] : $queryParams[
'uid'];
146 $pageId = (int)(isset($parsedBody[
'pid']) ? $parsedBody[
'pid'] : $queryParams[
'pid']);
147 $newRecordRow = isset($parsedBody[
'newRecordRow']) ? $parsedBody[
'newRecordRow'] : $queryParams[
'newRecordRow'];
151 if (is_numeric($uid)) {
153 if ($table ===
'pages') {
156 $pageId = $row[
'pid'];
159 $row = unserialize($newRecordRow);
162 $fieldConfig =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
165 $wizardConfig = $fieldConfig[
'wizards'][
'suggest'];
170 $resultRows = array();
174 foreach ($queryTables as $queryTable) {
176 if (!is_array(
$GLOBALS[
'TCA'][$queryTable]) || empty(
$GLOBALS[
'TCA'][$queryTable])) {
183 if (!isset($config[
'addWhere']) && $whereClause) {
184 $config[
'addWhere'] = $whereClause;
186 if (isset($config[
'addWhere'])) {
187 $replacement = array(
188 '###THIS_UID###' => (
int)$uid,
189 '###CURRENT_PID###' => (
int)$pageId
191 if (isset($TSconfig[
'TCEFORM.'][$table .
'.'][$field .
'.'])) {
192 $fieldTSconfig = $TSconfig[
'TCEFORM.'][$table .
'.'][$field .
'.'];
193 if (isset($fieldTSconfig[
'PAGE_TSCONFIG_ID'])) {
194 $replacement[
'###PAGE_TSCONFIG_ID###'] = (int)$fieldTSconfig[
'PAGE_TSCONFIG_ID'];
196 if (isset($fieldTSconfig[
'PAGE_TSCONFIG_IDLIST'])) {
197 $replacement[
'###PAGE_TSCONFIG_IDLIST###'] =
$GLOBALS[
'TYPO3_DB']->cleanIntList($fieldTSconfig[
'PAGE_TSCONFIG_IDLIST']);
199 if (isset($fieldTSconfig[
'PAGE_TSCONFIG_STR'])) {
200 $replacement[
'###PAGE_TSCONFIG_STR###'] =
$GLOBALS[
'TYPO3_DB']->quoteStr($fieldTSconfig[
'PAGE_TSCONFIG_STR'], $fieldConfig[
'foreign_table']);
203 $config[
'addWhere'] = strtr(
' ' . $config[
'addWhere'], $replacement);
207 $receiverClassName = $config[
'receiverClass'];
208 if (!class_exists($receiverClassName)) {
209 $receiverClassName = SuggestWizardDefaultReceiver::class;
212 $params = array(
'value' => $search);
213 $rows = $receiverObj->queryTable($params);
217 $resultRows = $rows + $resultRows;
222 $maxItems = isset($config[
'maxItemsInResultList']) ? $config[
'maxItemsInResultList'] : 10;
223 $maxItems = min(count($resultRows), $maxItems);
227 $response->
getBody()->write(json_encode($listItems));
239 return !$tableConfig[
'ctrl'][
'hideTable'];
251 if (
$GLOBALS[
'BE_USER']->isAdmin()) {
256 if ($tableConfig[
'ctrl'][
'adminOnly']) {
261 return !$tableConfig[
'ctrl'][
'rootLevel'] || $tableConfig[
'ctrl'][
'security'][
'ignoreRootLevelRestriction'];
276 if (strpos($field,
'|') ===
false) {
277 $fieldConfig =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
279 $parts = explode(
'|', $field);
281 if (
$GLOBALS[
'TCA'][$table][
'columns'][$parts[0]][
'config'][
'type'] !==
'flex') {
285 $flexfieldTCAConfig =
$GLOBALS[
'TCA'][$table][
'columns'][$parts[0]][
'config'];
289 $flexformElement = $parts[count($parts) - 2];
291 foreach ($flexformDSArray as $sheet) {
292 foreach ($sheet as $_ => $dataStructure) {
294 if (!empty($fieldConfig)) {
305 $field = str_replace(
'|',
'][', $field);
322 $config = (array)$wizardConfig[
'default'];
324 if (is_array($wizardConfig[$queryTable])) {
327 $globalSuggestTsConfig = $TSconfig[
'TCEFORM.'][
'suggest.'];
328 $currentFieldSuggestTsConfig = $TSconfig[
'TCEFORM.'][$table .
'.'][$field .
'.'][
'suggest.'];
332 if (is_array($globalSuggestTsConfig[
'default.'])) {
336 if (is_array($globalSuggestTsConfig[$queryTable .
'.'])) {
342 if (is_array($currentFieldSuggestTsConfig[
'default.'])) {
346 if (is_array($currentFieldSuggestTsConfig[$queryTable .
'.'])) {
363 if (empty($resultRows)) {
366 $listItems = array();
370 foreach ($resultRows as $key => $row) {
371 $rowsSort[$key] = $row[
'text'];
374 $rowsSort = array_keys($rowsSort);
377 for ($i = 0; $i < $maxItems; ++$i) {
378 $listItems[] = $resultRows[$rowsSort[$i]];
392 $queryTables = array();
394 if (isset($fieldConfig[
'allowed'])) {
395 if ($fieldConfig[
'allowed'] !==
'*') {
400 foreach (
$GLOBALS[
'TCA'] as $tableName => $tableConfig) {
402 $queryTables[] = $tableName;
405 unset($tableName, $tableConfig);
407 }
elseif (isset($fieldConfig[
'foreign_table'])) {
409 $queryTables = array($fieldConfig[
'foreign_table']);
425 if (!isset($fieldConfig[
'foreign_table'])) {
430 return trim(preg_replace(
'/ORDER[[:space:]]+BY.*/i',
'', $fieldConfig[
'foreign_table_where']));