Feature #17297 » 0005610_v4.patch
t3lib/class.t3lib_tceforms.php (Arbeitskopie) | ||
---|---|---|
$specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
|
||
// Getting the selector box items from the system
|
||
$selItems = $this->addSelectOptionsToItemArray($this->initItemArray($PA['fieldConf']),$PA['fieldConf'],$this->setTSconfig($table,$row),$field);
|
||
$selItems = $this->addItems($selItems,$PA['fieldTSConfig']['addItems.']);
|
||
if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
|
||
$selItems = $this->addSelectOptionsToItemArray(
|
||
$this->initItemArray($PA['fieldConf']),
|
||
$PA['fieldConf'],
|
||
$this->setTSconfig($table, $row),
|
||
$field
|
||
);
|
||
// Possibly filter some items:
|
||
$keepItemsFunc = create_function('$value', 'return $value[1];');
|
||
$selItems = t3lib_div::keepItemsInArray($selItems, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc);
|
||
// Possibly add some items:
|
||
$selItems = $this->addItems($selItems, $PA['fieldTSConfig']['addItems.']);
|
||
// Process items by a user function:
|
||
if ($config['itemsProcFunc']) {
|
||
$selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
|
||
}
|
||
// Possibly remove some items:
|
||
$removeItems = t3lib_div::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
|
||
... | ... | |
// Get "removeItems":
|
||
$removeItems = t3lib_div::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
|
||
// Get the array with selected items:
|
||
$itemArray = t3lib_div::trimExplode(',', $PA['itemFormElValue'], 1);
|
||
// Possibly filter some items:
|
||
$keepItemsFunc = create_function('$value', '$parts=explode(\'|\',$value,2); return rawurldecode($parts[0]);');
|
||
$itemArray = t3lib_div::keepItemsInArray($itemArray, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc);
|
||
// Perform modification of the selected items array:
|
||
$itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
|
||
foreach($itemArray as $tk => $tv) {
|
||
$tvP = explode('|',$tv,2);
|
||
$evalValue = rawurldecode($tvP[0]);
|
t3lib/class.t3lib_tceforms_inline.php (Arbeitskopie) | ||
---|---|---|
|
||
if ($foreignConfig['type'] == 'select') {
|
||
// Getting the selector box items from the system
|
||
$selItems = $this->fObj->addSelectOptionsToItemArray($this->fObj->initItemArray($PA['fieldConf']),$PA['fieldConf'],$this->fObj->setTSconfig($table,$row),$field);
|
||
if ($config['itemsProcFunc']) $selItems = $this->fObj->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
|
||
$selItems = $this->fObj->addSelectOptionsToItemArray(
|
||
$this->fObj->initItemArray($PA['fieldConf']),
|
||
$PA['fieldConf'],
|
||
$this->fObj->setTSconfig($table, $row),
|
||
$field
|
||
);
|
||
// Possibly filter some items:
|
||
$keepItemsFunc = create_function('$value', 'return $value[1];');
|
||
$selItems = t3lib_div::keepItemsInArray($selItems, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc);
|
||
// Possibly add some items:
|
||
$selItems = $this->addItems($selItems, $PA['fieldTSConfig']['addItems.']);
|
||
if (isset($config['itemsProcFunc']) && $config['itemsProcFunc']) {
|
||
$selItems = $this->fObj->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
|
||
}
|
||
|
||
// Possibly remove some items:
|
||
$removeItems = t3lib_div::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
|
t3lib/class.t3lib_div.php (Arbeitskopie) | ||
---|---|---|
}
|
||
/**
|
||
* Filters an array to reduce its elements to match the condition.
|
||
* The values in $keepItems can be optionally evaluated by a custom callback function.
|
||
*
|
||
* Example (arguments used to call this function):
|
||
* $array = array(
|
||
* array('aa' => array('first', 'second'),
|
||
* array('bb' => array('third', 'fourth'),
|
||
* array('cc' => array('fifth', 'sixth'),
|
||
* );
|
||
* $keepItems = array('third');
|
||
* $getValueFunc = create_function('$value', 'return $value[0];');
|
||
*
|
||
* Returns:
|
||
* array(
|
||
* array('bb' => array('third', 'fourth'),
|
||
* )
|
||
*
|
||
* @param array $array: The initial array to be filtered/reduced
|
||
* @param mixed $keepItems: The items which are allowed/kept in the array - accepts array or csv string
|
||
* @param string $getValueFunc: (optional) Unique function name set by create_function() used to get the value to keep
|
||
* @return array The filtered/reduced array with the kept items
|
||
*/
|
||
public function keepItemsInArray(array $array, $keepItems, $getValueFunc=null) {
|
||
// Convert strings to arrays:
|
||
if (is_string($keepItems)) {
|
||
$keepItems = t3lib_div::trimExplode(',', $keepItems);
|
||
}
|
||
// create_function() returns a string:
|
||
if (!is_string($getValueFunc)) {
|
||
$getValueFunc = null;
|
||
}
|
||
// Do the filtering:
|
||
if (is_array($array) && is_array($keepItems) && count($keepItems)) {
|
||
foreach ($array as $key => $value) {
|
||
// Get the value to compare by using the callback function:
|
||
$keepValue = (isset($getValueFunc) ? $getValueFunc($value) : $value);
|
||
if (!in_array($keepValue, $keepItems)) {
|
||
unset($array[$key]);
|
||
}
|
||
}
|
||
}
|
||
return $array;
|
||
}
|
||
/**
|
||
* Implodes a multidim-array into GET-parameters (eg. ¶m[key][key2]=value2¶m[key][key3]=value3)
|
||
* Usage: 24
|
||
*
|
typo3/sysext/cms/layout/db_new_content_el.php (Arbeitskopie) | ||
---|---|---|
t3lib_div::loadTCA('tt_content');
|
||
// Get TCEFORM from TSconfig of current page
|
||
$row = array('pid'=>$this->id);
|
||
$TCEFORM_TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig('tt_content',$row);
|
||
$removeItems = t3lib_div::trimExplode(',',$TCEFORM_TSconfig['CType']['removeItems'],1);
|
||
$row = array('pid' => $this->id);
|
||
$TCEFORM_TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig('tt_content', $row);
|
||
$removeItems = t3lib_div::trimExplode(',', $TCEFORM_TSconfig['CType']['removeItems'], 1);
|
||
$keepItems = t3lib_div::trimExplode(',', $TCEFORM_TSconfig['CType']['keepItems'], 1);
|
||
$headersUsed = Array();
|
||
// Traverse wizard items:
|
||
... | ... | |
if (is_array($TCA['tt_content']['columns'][$fN])) {
|
||
// Get information about if the field value is OK:
|
||
$config = &$TCA['tt_content']['columns'][$fN]['config'];
|
||
$authModeDeny = $config['type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode('tt_content',$fN,$fV,$config['authMode']);
|
||
$authModeDeny = ($config['type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode('tt_content', $fN, $fV, $config['authMode']));
|
||
$isNotInKeepItems = (count($keepItems) && !in_array($fV, $keepItems));
|
||
if ($authModeDeny || ($fN=='CType' && in_array($fV,$removeItems))) {
|
||
if ($authModeDeny || ($fN=='CType' && in_array($fV,$removeItems)) || $isNotInKeepItems) {
|
||
// Remove element all together:
|
||
unset($wizardItems[$key]);
|
||
break;
|