Bug #17255 » 0005514_v3.patch
t3lib/class.t3lib_tceforms_inline.php (Arbeitskopie) | ||
---|---|---|
* @return string A HTML string with <table> tag around.
|
||
*/
|
||
function renderCombinationTable(&$rec, $appendFormFieldNames, $config = array()) {
|
||
$foreign_table = $config['foreign_table'];
|
||
$foreign_selector = $config['foreign_selector'];
|
||
if ($foreign_selector && $config['appearance']['useCombination']) {
|
||
$comboConfig = $GLOBALS['TCA'][$foreign_table]['columns'][$foreign_selector]['config'];
|
||
$comboConfig = $this->getPossibleRecordsSelectorConfig($config, $foreign_selector);
|
||
|
||
if ($comboConfig['type'] !== false && $comboConfig['table'] && $config['appearance']['useCombination']) {
|
||
$comboRecord = array();
|
||
// record does already exist, so load it
|
||
if (t3lib_div::testInt($rec[$foreign_selector])) {
|
||
// Fetch only the uid if the type is group/db (e.g. tx_myext_table_123):
|
||
if ($comboConfig['type'] == 'groupdb') {
|
||
$idParts = t3lib_div::revExplode('_', $rec[$foreign_selector], 2);
|
||
$comboRecordId = $idParts[1];
|
||
$comboRecordIdPrefix = $comboConfig['table'].'_';
|
||
} else {
|
||
$comboRecordId = $rec[$foreign_selector];
|
||
}
|
||
// Record does already exist, load it:
|
||
if (t3lib_div::testInt($comboRecordId)) {
|
||
$comboRecord = $this->getRecord(
|
||
$this->inlineFirstPid,
|
||
$comboConfig['foreign_table'],
|
||
$rec[$foreign_selector]
|
||
$comboConfig['table'],
|
||
$comboRecordId
|
||
);
|
||
$isNewRecord = false;
|
||
// it's a new record, so get some default data
|
||
// It is a new record, create a new record virtually:
|
||
} else {
|
||
$comboRecord = $this->getNewRecord(
|
||
$this->inlineFirstPid,
|
||
$comboConfig['foreign_table']
|
||
$comboConfig['table']
|
||
);
|
||
$comboRecordId = $comboRecord['uid'];
|
||
$isNewRecord = true;
|
||
}
|
||
// get the TCEforms interpretation of the TCA of the child table
|
||
$out = $this->fObj->getMainFields($comboConfig['foreign_table'], $comboRecord);
|
||
// Render the form fields for the comboRecord using TCEforms:
|
||
$out = $this->fObj->getMainFields($comboConfig['table'], $comboRecord);
|
||
$out = $this->wrapFormsSection($out, array(), array('class' => 'wrapperAttention'));
|
||
// if this is a new record, add a pid value to store this record and the pointer value for the intermediate table
|
||
// If comboRecord is new, add the pid value for it:
|
||
if ($isNewRecord) {
|
||
$comboFormFieldName = $this->prependFormFieldNames.'['.$comboConfig['foreign_table'].']['.$comboRecord['uid'].'][pid]';
|
||
$comboFormFieldName = $this->prependFormFieldNames.'['.$comboConfig['table'].']['.$comboRecordId.'][pid]';
|
||
$out .= '<input type="hidden" name="'.$comboFormFieldName.'" value="'.$this->inlineFirstPid.'"/>';
|
||
}
|
||
// if the foreign_selector field is also responsible for uniqueness, tell the browser the uid of the "other" side of the relation
|
||
if ($isNewRecord || $config['foreign_unique'] == $foreign_selector) {
|
||
// Create the relationship in case of uniqueness or the the intermediate record was dynamically imported or created:
|
||
if (!t3lib_div::testInt($rec['uid']) || $config['foreign_unique'] == $foreign_selector) {
|
||
$parentFormFieldName = $this->prependFormFieldNames.$appendFormFieldNames.'['.$foreign_selector.']';
|
||
$out .= '<input type="hidden" name="'.$parentFormFieldName.'" value="'.$comboRecord['uid'].'" />';
|
||
$out .= '<input type="hidden" name="'.$parentFormFieldName.'" value="'.$comboRecordIdPrefix.$comboRecordId.'" />';
|
||
}
|
||
}
|
||
... | ... | |
$localMatches += $this->arrayCompareComplex($subjectArray, $value, $type) ? 1 : 0;
|
||
// directly compare a value
|
||
} else {
|
||
$localMatches += isset($subjectArray[$key]) && isset($value) && $subjectArray[$key] === $value ? 1 : 0;
|
||
if (isset($subjectArray[$key]) && isset($value)) {
|
||
// Boolean match:
|
||
if (is_bool($value)) {
|
||
$localMatches += (!($subjectArray[$key] xor $value) ? 1 : 0);
|
||
// Value match:
|
||
} elseif (t3lib_div::testInt($subjectArray[$key]) && t3lib_div::testInt($value)) {
|
||
$localMatches += ($subjectArray[$key] == $value ? 1 : 0);
|
||
// Value and type match:
|
||
} else {
|
||
$localMatches += ($subjectArray[$key] === $value ? 1 : 0);
|
||
}
|
||
}
|
||
}
|
||
// if one or more matches are required ('OR'), return true after the first successful match
|
||
... | ... | |
'foreign_table' => $table,
|
||
'%OR' => array(
|
||
'%AND' => array(
|
||
'appearance' => array('useCombination' => 1),
|
||
'appearance' => array('useCombination' => true),
|
||
'foreign_selector' => $field,
|
||
),
|
||
'MM' => $config['MM']
|
t3lib/class.t3lib_tcemain.php (Arbeitskopie) | ||
---|---|---|
}
|
||
// For group types:
|
||
if ($tcaFieldConf['type']=='group') {
|
||
switch($tcaFieldConf['internal_type']) {
|
||
case 'file':
|
||
$valueArray = $this->checkValue_group_select_file(
|
||
$valueArray,
|
||
$tcaFieldConf,
|
||
$curValue,
|
||
$uploadedFiles,
|
||
$status,
|
||
$table,
|
||
$id,
|
||
$recFID
|
||
);
|
||
break;
|
||
case 'db':
|
||
$valueArray = $this->checkValue_group_select_processDBdata($valueArray,$tcaFieldConf,$id,$status,'group', $table);
|
||
break;
|
||
}
|
||
if ($tcaFieldConf['type']=='group' && $tcaFieldConf['internal_type'] == 'file') {
|
||
$valueArray = $this->checkValue_group_select_file(
|
||
$valueArray,
|
||
$tcaFieldConf,
|
||
$curValue,
|
||
$uploadedFiles,
|
||
$status,
|
||
$table,
|
||
$id,
|
||
$recFID
|
||
);
|
||
}
|
||
// For select types which has a foreign table attached:
|
||
if ($tcaFieldConf['type']=='select' && $tcaFieldConf['foreign_table']) {
|
||
// check, if there is a NEW... id in the value, that should be substituded later
|
||
// For the types group/db and select with foreign_field:
|
||
if ($this->isReferenceField($tcaFieldConf)) {
|
||
$type = $tcaFieldConf['type'];
|
||
// Check, if there is a NEW... id in the value, that should be substituded (remapped) later:
|
||
if (strpos($value, 'NEW') !== false) {
|
||
$this->remapStackRecords[$table][$id] = array('remapStackIndex' => count($this->remapStack));
|
||
$this->remapStack[] = array(
|
||
'func' => 'checkValue_group_select_processDBdata',
|
||
'args' => array($valueArray,$tcaFieldConf,$id,$status,'select',$table),
|
||
'pos' => array('valueArray' => 0, 'tcaFieldConf' => 1, 'id' => 2, 'table' => 5),
|
||
'args' => array($valueArray,$tcaFieldConf,$id,$status,$type,$table),
|
||
'pos' => array('valueArray' => 0, 'tcaFieldConf' => 1, 'id' => 2, 'type' => 4, 'table' => 5),
|
||
'field' => $field
|
||
);
|
||
$unsetResult = true;
|
||
} else {
|
||
$valueArray = $this->checkValue_group_select_processDBdata($valueArray,$tcaFieldConf,$id,$status,'select', $table);
|
||
$valueArray = $this->checkValue_group_select_processDBdata($valueArray,$tcaFieldConf,$id,$status,$type,$table);
|
||
}
|
||
}
|
||
... | ... | |
$field = $remapAction['field'];
|
||
$id = $remapAction['args'][$remapAction['pos']['id']];
|
||
$rawId = $id;
|
||
$type = $remapAction['args'][$remapAction['pos']['type']];
|
||
$table = $remapAction['args'][$remapAction['pos']['table']];
|
||
$valueArray = $remapAction['args'][$remapAction['pos']['valueArray']];
|
||
$tcaFieldConf = $remapAction['args'][$remapAction['pos']['tcaFieldConf']];
|
||
... | ... | |
if(is_array($valueArray)) {
|
||
foreach($valueArray as $key => $value) {
|
||
if(strpos($value, 'NEW') !== false) {
|
||
// fetch the proper uid as integer for the NEW...-ID
|
||
$valueArray[$key] = $this->substNEWwithIDs[$value];
|
||
// set a hint that this was a new child record
|
||
// Fetch the proper uid as integer for the NEW... id:
|
||
if ($type == 'group') {
|
||
$valueParts = t3lib_div::revExplode('_', $value, 2);
|
||
$valueParts[1] = $this->substNEWwithIDs[$valueParts[1]];
|
||
$valueArray[$key] = implode('_', $valueParts);
|
||
} else {
|
||
$valueArray[$key] = $this->substNEWwithIDs[$value];
|
||
}
|
||
// Set a hint that this was a new child record:
|
||
$this->newRelatedIDs[$table][] = $valueArray[$key];
|
||
}
|
||
}
|