Project

General

Profile

Bug #18646 » 0008165_unfinished.patch

Administrator Admin, 2008-04-19 20:54

View differences:

t3lib/class.t3lib_tceforms.php (Arbeitskopie)
'check' => array('cols', 'showIfRTE'),
'select' => array('size', 'autoSizeMax', 'maxitems', 'minitems'),
'group' => array('size', 'autoSizeMax', 'max_size', 'show_thumbs', 'maxitems', 'minitems', 'disable_controls'),
'inline' => array('appearance', 'behaviour', 'foreign_label', 'foreign_selector', 'foreign_unique', 'maxitems', 'minitems', 'size', 'autoSizeMax', 'symmetric_label'),
'inline' => array('appearance', 'behaviour', 'foreign_label', 'foreign_selector', 'foreign_unique', 'maxitems', 'minitems', 'size', 'autoSizeMax', 'symmetric_label', 'symmetric_selector'),
);
// Create instance of t3lib_TCEforms_inline only if this a non-IRRE-AJAX call:
t3lib/class.t3lib_tceforms_inline.php (Arbeitskopie)
var $prependCmdFieldNames; // reference to $this->fObj->prependCmdFieldNames
protected $hookObjects = array(); // array containing instances of hook classes called once for IRRE objects
protected $inCombinationMode = false; // indicates whether already a combination rendering is active (no nested combination views allowed!)
/**
......
*/
function renderCombinationTable(&$rec, $appendFormFieldNames, $config = array()) {
$foreign_table = $config['foreign_table'];
$foreign_selector = $config['foreign_selector'];
$selectorField = $this->getSelectorField($rec, $config);
if ($foreign_selector && $config['appearance']['useCombination']) {
$comboConfig = $GLOBALS['TCA'][$foreign_table]['columns'][$foreign_selector]['config'];
if (!$this->inCombinationMode && $selectorField && $config['appearance']['useCombination']) {
$this->inCombinationMode = true;
$comboConfig = $GLOBALS['TCA'][$foreign_table]['columns'][$selectorField]['config'];
$comboRecord = array();
// If record does already exist, load it:
if ($rec[$foreign_selector] && t3lib_div::testInt($rec[$foreign_selector])) {
if ($rec[$selectorField] && t3lib_div::testInt($rec[$selectorField])) {
$comboRecord = $this->getRecord(
$this->inlineFirstPid,
$comboConfig['foreign_table'],
$rec[$foreign_selector]
$rec[$selectorField]
);
$isNewRecord = false;
// It is a new record, create a new record virtually:
......
}
// 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) {
$parentFormFieldName = $this->prependFormFieldNames.$appendFormFieldNames.'['.$foreign_selector.']';
if ($isNewRecord || $config['foreign_unique'] == $selectorField) {
$parentFormFieldName = $this->prependFormFieldNames.$appendFormFieldNames.'['.$selectorField.']';
$out .= '<input type="hidden" name="'.$parentFormFieldName.'" value="'.$comboRecord['uid'].'" />';
}
$this->inCombinationMode = false;
}
return $out;
......
foreach($itemArray as $uid) {
// Get the records for this uid using t3lib_transferdata:
if ($record = $this->getRecord($pid, $table, $uid)) {
// If this record was already processed in the current structure, show it virtually:
if ($this->isPartOfStructure($table, $record['uid'])) {
$record['__virtual'] = true;
}
$records[$uid] = $record;
}
}
......
}
}
/**
* Determines whether a set of table-uid or table-uid-field is part of the current structure stack.
* This can be used to figure out if a record was already processed and thus can determine endless recursions.
*
* @param string $table: name of the table to search for
* @param mixed $uid: uid of the record to search for (can be integer or string, like 'NEW...')
* @param string $field: (optional) name of the field to search for
* @return boolean Whether the set of table-uid or table-uid-field is present in the current structure stack
*/
protected function isPartOfStructure($table, $uid, $field='') {
$structureDepth = $this->getStructureDepth();
for ($i = 0; $i < $structureDepth; $i++) {
$level = $this->getStructureLevel($i);
if ($level['table']==$table && $level['uid']==$uid && (!$field || $level['field']==$field)) {
return true;
}
}
return false;
}
/*******************************************************
*
* Helper functions
......
'%OR' => array(
'%AND' => array(
'appearance' => array('useCombination' => true),
'foreign_selector' => $field,
'%OR' => array(
'foreign_selector' => $field,
'symmetric_selector' => $field,
),
),
'MM' => $config['MM']
),
......
$result.= '>'.$text.'</a>';
return $result;
}
/**
* Returns the correct selector field (foreign_selector or symmetric_selector) which depends
* on the disposal of the relationship in general (asymmetric or symmetric). If symmetric
* relations are used, it depends furthermore on the side the parent record is currently accessed.
*
* @param array $childRecord: Child record (in asymmetric/symmetric context normally from intermediate table)
* @param array $parentConfig: The field configuration of the parent
* @param mixed $parentUid: The uid of the parent (can also be NEW... if it's a new record)
* @return mixed Returns the selector field (string) or false (boolean) if this couldn't be determined
*/
protected function getSelectorField(array $childRecord, array $parentConfig, $parentUid=0) {
// Fetch the uid of the parent from current stack:
if (!$parentUid) {
$parent = $this->getStructureLevel(-1);
$parentUid = $parent['uid'];
}
$selectorField = false;
$isOnSymmetricSide = t3lib_loadDBGroup::isOnSymmetricSide($parentUid, $parentConfig, $childRecord);
if (!$isOnSymmetricSide && isset($parentConfig['foreign_selector']) && $parentConfig['foreign_selector']) {
$selectorField = $parentConfig['foreign_selector'];
} elseif ($isOnSymmetricSide && isset($parentConfig['symmetric_selector']) && $parentConfig['symmetric_selector']) {
$selectorField = $parentConfig['symmetric_selector'];
}
return $selectorField;
}
}
(1-1/2)