Bug #24961 » 17489_v5.diff
t3lib/class.t3lib_extmgm.php (revision ) | ||
---|---|---|
$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;
|
||
}
|
||
... | ... | |
$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;
|
||
}
|
||
}
|
||
... | ... | |
$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;
|
||
}
|
||
}
|
||
... | ... | |
);
|
||
// 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
|
||
... | ... | |
*/
|
||
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):
|
||
... | ... | |
$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;
|
||
... | ... | |
}
|
||
// Insert data after:
|
||
foreach ($needles['after'] as $needle) {
|
||
if (in_array($needle, $positions)) {
|
||
if (strpos($needle, $insertionPosition) !== FALSE) {
|
||
$itemDetails['rawData'] .= ', ' . $insertionList;
|
||
$isInserted = TRUE;
|
||
break;
|
||
... | ... | |
}
|
||
// Replace with data:
|
||
foreach ($needles['replace'] as $needle) {
|
||
if (in_array($needle, $positions)) {
|
||
if (strpos($needle, $insertionPosition) !== FALSE) {
|
||
$itemDetails['rawData'] = $insertionList;
|
||
$isInserted = TRUE;
|
||
break;
|
||
... | ... | |
}
|
||
|
||
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;
|
||
$insertionList = '';
|
||
$insertionListMatches[2] = array_flip(array_flip($insertionListMatches[2]));
|
||
$listItems = array_diff($insertionListMatches[2], $listItems);
|
||
if (count($listItems) > 0) {
|
||
$insertionListMatches[2] = array_intersect_key($listItems, $insertionListMatches[0]);
|
||
} else {
|
||
} else {
|
||
unset($insertionListMatches[0][$insertionIndex]);
|
||
$insertionDuplicates = TRUE;
|
||
$insertionListMatches[2] = $insertionListMatches[0];
|
||
}
|
||
}
|
||
if (count($insertionListMatches[2]) > 0) {
|
||
$insertionList = implode(',',$insertionListMatches[2]);
|
||
}
|
||
|
||
if ($insertionDuplicates) {
|
||
$insertionList = implode('', $insertionListMatches[0]);
|
||
}
|
||
}
|
||
}
|
||
|
||
return $insertionList;
|
||
}
|
||
|
||
... | ... | |
* @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(
|
||
... | ... | |
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);
|
||
}
|
||
... | ... | |
$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) {
|