Project

General

Profile

Bug #20962 » 0011834_v2_ws.patch

Administrator Admin, 2009-08-31 19:39

View differences:

t3lib/class.t3lib_extmgm.php (Arbeitskopie)
*/
public static function addFieldsToAllPalettesOfField($table, $field, $addFields, $insertionPosition = '') {
$generatedPalette = '';
$processedPalettes = array();
t3lib_div::loadTCA($table);
if (isset($GLOBALS['TCA'][$table]['columns'][$field])) {
......
// If the field already has a palette, extend it:
if ($items[$field]['details']['palette']) {
$palette = $items[$field]['details']['palette'];
if (!isset($processedPalettes[$palette])) {
self::addFieldsToPalette($table, $palette, $addFields, $insertionPosition);
$processedPalettes[$palette] = true;
}
// If there's not palette yet, create one:
} else {
if ($generatedPalette) {
......
);
// If it's a new palette, just set the data:
} else {
$paletteData['showitem'] = $addFields;
$paletteData['showitem'] = self::removeDuplicatesForInsertion($addFields);
}
}
}
......
*/
protected static function executePositionedStringInsertion($list, $insertionList, $insertionPosition = '') {
$list = trim($list);
$insertionList = self::removeDuplicatesForInsertion($list, $insertionList);
$insertionList = self::removeDuplicatesForInsertion($insertionList, $list);
if ($insertionList) {
// Append data to the end (default):
if ($insertionPosition === '') {
$list.= ($list ? ', ' : '') . $insertionList;
......
$list = self::generateItemList($items, true);
}
}
}
return $list;
}
......
* + 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
* @param string $list: The list of items to be extended (default: '')
* @return string Duplicate-free list of items to be inserted
*/
protected static function removeDuplicatesForInsertion($list, $insertionList) {
protected static function removeDuplicatesForInsertion($insertionList, $list = '') {
$pattern = '/(^|,)\s*\b([^;,]+)\b[^,]*/';
$listItems = array();
if ($list && preg_match_all($pattern, $list, $listMatches)) {
$listItems = $listMatches[2];
}
if ($insertionList && preg_match_all($pattern, $insertionList, $insertionListMatches)) {
$duplicates = array_intersect($listMatches[2], $insertionListMatches[2]);
if ($duplicates) {
foreach ($duplicates as &$duplicate) {
$duplicate = preg_quote($duplicate, '/');
$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;
}
$insertionList = preg_replace(
array('/(^|,)\s*\b(' . implode('|', $duplicates) . ')\b[^,]*(,|$)/', '/,$/'),
array('\3', ''),
$insertionList
);
}
if ($insertionDuplicates) {
$insertionList = implode('', $insertionListMatches[0]);
}
}
(3-3/3)