Project

General

Profile

Bug #17255 » 0005514_v4_41.patch

Administrator Admin, 2007-06-26 09:03

View differences:

t3lib/jsfunc.inline.js (Arbeitskopie)
},
deleteRecord: function(objectId) {
var i, j, inlineRecords, records, childObjectId, childTable;
var i, j, comboRecords, inlineRecords, records, childObjectId, childTable;
var objectPrefix = this.parseFormElementName('full', objectId, 0 , 1);
var elName = this.parseFormElementName('full', objectId, 2);
var shortName = this.parseFormElementName('parts', objectId, 2);
......
// if the record already exists in storage, mark it to be deleted on clicking the save button
} else {
document.getElementsByName('cmd'+shortName+'[delete]')[0].disabled = false;
new Effect.Fade(objectId+'_div');
comboRecords = document.getElementsByClassName('inlineCombination', objectId+'_div');
new Effect.Fade(objectId+'_div', {
afterFinish: function() { for (var i=0; i<comboRecords.length; i++) { Element.remove(comboRecords[i]); } }
});
// Combined Mode: Remove from TBE_EDITOR (required fields, required range, etc.):
if (TBE_EDITOR && TBE_EDITOR.removeElement) {
for (i=0; i<comboRecords.length; i++) {
childObjectId = this.parseFormElementName('none', comboRecords[i].id, 1);
childTable = this.parseFormElementName('none', comboRecords[i].id, 1, 1);
TBE_EDITOR.removeElement(this.prependFormFieldNames+'['+childTable+']['+childObjectId+']');
}
}
}
// Remove from TBE_EDITOR (required fields, required range, etc.):
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);
$out = $this->wrapFormsSection($out, array(), array('class' => 'wrapperAttention'));
// Render the form fields for the comboRecord using TCEforms:
$out = $this->fObj->getMainFields($comboConfig['table'], $comboRecord);
$wrapArray = array(
'id' => 'combination['.$comboConfig['table'].']['.$comboRecordId.']',
'class' => 'wrapperAttention inlineCombination',
);
$out = $this->wrapFormsSection($out, array(), $wrapArray);
// 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.'" />';
}
}
......
$config['appearance']['newRecordLinkPosition'] = 'top';
}
// Combined mode with selector and without uniquness doesn't make any sense:
// @TODO: Maybe foreign_unique could be changed to "isUnique" in appearance
if ($config['foreign_selector'] && $config['appearance']['useCombination'] && !$config['foreign_unique']) {
$config['foreign_unique'] = $config['foreign_selector'];
}
return true;
}
......
$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 for numbers:
} elseif (is_numeric($subjectArray[$key]) && is_numeric($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];
}
}
(3-3/4)