Feature #19497 » 0009625_followup.patch
t3lib/class.t3lib_extmgm.php (Arbeitskopie) | ||
---|---|---|
* Compares an existing list of items and a list of items to be inserted
|
||
* and returns a duplicate-free variant of that insertion list.
|
||
*
|
||
* Example:
|
||
* + list: 'field_a, field_b;;;;2-2-2, field_c;;;;3-3-3'
|
||
* + insertion: 'field_b, field_d, field_c;;;4-4-4'
|
||
* -> new insertion: 'field_d'
|
||
*
|
||
* @param string $list: The list of items to be extended
|
||
* @param string $insertionList: The list of items to inserted
|
||
* @return string Duplicate-free list of items to be inserted
|
||
*/
|
||
protected static function removeDuplicatesForInsertion($list, $insertionList) {
|
||
$pattern = '/(^|,)\s*([^,]+)\b[^,]*(,|$)/';
|
||
$pattern = '/(^|,)\s*\b([^;,]+)\b[^,]*/';
|
||
if ($list && preg_match_all($pattern, $list, $listMatches)) {
|
||
if ($insertionList && preg_match_all($pattern, $insertionList, $insertionListMatches)) {
|
||
... | ... | |
$duplicate = preg_quote($duplicate, '/');
|
||
}
|
||
$insertionList = preg_replace(
|
||
array('/(^|,)\s*(' . implode('|', $duplicates) . ')\b[^,]*(,|$)/', ',$'),
|
||
array('/(^|,)\s*\b(' . implode('|', $duplicates) . ')\b[^,]*(,|$)/', '/,$/'),
|
||
array('\3', ''),
|
||
$insertionList
|
||
);
|
- « Previous
- 1
- 2
- 3
- Next »