50 public function init($tceForms) {
51 $this->TCEformsObj = $tceForms;
65 $this->suggestCount++;
66 $containerCssClass = $this->cssClass .
' ' . $this->cssClass .
'-position-right';
67 $suggestId =
'suggest-' . $table .
'-' . $field .
'-' . $row[
'uid'];
68 $isFlexFormField =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'][
'type'] ===
'flex';
69 if ($isFlexFormField) {
70 $fieldPattern =
'data[' . $table .
'][' . $row[
'uid'] .
'][';
71 $flexformField = str_replace($fieldPattern,
'', $fieldname);
72 $flexformField = substr($flexformField, 0, -1);
73 $field = str_replace(array(
']['),
'|', $flexformField);
76 <div class="' . $containerCssClass .
'" id="' . $suggestId .
'"> 77 <input type="text" id="' . $fieldname .
'Suggest" value="' .
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.findRecord') .
'" class="' . $this->cssClass .
'-search" /> 78 <div class="' . $this->cssClass .
'-indicator" style="display: none;" id="' . $fieldname .
'SuggestIndicator"> 79 <img src="' .
$GLOBALS[
'BACK_PATH'] .
'gfx/spinner.gif" alt="' .
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:alttext.suggestSearching') .
'" /> 81 <div class="' . $this->cssClass .
'-choices" style="display: none;" id="' . $fieldname .
'SuggestChoices"></div> 86 if (isset($config[
'fieldConf'][
'config'][
'wizards'][
'suggest'][
'default'][
'minimumCharacters'])) {
87 $minChars = (int)$config[
'fieldConf'][
'config'][
'wizards'][
'suggest'][
'default'][
'minimumCharacters'];
90 if (isset($config[
'fieldTSConfig'][
'suggest.'][
'default.'][
'minimumCharacters'])) {
91 $minChars = (int)$config[
'fieldTSConfig'][
'suggest.'][
'default.'][
'minimumCharacters'];
93 $minChars = $minChars > 0 ? $minChars : 2;
97 if (isset($config[
'fieldConf'][
'config'][
'type'])) {
98 $type = $config[
'fieldConf'][
'config'][
'type'];
106 $jsRow = json_encode($row);
111 $this->TCEformsObj->additionalJS_post[] =
' 112 var ' . $jsObj .
' = new TCEForms.Suggest(' 117 . (int)$row[
'pid'] .
', ' 118 . (
int)$minChars .
', ' 134 $fieldConfig = array();
135 $elements = $dataStructure[
'ROOT'][
'el'] ? $dataStructure[
'ROOT'][
'el'] : $dataStructure[
'el'];
136 if (is_array($elements)) {
137 foreach ($elements as $k => $ds) {
138 if ($k === $fieldName) {
139 $fieldConfig = $ds[
'TCEforms'][
'config'];
141 } elseif (isset($ds[
'el'][$fieldName][
'TCEforms'][
'config'])) {
142 $fieldConfig = $ds[
'el'][$fieldName][
'TCEforms'][
'config'];
171 if (is_numeric(
$uid)) {
172 $row = BackendUtility::getRecord($table,
$uid);
173 if ($table ==
'pages') {
176 $pageId = $row[
'pid'];
179 $row = json_decode($newRecordRow, TRUE);
182 $queryTables = array();
183 $foreign_table_where =
'';
184 $fieldConfig =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
185 $parts = explode(
'|', $field);
186 if (
$GLOBALS[
'TCA'][$table][
'columns'][$parts[0]][
'config'][
'type'] ===
'flex') {
187 $flexfieldTCAConfig =
$GLOBALS[
'TCA'][$table][
'columns'][$parts[0]][
'config'];
190 $flexformElement = $parts[count($parts) - 2];
192 foreach ($flexformDSArray as $sheet) {
193 foreach ($sheet as $dataStructure) {
195 if (count($fieldConfig) > 0) {
204 $field = str_replace(
'|',
'][', $field);
206 $wizardConfig = $fieldConfig[
'wizards'][
'suggest'];
207 if (isset($fieldConfig[
'allowed'])) {
208 if ($fieldConfig[
'allowed'] ===
'*') {
209 foreach (
$GLOBALS[
'TCA'] as $tableName => $tableConfig) {
211 if (empty($tableConfig[
'ctrl'][
'hideTable'])
213 || (empty($tableConfig[
'ctrl'][
'adminOnly'])
214 && (empty($tableConfig[
'ctrl'][
'rootLevel'])
215 || !empty($tableConfig[
'ctrl'][
'security'][
'ignoreRootLevelRestriction']))))
217 $queryTables[] = $tableName;
220 unset($tableName, $tableConfig);
224 } elseif (isset($fieldConfig[
'foreign_table'])) {
225 $queryTables = array($fieldConfig[
'foreign_table']);
226 $foreign_table_where = $fieldConfig[
'foreign_table_where'];
228 $foreign_table_where = trim(preg_replace(
'/ORDER[[:space:]]+BY.*/i',
'', $foreign_table_where));
230 $resultRows = array();
233 foreach ($queryTables as $queryTable) {
235 if (!is_array(
$GLOBALS[
'TCA'][$queryTable]) || !count(
$GLOBALS[
'TCA'][$queryTable])) {
238 $config = (array)$wizardConfig[
'default'];
239 if (is_array($wizardConfig[$queryTable])) {
244 if (is_array($TSconfig[
'TCEFORM.'][
'suggest.'][
'default.'])) {
247 if (is_array($TSconfig[
'TCEFORM.'][
'suggest.'][$queryTable .
'.'])) {
252 if (is_array($TSconfig[
'TCEFORM.'][$table .
'.'][$field .
'.'][
'suggest.'][
'default.'])) {
255 if (is_array($TSconfig[
'TCEFORM.'][$table .
'.'][$field .
'.'][
'suggest.'][$queryTable .
'.'])) {
259 if (!isset($config[
'addWhere']) && $foreign_table_where) {
260 $config[
'addWhere'] = $foreign_table_where;
262 if (isset($config[
'addWhere'])) {
263 $replacement = array(
264 '###THIS_UID###' => (
int)
$uid,
265 '###CURRENT_PID###' => (
int)$pageId
267 if (isset($TSconfig[
'TCEFORM.'][$table .
'.'][$field .
'.'])) {
268 $fieldTSconfig = $TSconfig[
'TCEFORM.'][$table .
'.'][$field .
'.'];
269 if (isset($fieldTSconfig[
'PAGE_TSCONFIG_ID'])) {
270 $replacement[
'###PAGE_TSCONFIG_ID###'] = (int)$fieldTSconfig[
'PAGE_TSCONFIG_ID'];
272 if (isset($fieldTSconfig[
'PAGE_TSCONFIG_IDLIST'])) {
273 $replacement[
'###PAGE_TSCONFIG_IDLIST###'] =
$GLOBALS[
'TYPO3_DB']->cleanIntList($fieldTSconfig[
'PAGE_TSCONFIG_IDLIST']);
275 if (isset($fieldTSconfig[
'PAGE_TSCONFIG_STR'])) {
276 $replacement[
'###PAGE_TSCONFIG_STR###'] =
$GLOBALS[
'TYPO3_DB']->quoteStr($fieldTSconfig[
'PAGE_TSCONFIG_STR'], $fieldConfig[
'foreign_table']);
279 $config[
'addWhere'] = strtr(
' ' . $config[
'addWhere'], $replacement);
282 $receiverClassName = $config[
'receiverClass'];
283 if (!class_exists($receiverClassName)) {
284 $receiverClassName =
'TYPO3\\CMS\\Backend\\Form\\Element\\SuggestDefaultReceiver';
287 $params = array(
'value' => $search);
288 $rows = $receiverObj->queryTable($params);
295 $listItems = array();
296 if (count($resultRows) > 0) {
299 foreach ($resultRows as $key => $row) {
300 $rowsSort[$key] = $row[
'text'];
303 $rowsSort = array_keys($rowsSort);
305 $maxItems = $config[
'maxItemsInResultList'] ?: 10;
306 $maxItems = min(count($resultRows), $maxItems);
308 for ($i = 0; $i < $maxItems; $i++) {
309 $row = $resultRows[$rowsSort[$i]];
310 $rowId = $row[
'table'] .
'-' . $row[
'uid'] .
'-' . $table .
'-' .
$uid .
'-' . $field;
311 $listItems[] =
'<li' . ($row[
'class'] !=
'' ?
' class="' . $row[
'class'] .
'"' :
'') .
' id="' . $rowId .
'"' . ($row[
'style'] !=
'' ?
' style="' . $row[
'style'] .
'"' :
'') .
'>' . $row[
'sprite'] . $row[
'text'] .
'</li>';
314 if (count($listItems) > 0) {
315 $list = implode(
'', $listItems);
317 $list =
'<li class="suggest-noresults"><i>' .
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.noRecordFound') .
'</i></li>';
319 $list =
'<ul class="' . $this->cssClass .
'-resultlist">' . $list .
'</ul>';
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=TRUE, $includeEmptyValues=TRUE, $enableUnsetFeature=TRUE)
static resolveAllSheetsInDS(array $dataStructArray)
static quoteJSvalue($value)
static canBeInterpretedAsInteger($var)
static makeInstance($className)
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
static getFlexFormDS($conf, $row, $table, $fieldName='', $WSOL=TRUE, $newRecordPidValue=0)
static array_merge(array $arr1, array $arr2)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static getPagesTSconfig($id, $rootLine=NULL, $returnPartArray=FALSE)
if($ajaxRegistryEntry !==NULL) $ajaxObj