private static function vocabulary_params($params)
{
$return = array();
foreach ($params as $key => $value) {
// split vocab off the beginning of the key
if (strpos($key, ':') !== false) {
list($newkey, $subkey) = explode(':', $key, 2);
$params[$newkey][$subkey] = $value;
unset($params[$key]);
}
}
foreach ($params as $vocab => $values) {
foreach ($values as $key => $value) {
$value = Utils::single_array($value);
// if there's a colon we've got a mode and a field
if (strpos($key, ':') !== false) {
list($mode, $by_field) = explode(':', $key, 2);
foreach ($value as $v) {
$return[$mode][$vocab][$by_field][] = $v;
}
} else {
// if there's no colon we've got a single field name
foreach ($value as $v) {
if ($v instanceof Term) {
// $vocab is not a vocab, but the mode - always match by its ID for the best performance
$return[$vocab][$v->vocabulary->name]['id'][] = $v->id;
} else {
$return['any'][$vocab][$key][] = $v;
}
}
}
}
}
return $return;
}