Project

General

Profile

Bug #21926 ยป bug_13176_v1.diff

Administrator Admin, 2010-01-08 23:47

View differences:

t3lib\class.t3lib_befunc.php Fri Jan 08 23:43:56 2010
/**
* Finds the Data Structure for a FlexForm field
* NOTE ON data structures for deleted records: This function may fail to deliver the data structure for a record for a few reasons: a) The data structure could be deleted (either with deleted-flagged or hard-deleted), b) the data structure is fetched using the ds_pointerField_searchParent in which case any deleted record on the route to the final location of the DS will make it fail. In theory, we can solve the problem in the case where records that are deleted-flagged keeps us from finding the DS - this is done at the markers ###NOTE_A### where we make sure to also select deleted records. However, we generally want the DS lookup to fail for deleted records since for the working website we expect a deleted-flagged record to be as inaccessible as one that is completely deleted from the DB. Any way we look at it, this may lead to integrity problems of the reference index and even lost files if attached. However, that is not really important considering that a single change to a data structure can instantly invalidate large amounts of the reference index which we do accept as a cost for the flexform features. Other than requiring a reference index update, deletion of/changes in data structure or the failure to look them up when completely deleting records may lead to lost files in the uploads/ folders since those are now without a proper reference.
* NOTE ON data structures for deleted records: This function may fail to deliver the data structure for a record for a few reasons:
* a) The data structure could be deleted (either with deleted-flagged or hard-deleted),
* b) the data structure is fetched using the ds_pointerField_searchParent in which case any deleted record on the route to the
* final location of the DS will make it fail. In theory, we can solve the problem in the case where records that are deleted-flagged
* keeps us from finding the DS - this is done at the markers ###NOTE_A### where we make sure to also select deleted records.
* However, we generally want the DS lookup to fail for deleted records since for the working website we expect a deleted-flagged
* record to be as inaccessible as one that is completely deleted from the DB. Any way we look at it, this may lead to integrity problems
* of the reference index and even lost files if attached. However, that is not really important considering that a single change to a
* data structure can instantly invalidate large amounts of the reference index which we do accept as a cost for the flexform features.
* Other than requiring a reference index update, deletion of/changes in data structure or the failure to look them up when completely
* deleting records may lead to lost files in the uploads/ folders since those are now without a proper reference.
* Usage: 5
*
* @param array Field config array
......
// Up to two pointer fields can be specified in a comma separated list.
$pointerFields = t3lib_div::trimExplode(',', $ds_pointerField);
if(count($pointerFields) == 2) { // If we have two pointer fields, the array keys should contain both field values separated by comma. The asterisk "*" catches all values. For backwards compatibility, it's also possible to specify only the value of the first defined ds_pointerField.
if($ds_array[$row[$pointerFields[0]].','.$row[$pointerFields[1]]]) { // Check if we have a DS for the combination of both pointer fields values
$srcPointer = $row[$pointerFields[0]].','.$row[$pointerFields[1]];
} elseif($ds_array[$row[$pointerFields[1]].',*']) { // Check if we have a DS for the value of the first pointer field suffixed with ",*"
$srcPointer = $row[$pointerFields[1]].',*';
} elseif($ds_array['*,'.$row[$pointerFields[1]]]) { // Check if we have a DS for the value of the second pointer field prefixed with "*,"
$srcPointer = '*,'.$row[$pointerFields[1]];
} elseif($ds_array[$row[$pointerFields[0]]]) { // Check if we have a DS for just the value of the first pointer field (mainly for backwards compatibility)
// If we have two pointer fields, the array keys should contain both field values separated by comma. The asterisk "*" catches all values.
// For backwards compatibility, it's also possible to specify only the value of the first defined ds_pointerField.
if(count($pointerFields) == 2) {
// Check if we have a DS for the value of the first pointer field suffixed with ",*"
if($ds_pointerField == $pointerFields[0].',*') {
$srcPointer = $row[$pointerFields[0]].',*';
}
// Check if we have a DS for the value of the second pointer field prefixed with "*,"
elseif($ds_pointerField == '*,'.$pointerFields[1]) {
$srcPointer = '*';
if ($pointerFields[1]) $srcPointer .= ','.$row[$pointerFields[1]];
else $srcPointer .= ',list';
}
// Check if we have a DS for the combination of both pointer fields values
elseif($ds_pointerField == $pointerFields[0].','.$pointerFields[1]) {
$srcPointer = $row[$pointerFields[0]];
if ($row[$pointerFields[1]]) $srcPointer .= ','.$row[$pointerFields[1]];
else $srcPointer .= ',list';
}
// Check if we have a DS for just the value of the first pointer field (mainly for backwards compatibility)
elseif($pointerFields[0]) {
$srcPointer = $row[$pointerFields[0]].',list';
}
} else {
$srcPointer = $row[$pointerFields[0]];
} elseif($pointerFields[0]) {
$srcPointer = $row[$pointerFields[0]].',list';
}
$srcPointer = isset($ds_array[$srcPointer]) ? $srcPointer : 'default';
} else $srcPointer = 'default';
......
if (substr($ds_array[$srcPointer], 0, 5)=='FILE:') {
$file = t3lib_div::getFileAbsFileName(substr($ds_array[$srcPointer], 5));
if ($file && @is_file($file)) {
$dataStructArray = t3lib_div::xml2array(t3lib_div::getUrl($file));
$url = t3lib_div::getURL($file,0,0,array());
$dataStructArray = t3lib_div::xml2array($url);
} else $dataStructArray = 'The file "'.substr($ds_array[$srcPointer], 5).'" in ds-array key "'.$srcPointer.'" was not found ("'.$file.'")'; // Error message.
} else {
$dataStructArray = t3lib_div::xml2array($ds_array[$srcPointer]);
}
} elseif ($ds_pointerField) { // If pointer field AND possibly a table/field is set:
// Value of field pointed to:
$srcPointer = $row[$ds_pointerField];
    (1-1/1)