Index: t3lib/class.t3lib_extmgm.php =================================================================== --- t3lib/class.t3lib_extmgm.php (revision 10289) +++ t3lib/class.t3lib_extmgm.php (revision ) @@ -312,8 +312,8 @@ $positionArray = t3lib_div::trimExplode(':', $position); if ($positionArray[0] == 'replace') { foreach ($GLOBALS['TCA'][$table]['palettes'] as $palette => $paletteDetails) { - if (preg_match('/\b' . $palette . '\b/', $typeDetails['showitem']) > 0 - && preg_match('/\b' . $positionArray[1] . '\b/', $paletteDetails['showitem']) > 0) { + if (preg_match('/\b' . $positionArray[1] . '\b/', $paletteDetails['showitem']) > 0 + && preg_match('/\b' . $palette . '\b/', $typeDetails['showitem']) > 0) { self::addFieldsToPalette($table, $palette, $str, $position); $fieldExists = TRUE; } @@ -323,8 +323,8 @@ $fieldExists = TRUE; } else { foreach ($GLOBALS['TCA'][$table]['palettes'] as $palette => $paletteDetails) { - if (preg_match('/\b' . $palette . '\b/', $typeDetails['showitem']) > 0 - && preg_match('/\b' . $positionArray[1] . '\b/', $paletteDetails['showitem']) > 0) { + if (preg_match('/\b' . $positionArray[1] . '\b/', $paletteDetails['showitem']) > 0 + && preg_match('/\b' . $palette . '\b/', $typeDetails['showitem']) > 0) { $position = $positionArray[0] . ':--palette--;;' . $palette; } } @@ -335,8 +335,8 @@ $fieldExists = TRUE; } else if(is_array($GLOBALS['TCA'][$table]['palettes'])) { foreach ($GLOBALS['TCA'][$table]['palettes'] as $palette => $paletteDetails) { - if (preg_match('/\b' . $palette . '\b/', $typeDetails['showitem']) > 0 - && strpos($paletteDetails['showitem'], $str) !== FALSE) { + if (strpos($paletteDetails['showitem'], $str) !== FALSE + && preg_match('/\b' . $palette . '\b/', $typeDetails['showitem']) > 0) { $fieldExists = TRUE; } } @@ -433,10 +433,12 @@ ); // If it's a new palette, just set the data: } else { + if($addFields) { - $paletteData['showitem'] = self::removeDuplicatesForInsertion($addFields); - } - } - } + $paletteData['showitem'] = self::removeDuplicatesForInsertion($addFields); + } + } + } + } /** * Adds a list of new fields to the TYPO3 USER SETTINGS configuration "showitem" list, the array with @@ -472,7 +474,10 @@ */ protected static function executePositionedStringInsertion($list, $insertionList, $insertionPosition = '') { $list = trim($list); + + if($insertionList) { - $insertionList = self::removeDuplicatesForInsertion($insertionList, $list); + $insertionList = self::removeDuplicatesForInsertion($insertionList, $list); + } if ($insertionList) { // Append data to the end (default): @@ -480,15 +485,14 @@ $list .= ($list ? ', ' : '') . $insertionList; // Insert data before or after insertion points: } else { - $positions = t3lib_div::trimExplode(',', $insertionPosition, TRUE); $items = self::explodeItemList($list); $isInserted = FALSE; - // Iterate through all fields an check whether it's possible to inserte there: + // Iterate through all fields and check whether it's possible to insert there: foreach ($items as $item => &$itemDetails) { $needles = self::getInsertionNeedles($item, $itemDetails['details']); // Insert data before: foreach ($needles['before'] as $needle) { - if (in_array($needle, $positions)) { + if (strpos($needle, $insertionPosition) !== FALSE) { $itemDetails['rawData'] = $insertionList . ', ' . $itemDetails['rawData']; $isInserted = TRUE; break; @@ -496,7 +500,7 @@ } // Insert data after: foreach ($needles['after'] as $needle) { - if (in_array($needle, $positions)) { + if (strpos($needle, $insertionPosition) !== FALSE) { $itemDetails['rawData'] .= ', ' . $insertionList; $isInserted = TRUE; break; @@ -504,7 +508,7 @@ } // Replace with data: foreach ($needles['replace'] as $needle) { - if (in_array($needle, $positions)) { + if (strpos($needle, $insertionPosition) !== FALSE) { $itemDetails['rawData'] = $insertionList; $isInserted = TRUE; break; @@ -566,8 +570,6 @@ $insertionList = implode('', $insertionListMatches[0]); } } - - return $insertionList; } /** @@ -580,9 +582,10 @@ * @return array The needled to be used for inserting content before or after existing fields/items */ protected static function getInsertionNeedles($item, array $itemDetails) { - if (strstr($item, '--')) { + - // If $item is a separator (--div--) or palette (--palette--) then it may have been appended by a unique number. This must be stripped away here. + // If $item is a separator (--div--) or palette (--palette--) then it may have been appended by a unique number. This must be stripped away here. - $item = preg_replace('/[0-9]+$/', '', $item); + if ($item{0} === '-') { + $item = rtrim($item, '0123456789'); } $needles = array( @@ -616,7 +619,7 @@ foreach ($itemParts as $itemPart) { $itemDetails = t3lib_div::trimExplode(';', $itemPart, FALSE, 5); $key = $itemDetails[0]; - if (strstr($key, '--')) { + if ($key{0} === '-') { // If $key is a separator (--div--) or palette (--palette--) then it will be appended by a unique number. This must be removed again when using this value! $key .= count($items); } @@ -651,9 +654,10 @@ $itemParts = array(); foreach ($items as $item => $itemDetails) { - if (strstr($item, '--')) { + - // If $item is a separator (--div--) or palette (--palette--) then it may have been appended by a unique number. This must be stripped away here. + // If $item is a separator (--div--) or palette (--palette--) then it may have been appended by a unique number. This must be stripped away here. - $item = preg_replace('/[0-9]+$/', '', $item); + if ($item{0} === '-') { + $item = rtrim($item, '0123456789'); } if ($useRawData) {