//XCLASS
$TYPO3_CONF_VARS[TYPO3_MODE][‘XCLASS’][‘t3lib/class.t3lib_tceforms.php’]=t3lib_extMgm::extPath(‘ext_name’).’class.ux_t3lib_tceforms.php’;
class.ux_t3lib_tceforms.php:
<?php
class ux_t3lib_tceforms extends t3lib_TCEforms{
/**
* Creates a multiple-selector box (two boxes, side-by-side)
* (Render function for getSingleField_typeSelect())
*
* @param string See getSingleField_typeSelect()
* @param string See getSingleField_typeSelect()
* @param array See getSingleField_typeSelect()
* @param array See getSingleField_typeSelect()
* @param array (Redundant) content of $PA[‘fieldConf’][‘config’] (for convenience)
* @param array Items available for selection
* @param string Label for no-matching-value
* @return string The HTML code for the item
* @see getSingleField_typeSelect()
*/
function getSingleField_typeSelect_multiple($table,$field,$row,&$PA,$config,$selItems,$nMV_label) {
$disabled = ”;
if($this->renderReadonly || $config[‘readOnly’]) {
$disabled = ‘ disabled=”disabled”‘;
}
// Setting this hidden field (as a flag that JavaScript can read out)
if (!$disabled) {
$item.= ‘<input type=”hidden” name=”‘.$PA[‘itemFormElName’].’_mul” value=”‘.($config[‘multiple’]?1:0).'” />’;
}
// Set max and min items:
$maxitems = t3lib_div::intInRange($config[‘maxitems’],0);
if (!$maxitems) $maxitems=100000;
$minitems = t3lib_div::intInRange($config[‘minitems’],0);
// Register the required number of elements:
$this->registerRequiredProperty(‘range’, $PA[‘itemFormElName’], array($minitems,$maxitems,’imgName’=>$table.’_’.$row[‘uid’].’_’.$field));
// 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:
foreach($itemArray as $tk => $tv) {
$tvP = explode(‘|’,$tv,2);
$evalValue = rawurldecode($tvP[0]);
$isRemoved = in_array($evalValue,$removeItems) || ($config[‘form_type’]==’select’ && $config[‘authMode’] && !$GLOBALS[‘BE_USER’]->checkAuthMode($table,$field,$evalValue,$config[‘authMode’]));
if ($isRemoved && !$PA[‘fieldTSConfig’][‘disableNoMatchingValueElement’] && !$config[‘disableNoMatchingValueElement’]) {
$tvP[1] = rawurlencode(@sprintf($nMV_label, $evalValue));
} elseif (isset($PA[‘fieldTSConfig’][‘altLabels.’][$evalValue])) {
$tvP[1] = rawurlencode($this->sL($PA[‘fieldTSConfig’][‘altLabels.’][$evalValue]));
}
if ($tvP[1] == ”) {
// Case: flexform, default values supplied, no label provided (bug #9795)
foreach ($selItems as $selItem) {
if ($selItem[1] == $tvP[0]) {
$tvP[1] = $selItem[0];
break;
}
}
}
$itemArray[$tk] = implode(‘|’,$tvP);
}
$itemsToSelect = ”;
if(!$disabled) {
// Create option tags:
$opt = array();
$styleAttrValue = ”;
foreach($selItems as $p) {
if ($config[‘iconsInOptionTags’]) {
$styleAttrValue = $this->optionTagStyle($p[2]);
}
$opt[]= ‘<option value=”‘.htmlspecialchars($p[1]).'”‘.
($styleAttrValue ? ‘ style=”‘.htmlspecialchars($styleAttrValue).'”‘ : ”).
‘>’.htmlspecialchars($p[0]).'</option>’;
}
// Put together the selector box:
$selector_itemListStyle = isset($config[‘itemListStyle’]) ? ‘ style=”‘.htmlspecialchars($config[‘itemListStyle’]).'”‘ : ‘ style=”‘.$this->defaultMultipleSelectorStyle.'”‘;
$size = intval($config[‘size’]);
$size = $config[‘autoSizeMax’] ? t3lib_div::intInRange(count($itemArray)+1,t3lib_div::intInRange($size,1),$config[‘autoSizeMax’]) : $size;
if ($config[‘exclusiveKeys’]) {
$sOnChange = ‘setFormValueFromBrowseWin(\”.$PA[‘itemFormElName’].’\’,this.options[this.selectedIndex].value,this.options[this.selectedIndex].text,\”.$config[‘exclusiveKeys’].’\’); ‘;
} else {
$sOnChange = ‘setFormValueFromBrowseWin(\”.$PA[‘itemFormElName’].’\’,this.options[this.selectedIndex].value,this.options[this.selectedIndex].text); ‘;
}
$sOnChange .= implode(”,$PA[‘fieldChangeFunc’]);
$itemsToSelect = ‘
<select id=”‘ . uniqid(‘tceforms-multiselect-‘) . ‘” name=”‘.$PA[‘itemFormElName’].’_sel”‘.
$this->insertDefStyle(‘select’, ‘tceforms-multiselect tceforms-itemstoselect’).
($size ? ‘ size=”‘.$size.'”‘ : ”).
‘ onClick=”‘.htmlspecialchars($sOnChange).'”‘.
$PA[‘onFocus’].
$selector_itemListStyle.’>
‘.implode(‘
‘,$opt).’
</select>’;
}
// Pass to “dbFileIcons” function:
$params = array(
‘size’ => $size,
‘autoSizeMax’ => t3lib_div::intInRange($config[‘autoSizeMax’],0),
‘style’ => isset($config[‘selectedListStyle’]) ? ‘ style=”‘.htmlspecialchars($config[‘selectedListStyle’]).'”‘ : ‘ style=”‘.$this->defaultMultipleSelectorStyle.'”‘,
‘dontShowMoveIcons’ => ($maxitems<=1),
‘maxitems’ => $maxitems,
‘info’ => ”,
‘headers’ => array(
‘selector’ => $this->getLL(‘l_selected’).’:<br />’,
‘items’ => $this->getLL(‘l_items’).’:<br />’
),
‘noBrowser’ => 1,
‘thumbnails’ => $itemsToSelect,
‘readOnly’ => $disabled
);
$item.= $this->dbFileIcons($PA[‘itemFormElName’],”,”,$itemArray,”,$params,$PA[‘onFocus’]);
return $item;
}
}
?>