Project

General

Profile

Feature #22231 » wizzards_suggest_for_flexforms4.5.patch

Chetan Thapliyal, 2011-09-28 14:42

View differences:

class.t3lib_tceforms_suggest.php (working copy)
$containerCssClass = $this->cssClass . ' ' . $this->cssClass . '-position-right';
$suggestId = 'suggest-' . $table . '-' . $field . '-' . $row['uid'];
if ('flex' === $GLOBALS['TCA'][$table]['columns'][$field]['config']['type']) {
$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 ('flex' === $GLOBALS['TCA'][$table]['columns'][$parts[0]]['config']['type']) {
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));
}
(5-5/5)