Index: t3lib/class.t3lib_extmgm.php =================================================================== --- t3lib/class.t3lib_extmgm.php (revision 10289) +++ t3lib/class.t3lib_extmgm.php (revision ) @@ -483,7 +483,7 @@ $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: @@ -550,23 +550,14 @@ } if ($insertionList && preg_match_all($pattern, $insertionList, $insertionListMatches)) { - $insertionItems = array(); - $insertionDuplicates = FALSE; - - foreach ($insertionListMatches[2] as $insertionIndex => $insertionItem) { - if (!isset($insertionItems[$insertionItem]) && !in_array($insertionItem, $listItems)) { - $insertionItems[$insertionItem] = TRUE; - } else { - unset($insertionListMatches[0][$insertionIndex]); - $insertionDuplicates = TRUE; + $matchedArray = array_diff($insertionListMatches[2], $listItems); + if(count($matchedArray) > 0) { + $insertionArray = array_intersect_key($matchedArray, $insertionListMatches[0]); - } + } + if(count($insertionArray) > 0) { + $insertionList = implode(',',$insertionArray); } - - if ($insertionDuplicates) { - $insertionList = implode('', $insertionListMatches[0]); - } + } - } - return $insertionList; } @@ -580,9 +571,12 @@ * @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 (strpos($item, '--div') !== FALSE) { + $item = '--div--'; + } else if (strpos($item, '--palette') !== FALSE) { + $item = '--palette--'; } $needles = array( @@ -616,7 +610,7 @@ foreach ($itemParts as $itemPart) { $itemDetails = t3lib_div::trimExplode(';', $itemPart, FALSE, 5); $key = $itemDetails[0]; - if (strstr($key, '--')) { + if (strpos($key, '--') !== FALSE) { // 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,11 +645,15 @@ $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 (strpos($item, '--div') !== FALSE) { + $item = '--div--'; + } else if (strpos($item, '--palette') !== FALSE) { + $item = '--palette--'; } + if ($useRawData) { $itemParts[] = $itemDetails['rawData']; } else {