[BUGFIX] Suggest Wizard: support for PAGE_TSCONFIG_*-values in addWhere 95/26695/7
authorJulian Hofmann <info@julian-hofmann.net>
Wed, 8 Jan 2014 17:22:33 +0000 (18:22 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Mon, 7 Jul 2014 20:14:27 +0000 (22:14 +0200)
Using PAGE_TSCONFIG_*-values in the foreign_table_where-clause limits
the entries. This where clause is also used for the suggest wizard, but
the markers are not replaced there.
PAGE_TSCONFIG_*-values are now supported in the suggest wizard too.

Resolves: #54843
Releases: 6.3, 6.2
Documentation: #60160
Change-Id: Ieb53d48ca0ddf22bbbbc4aed4d1e83220a82ec09
Reviewed-on: https://review.typo3.org/26695
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/backend/Classes/Form/Element/SuggestElement.php

index 793d30a..b5ae46f 100644 (file)
@@ -240,10 +240,23 @@ class SuggestElement {
                                $config['addWhere'] = $foreign_table_where;
                        }
                        if (isset($config['addWhere'])) {
-                               $config['addWhere'] = strtr(' ' . $config['addWhere'], array(
+                               $replacement = array(
                                        '###THIS_UID###' => (int)$uid,
                                        '###CURRENT_PID###' => (int)$pageId
-                               ));
+                               );
+                               if (isset($TSconfig['TCEFORM.'][$table . '.'][$field . '.'])) {
+                                       $fieldTSconfig = $TSconfig['TCEFORM.'][$table . '.'][$field . '.'];
+                                       if (isset($fieldTSconfig['PAGE_TSCONFIG_ID'])) {
+                                               $replacement['###PAGE_TSCONFIG_ID###'] = (int)$fieldTSconfig['PAGE_TSCONFIG_ID'];
+                                       }
+                                       if (isset($fieldTSconfig['PAGE_TSCONFIG_IDLIST'])) {
+                                               $replacement['###PAGE_TSCONFIG_IDLIST###'] = $GLOBALS['TYPO3_DB']->cleanIntList($fieldTSconfig['PAGE_TSCONFIG_IDLIST']);
+                                       }
+                                       if (isset($fieldTSconfig['PAGE_TSCONFIG_STR'])) {
+                                               $replacement['###PAGE_TSCONFIG_STR###'] = $GLOBALS['TYPO3_DB']->quoteStr($fieldTSconfig['PAGE_TSCONFIG_STR'], $fieldConfig['foreign_table']);
+                                       }
+                               }
+                               $config['addWhere'] = strtr(' ' . $config['addWhere'], $replacement);
                        }
                        // instantiate the class that should fetch the records for this $queryTable
                        $receiverClassName = $config['receiverClass'];