Project

General

Profile

Bug #23815 » 16096_v2.diff

Administrator Admin, 2010-12-15 21:32

View differences:

t3lib/class.t3lib_extmgm.php (revision )
* @param string Table name
* @param string Field list to add.
* @param string List of specific types to add the field list to. (If empty, all type entries are affected)
* @param string Insert fields before (default) or after one of this fields (commalist with "before:" or "after:" commands). Example: "before:keywords,--palette--;;4,after:description". Palettes must be passed like in the example no matter how the palette definition looks like in TCA.
* @param string Insert fields before (default) or after one
* of this fields (commalist with "before:", "after:" or "replace:" commands).
* Example: "before:keywords,--palette--;;4,after:description".
* Palettes must be passed like in the example no matter how the palette definition looks like in TCA.
* It will add the list of new fields before or after a palette or replace the field inside the palette,
* when the field given in $position is found inside a palette used by the type.
* @return void
*/
public static function addToAllTCAtypes($table, $str, $specificTypesList = '', $position = '') {
......
if ($str && is_array($GLOBALS['TCA'][$table]) && is_array($GLOBALS['TCA'][$table]['types'])) {
foreach ($GLOBALS['TCA'][$table]['types'] as $type => &$typeDetails) {
if ($specificTypesList === '' || t3lib_div::inList($specificTypesList, $type)) {
if ($position != '' && is_array($GLOBALS['TCA'][$table]['palettes'])) {
$fieldExists = FALSE;
$positionArray = t3lib_div::trimExplode(':', $position);
if($positionArray[0] == 'replace') {
foreach($GLOBALS['TCA'][$table]['palettes'] as $palette => $paletteDetails) {
if (preg_match('/\b' . $palette . '/', $typeDetails['showitem']) != FALSE
&& preg_match('/\b' . $positionArray[1] . '/', $paletteDetails['showitem']) != FALSE) {
self::addFieldsToPalette($table, $palette, $str, $position);
$fieldExists = TRUE;
}
}
} else {
foreach($GLOBALS['TCA'][$table]['palettes'] as $palette => $paletteDetails) {
if (strstr($str, $typeDetails['showitem']) != FALSE
|| strstr($str, $paletteDetails['showitem']) != FALSE) {
$fieldExists = TRUE;
} else if (preg_match('/\b' . $palette . '/', $typeDetails['showitem']) != FALSE
&& preg_match('/\b' . $positionArray[1] . '/', $paletteDetails['showitem']) != FALSE) {
$position = $positionArray[0] . ':--palette--;;' . $palette;
}
}
}
}
if ($fieldExists === FALSE) {
$typeDetails['showitem'] = self::executePositionedStringInsertion(
$typeDetails['showitem'],
$str,
$position
);
}
}
}
}
$typeDetails['showitem'] = self::executePositionedStringInsertion(
$typeDetails['showitem'],
$str,
$position
);
}
}
}
}
}
/**
* Adds new fields to all palettes of an existing field.
......
* @param string $field: Name of the field that has the palette to be extended
* @param string $addFields: List of fields to be added to the palette
* @param string $insertionPosition: Insert fields before (default) or after one
* of this fields (commalist with "before:" or "after:" commands).
* of this fields (commalist with "before:", "after:" or "replace:" commands).
* Example: "before:keywords,--palette--;;4,after:description".
* Palettes must be passed like in the example no matter how the
* palette definition looks like in TCA.
......
* @param string $palette: Name of the palette to be extended
* @param string $addFields: List of fields to be added to the palette
* @param string $insertionPosition: Insert fields before (default) or after one
* of this fields (commalist with "before:" or "after:" commands).
* of this fields (commalist with "before:", "after:" or "replace:" commands).
* Example: "before:keywords,--palette--;;4,after:description".
* Palettes must be passed like in the example no matter how the
* palette definition looks like in TCA.
......
*
* @param string $addFields: List of fields to be added to the user settings
* @param string $insertionPosition: Insert fields before (default) or after one
* of this fields (commalist with "before:" or "after:" commands).
* of this fields (commalist with "before:", "after:" or "replace:" commands).
* Example: "before:password,after:email".
* @return void
*/
......
}
}
// Insert data after:
foreach ($needles['after'] as $needle) {
if (in_array($needle, $positions)) {
$itemDetails['rawData'] .= ', ' . $insertionList;
$isInserted = TRUE;
break;
}
}
foreach ($needles['after'] as $needle) {
if (in_array($needle, $positions)) {
$itemDetails['rawData'] .= ', ' . $insertionList;
$isInserted = TRUE;
break;
}
}
// Replace with data:
foreach ($needles['replace'] as $needle) {
if (in_array($needle, $positions)) {
$itemDetails['rawData'] = $insertionList;
$isInserted = TRUE;
break;
}
}
// Break if insertion was already done:
if ($isInserted) {
break;
......
$needles = array(
'before' => array($item, 'before:' . $item),
'after' => array('after:' . $item),
'after' => array('after:' . $item),
'replace' => array('replace:' . $item),
);
if ($itemDetails['palette']) {
$palette = $item . ';;' . $itemDetails['palette'];
$needles['before'][] = $palette;
$needles['before'][] = 'before:' . $palette;
$needles['after'][] = 'after:' . $palette;
$needles['after'][] = 'after:' . $palette;
$needles['replace'][] = 'replace:' . $palette;
}
return $needles;
(2-2/2)