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; } } @@ -333,10 +333,10 @@ } else { if (strpos($typeDetails['showitem'], $str) !== FALSE) { $fieldExists = TRUE; - } else if(is_array($GLOBALS['TCA'][$table]['palettes'])) { + } 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,31 +485,30 @@ $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)) { + foreach ($needles['before'] as $key => $needle) { + if (strpos($needle, $insertionPosition) !== FALSE) { $itemDetails['rawData'] = $insertionList . ', ' . $itemDetails['rawData']; $isInserted = TRUE; break; } } // Insert data after: - foreach ($needles['after'] as $needle) { - if (in_array($needle, $positions)) { + foreach ($needles['after'] as $key => $needle) { + if (strpos($needle, $insertionPosition) !== FALSE) { $itemDetails['rawData'] .= ', ' . $insertionList; $isInserted = TRUE; break; } } // Replace with data: - foreach ($needles['replace'] as $needle) { - if (in_array($needle, $positions)) { + foreach ($needles['replace'] as $key => $needle) { + 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( @@ -613,10 +616,10 @@ $items = array(); $itemParts = t3lib_div::trimExplode(',', $itemList, TRUE); - foreach ($itemParts as $itemPart) { + foreach ($itemParts as $itemKey => $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) {