Index: t3lib/class.t3lib_tceforms_inline.php
===================================================================
--- t3lib/class.t3lib_tceforms_inline.php (revision 9389)
+++ t3lib/class.t3lib_tceforms_inline.php (working copy)
@@ -184,9 +184,6 @@ class t3lib_TCEforms_inline {
$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;
@@ -286,23 +283,9 @@ class t3lib_TCEforms_inline {
$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 .= '
';
@@ -319,7 +302,7 @@ class t3lib_TCEforms_inline {
// 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
@@ -341,6 +324,37 @@ class t3lib_TCEforms_inline {
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;
+
+ }
+
/*******************************************************
*
@@ -912,9 +926,10 @@ class t3lib_TCEforms_inline {
* @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) {
@@ -923,7 +938,7 @@ class t3lib_TCEforms_inline {
$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'];
}
@@ -1203,12 +1218,29 @@ class t3lib_TCEforms_inline {
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');"
)
);
Index: t3lib/jsfunc.inline.js
===================================================================
--- t3lib/jsfunc.inline.js (revision 9389)
+++ t3lib/jsfunc.inline.js (working copy)
@@ -367,6 +367,9 @@ var inline = {
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);
}
@@ -550,7 +553,11 @@ var inline = {
}
},
- 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);
@@ -559,15 +566,21 @@ var inline = {
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