null,
'class' => null,
'id' => null,
'value' => null,
'filter' => [],
'title' => null,
'searchfield' => $prefs['tiki_object_selector_searchfield'],
'simplename' => null,
'simpleid' => null,
'simpleclass' => null,
'simplevalue' => null,
'separator' => null,
'threshold' => null,
'parent' => null,
'parentkey' => null,
'format' => null,
'placeholder' => tr('Title'),
'sort' => null,
'wildcard' => 'n',
'extra_type' => null,
'selector_type_reference' => null
];
// Handle reserved parameters
foreach (array_keys($arguments) as $var) {
if (isset($params["_$var"])) {
$arguments[$var] = $params["_$var"];
}
unset($params["_$var"]);
}
if ($prefs['feature_search'] !== 'y') {
if ($arguments['simplename'] && isset($arguments['simplevalue'])) {
if ($params['type'] === 'trackerfield' && $arguments['separator'] === ',') {
$help = tra('Comma-separated list of field IDs');
} else {
$help = tr('%0 list separated with "%1"', ucfirst($params['type']), $arguments['separator']);
}
return "" .
"
" . $help . "
";
} else {
return tra('Object selector requires Unified Index to be enabled.');
}
}
if (empty($arguments['id'])) {
$arguments['id'] = 'object_selector_multi_' . ++$uniqid;
}
if (empty($arguments['simpleid'])) {
$arguments['simpleid'] = 'object_selector_multi_' . ++$uniqid;
}
if ($arguments['filter']) {
$arguments['filter'] = array_merge($arguments['filter'], $params);
} else {
$arguments['filter'] = $params;
}
$selector = TikiLib::lib('objectselector');
if ($arguments['simplevalue'] && ! empty($arguments['filter']['type']) && $arguments['separator']) {
$arguments['current_selection'] = $selector->readMultipleSimple($arguments['filter']['type'], $arguments['simplevalue'], $arguments['separator'], $arguments['format']);
} else {
$arguments['current_selection'] = $selector->readMultiple($arguments['value'], $arguments['format']);
}
if (isset($arguments['extra_type'])) {
unset($arguments['current_selection']);
$template = 'object_selector_multi_extra.tpl';
}
if ($arguments['simplename']) {
$arguments['class'] .= ' d-none';
} else {
$arguments['simpleclass'] .= ' d-none';
}
$arguments['current_selection_simple'] = array_map(function ($item) {
return $item['id'];
}, $arguments['current_selection']);
$arguments['filter'] = json_encode($arguments['filter']);
$smarty->assign(
'object_selector_multi',
$arguments
);
return $smarty->fetch($template);
}