updated webform, uuid, synonyms modules
This commit is contained in:
@@ -165,7 +165,9 @@ function synonyms_autocomplete_taxonomy_term($field_name, $entity_type, $bundle,
|
||||
$synonym_terms = taxonomy_term_load_multiple($synonym_terms);
|
||||
foreach ($tags_return as &$v) {
|
||||
if (isset($v['synonym'])) {
|
||||
$entity_ids = entity_extract_ids('taxonomy_term', $synonym_terms[$v['tid']]);
|
||||
$v['name'] = $synonym_terms[$v['tid']]->name;
|
||||
$v['bundle'] = $entity_ids[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,8 +244,10 @@ function synonyms_autocomplete_entity($field_name, $entity_type, $bundle, $tags_
|
||||
|
||||
$tags_typed_entity_ids = array();
|
||||
if (!empty($tags_typed)) {
|
||||
foreach ($handler->getReferencableEntities($tags_typed, 'IN') as $target_entity_ids) {
|
||||
$tags_typed_entity_ids = array_merge($tags_typed_entity_ids, array_keys($target_entity_ids));
|
||||
foreach ($tags_typed as $v) {
|
||||
foreach ($handler->getReferencableEntities($v, '=') as $target_entity_ids) {
|
||||
$tags_typed_entity_ids = array_merge($tags_typed_entity_ids, array_keys($target_entity_ids));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,9 +255,18 @@ function synonyms_autocomplete_entity($field_name, $entity_type, $bundle, $tags_
|
||||
if ($tag_last) {
|
||||
foreach ($handler->getReferencableEntities($tag_last) as $target_entity_ids) {
|
||||
foreach (array_diff_key($target_entity_ids, drupal_map_assoc($tags_typed_entity_ids)) as $target_id => $label) {
|
||||
// We do not use the label such as given us by
|
||||
// $handler->getReferencableEntities() because some handlers may include
|
||||
// more than just plain entity label. However, our validate handler
|
||||
// expects the exact labels in the text field. So we assure we put a
|
||||
// label there.
|
||||
// These entities have already been loaded by $handler, so we shouldn't
|
||||
// care that much performance-wise about loading them in batch.
|
||||
$entity = entity_load($field['settings']['target_type'], array($target_id));
|
||||
$entity = reset($entity);
|
||||
$matches[] = array(
|
||||
'target_id' => $target_id,
|
||||
'name' => $label,
|
||||
'name' => entity_label($field['settings']['target_type'], $entity),
|
||||
);
|
||||
if (count($matches) == $max_suggestions) {
|
||||
break (2);
|
||||
@@ -306,7 +319,9 @@ function synonyms_autocomplete_entity($field_name, $entity_type, $bundle, $tags_
|
||||
foreach ($matches as $k => $match) {
|
||||
if (!isset($match['name']) && isset($match['synonym'])) {
|
||||
if (entity_access('view', $field['settings']['target_type'], $synonym_entities[$match['target_id']])) {
|
||||
$entity_ids = entity_extract_ids($field['settings']['target_type'], $synonym_entities[$match['target_id']]);
|
||||
$matches[$k]['name'] = entity_label($field['settings']['target_type'], $synonym_entities[$match['target_id']]);
|
||||
$matches[$k]['bundle'] = $entity_ids[2];
|
||||
}
|
||||
else {
|
||||
unset($matches[$k]);
|
||||
@@ -332,6 +347,7 @@ function synonyms_autocomplete_entity($field_name, $entity_type, $bundle, $tags_
|
||||
* - behavior_implementation: (array) If this entry is matched through a
|
||||
* synonym, put here the behavior implementation array that provided this
|
||||
* match
|
||||
* - bundle: (string) Bundle of the entity that is suggested in this entry
|
||||
* @param string $prefix
|
||||
* Any prefix to be appended to 'name' property of $matches array when
|
||||
* inserting into the autocomplete textfield. Normally it is the already
|
||||
@@ -344,6 +360,8 @@ function synonyms_autocomplete_entity($field_name, $entity_type, $bundle, $tags_
|
||||
function synonyms_autocomplete_format($matches, $prefix) {
|
||||
$output = array();
|
||||
|
||||
$entity_info = array();
|
||||
|
||||
foreach ($matches as $match) {
|
||||
$n = synonyms_autocomplete_escape($match['name']);
|
||||
while (isset($output[$prefix . $n])) {
|
||||
@@ -351,10 +369,15 @@ function synonyms_autocomplete_format($matches, $prefix) {
|
||||
}
|
||||
$wording = check_plain($match['name']);
|
||||
if (isset($match['synonym'])) {
|
||||
$wording = format_string(filter_xss($match['behavior_implementation']['settings']['wording']), array(
|
||||
if (!isset($entity_info[$match['behavior_implementation']['entity_type']])) {
|
||||
$entity_info[$match['behavior_implementation']['entity_type']] = entity_get_info($match['behavior_implementation']['entity_type']);
|
||||
}
|
||||
|
||||
$wording = format_string(filter_xss_admin($match['behavior_implementation']['settings']['wording']), array(
|
||||
'@entity' => $match['name'],
|
||||
'@synonym' => $match['synonym'],
|
||||
'@field_name' => drupal_strtolower($match['behavior_implementation']['label']),
|
||||
'@bundle' => $entity_info[$match['behavior_implementation']['entity_type']]['bundles'][$match['bundle']]['label'],
|
||||
));
|
||||
}
|
||||
$output[$prefix . $n] = $wording;
|
||||
|
Reference in New Issue
Block a user