Bug #24961 » 17489_v2.diff
t3lib/class.t3lib_extmgm.php (revision ) | ||
---|---|---|
$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:
|
||
... | ... | |
}
|
||
|
||
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;
|
||
$insertionArray = array_unique($insertionListMatches[2]);
|
||
$diffArray = array_diff($insertionArray, $listItems);
|
||
if(count($diffArray) > 0) {
|
||
$insertionArray = array_intersect_key($diffArray, $insertionListMatches[0]);
|
||
} else {
|
||
} else {
|
||
unset($insertionListMatches[0][$insertionIndex]);
|
||
$insertionDuplicates = TRUE;
|
||
$insertionArray = $insertionListMatches[0];
|
||
}
|
||
}
|
||
if(count($insertionArray) > 0) {
|
||
$insertionList = implode(',',$insertionArray);
|
||
}
|
||
|
||
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 (strpos($item, '--div') !== FALSE) {
|
||
$item = '--div--';
|
||
} else if (strpos($item, '--palette') !== FALSE) {
|
||
$item = '--palette--';
|
||
}
|
||
|
||
$needles = array(
|
||
... | ... | |
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);
|
||
}
|
||
... | ... | |
$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 {
|