Project

General

Profile

Feature #24019 » 16350_v2.patch

Administrator Admin, 2010-11-16 00:35

View differences:

t3lib/class.t3lib_tceforms_inline.php (working copy)
$foreign_table = $config['foreign_table'];
t3lib_div::loadTCA($foreign_table);
if (t3lib_BEfunc::isTableLocalizable($table)) {
$language = intval($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
}
$minitems = t3lib_div::intInRange($config['minitems'],0);
$maxitems = t3lib_div::intInRange($config['maxitems'],0);
if (!$maxitems) $maxitems=100000;
......
$config['inline']['inlineNewButtonStyle'] = 'display: none;';
}
// Render the level links (create new record, localize all, synchronize):
if ($config['appearance']['levelLinksPosition']!='none') {
$levelLinks = $this->getLevelInteractionLink('newRecord', $nameObject . self::Structure_Separator . $foreign_table, $config);
if ($language>0) {
// Add the "Localize all records" link before all child records:
if (isset($config['appearance']['showAllLocalizationLink']) && $config['appearance']['showAllLocalizationLink']) {
$levelLinks.= $this->getLevelInteractionLink('localize', $nameObject . self::Structure_Separator . $foreign_table, $config);
}
// Add the "Synchronize with default language" link before all child records:
if (isset($config['appearance']['showSynchronizationLink']) && $config['appearance']['showSynchronizationLink']) {
$levelLinks.= $this->getLevelInteractionLink('synchronize', $nameObject . self::Structure_Separator . $foreign_table, $config);
}
}
}
// Add the level links before all child records:
// Render the level links (create new record, localize all, synchronize) before all child records
if (in_array($config['appearance']['levelLinksPosition'], array('both', 'top'))) {
$item.= $levelLinks;
$item .= $this->getLevelLinks($table, $row, $config, 'top');
}
$item .= '<div id="'.$nameObject.'_records">';
......
// Add the level links after all child records:
if (in_array($config['appearance']['levelLinksPosition'], array('both', 'bottom'))) {
$item.= $levelLinks;
$item .= $this->getLevelLinks($table, $row, $config, 'bottom');
}
// add Drag&Drop functions for sorting to TCEforms::$additionalJS_post
......
return $item;
}
/**
* Creates the links above and/or below the inline records
*
* @param string $table: The parent table
* @param array $row: The current row
* @param array $config: The current config
* @param string $position: Position of the current set of links, can be top or bottom
* @return string The rendered links
*/
protected function getLevelLinks ($table, &$row, &$config, $position = 'bottom') {
$language = 0;
$nameObject = $nameObject = $this->inlineNames['object'];
if (t3lib_BEfunc::isTableLocalizable($table)) {
$language = intval($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
}
$levelLinks = $this->getLevelInteractionLink('newRecord', $nameObject . self::Structure_Separator . $config['foreign_table'], $config, $position);
if ($language>0) {
// Add the "Localize all records" link before all child records:
if (isset($config['appearance']['showAllLocalizationLink']) && $config['appearance']['showAllLocalizationLink']) {
$levelLinks.= $this->getLevelInteractionLink('localize', $nameObject . self::Structure_Separator . $config['foreign_table'], $config);
}
// Add the "Synchronize with default language" link before all child records:
if (isset($config['appearance']['showSynchronizationLink']) && $config['appearance']['showSynchronizationLink']) {
$levelLinks.= $this->getLevelInteractionLink('synchronize', $nameObject . self::Structure_Separator . $config['foreign_table'], $config);
}
}
return $levelLinks;
}
/*******************************************************
*
......
* @param string $type: The link type, values are 'newRecord', 'localize' and 'synchronize'.
* @param string $objectPrefix: The "path" to the child record to create (e.g. 'data-parentPageId-partenTable-parentUid-parentField-childTable]')
* @param array $conf: TCA configuration of the parent(!) field
* @param string $position: The position for newly inserted records
* @return string The HTML code of the new link, wrapped in a div
*/
protected function getLevelInteractionLink($type, $objectPrefix, $conf=array()) {
protected function getLevelInteractionLink($type, $objectPrefix, $conf=array(), $position = 'bottom') {
$nameObject = $this->inlineNames['object'];
$attributes = array();
switch($type) {
......
$icon = 'actions-document-new';
$className = 'typo3-newRecordLink';
$attributes['class'] = 'inlineNewButton '.$this->inlineData['config'][$nameObject]['md5'];
$attributes['onclick'] = "return inline.createNewRecord('$objectPrefix')";
$attributes['onclick'] = "return inline.createNewRecord('$objectPrefix', '$position')";
if (isset($conf['inline']['inlineNewButtonStyle']) && $conf['inline']['inlineNewButtonStyle']) {
$attributes['style'] = $conf['inline']['inlineNewButtonStyle'];
}
......
return $this->getErrorMessageForAJAX('Access denied');
}
if (!$current['uid']) {
if (!isset($current['uid']) || in_array($current['uid'], array('top', 'bottom'))) {
// default position if nothing else is configured
$position = 'bottom';
// check if uid was actually a keyword
if (isset($config['appearance']['newRecordPosition'])) {
switch ($config['appearance']['newRecordPosition']) {
case 'top':
$position = 'top';
break;
case 'auto':
$position = ($current['uid'] === 'top' ? 'top' : 'bottom');
break;
case 'bottom':
default:
break;
}
}
$jsonArray = array(
'data' => $item,
'scriptCall' => array(
"inline.domAddNewRecord('bottom','".$this->inlineNames['object']."_records','$objectPrefix',json.data);",
"inline.memorizeAddRecord('$objectPrefix','".$record['uid']."',null,'$foreignUid');"
"inline.domAddNewRecord('$position','" . $this->inlineNames['object'] . "_records', '$objectPrefix', json.data);",
"inline.memorizeAddRecord('$objectPrefix', '" . $record['uid'] . "', '$position', '$foreignUid');"
)
);
t3lib/jsfunc.inline.js (working copy)
if (this.isBelowMax(objectPrefix)) {
if (method == 'bottom')
new Insertion.Bottom(insertObject, htmlData);
else if (method == 'top') {
new Insertion.Top(insertObject, htmlData);
}
else if (method == 'after')
new Insertion.After(insertObject, htmlData);
}
......
}
},
memorizeAddRecord: function(objectPrefix, newUid, afterUid, selectedValue) {
memorizeAddRecord: function(objectPrefix, newUid, position, selectedValue) {
// default value for position
if (position === null) {
position = 'bottom';
}
if (this.isBelowMax(objectPrefix)) {
var objectName = this.prependFormFieldNames+this.parseObjectId('parts', objectPrefix, 3, 1, true);
var formObj = document.getElementsByName(objectName);
......
var records = new Array();
if (formObj[0].value.length) records = formObj[0].value.split(',');
if (afterUid) {
switch (position) {
case 'top':
records.unshift(newUid);
break;
case 'bottom':
records.push(newUid);
break;
default:
var newRecords = new Array();
for (var i=0; i<records.length; i++) {
if (records[i].length) newRecords.push(records[i]);
if (afterUid == records[i]) newRecords.push(newUid);
if (position == records[i]) newRecords.push(newUid);
}
records = newRecords;
} else {
records.push(newUid);
break;
}
formObj[0].value = records.join(',');
}
(2-2/2)