Feature #22231 » wizzards_suggest_for_flexforms4.5.patch
class.t3lib_tceforms_suggest.php (working copy) | ||
---|---|---|
$containerCssClass = $this->cssClass . ' ' . $this->cssClass . '-position-right';
|
||
$suggestId = 'suggest-' . $table . '-' . $field . '-' . $row['uid'];
|
||
|
||
if ( ($field === 'pi_flexform') || ($field === 'tx_templavoila_flex')) {
|
||
$fieldPattern = 'data[' . $table . '][' . $row['uid'] . '][';
|
||
$flexformField = str_replace($fieldPattern, '', $fieldname);
|
||
$flexformField = substr($flexformField, 0, -1);
|
||
$field = str_replace(array(']['), '|', $flexformField);
|
||
}
|
||
$selector = '
|
||
<div class="' . $containerCssClass . '" id="' . $suggestId . '">
|
||
... | ... | |
$TSconfig = t3lib_BEfunc::getPagesTSconfig($pageId);
|
||
$queryTables = array();
|
||
$foreign_table_where = '';
|
||
$wizardConfig = $GLOBALS['TCA'][$table]['columns'][$field]['config']['wizards']['suggest'];
|
||
if (isset($GLOBALS['TCA'][$table]['columns'][$field]['config']['allowed'])) {
|
||
$queryTables = t3lib_div::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$field]['config']['allowed']);
|
||
} elseif (isset($GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_table'])) {
|
||
$queryTables = array($GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_table']);
|
||
$foreign_table_where = $GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_table_where'];
|
||
$fieldConfig = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
|
||
|
||
$parts = explode('|', $field);
|
||
if (('tx_templavoila_flex' === $parts[0]) || ('pi_flexform' === $parts[0])) {
|
||
if (is_array($row) && (0 < count($row))) {
|
||
$flexfieldTCAConfig = $GLOBALS['TCA'][$table]['columns'][$parts[0]]['config'];
|
||
$flexformDSArray = t3lib_BEfunc::getFlexFormDS($flexfieldTCAConfig, $row, $table);
|
||
$flexformDSArray = t3lib_div::resolveAllSheetsInDS($flexformDSArray);
|
||
$flexformElement = $parts[count($parts)-2];
|
||
$continue = true;
|
||
foreach ($flexformDSArray as $sheet ) {
|
||
foreach ($sheet as $sheetId => $dataStructure) {
|
||
if (isset($dataStructure['ROOT']['el'][$flexformElement]['TCEforms']['config'])) {
|
||
$fieldConfig = $dataStructure['ROOT']['el'][$flexformElement]['TCEforms']['config'];
|
||
$continue = false;
|
||
break;
|
||
}
|
||
}
|
||
if (!$continue) break;
|
||
}
|
||
$field = str_replace('|', '][', $field);
|
||
}
|
||
}
|
||
|
||
$wizardConfig = $fieldConfig['wizards']['suggest'];
|
||
|
||
if (isset($fieldConfig['allowed'])) {
|
||
$queryTables = t3lib_div::trimExplode(',', $fieldConfig['allowed']);
|
||
} elseif (isset($fieldConfig['foreign_table'])) {
|
||
$queryTables = array($fieldConfig['foreign_table']);
|
||
$foreign_table_where = $fieldConfig['foreign_table_where'];
|
||
// strip ORDER BY clause
|
||
$foreign_table_where = trim(preg_replace('/ORDER[[:space:]]+BY.*/i', '', $foreign_table_where));
|
||
}
|