updated admin_menu, entity_translation, addressfield, addressfield_token, autocomplete_deluxe

This commit is contained in:
2019-05-13 17:41:56 +02:00
parent 472762edfa
commit 33210e10f2
65 changed files with 3124 additions and 700 deletions

View File

@@ -52,6 +52,37 @@ function addressfield_module_implements_alter(&$implementations, $hook) {
}
}
/**
* Returns a list of address fields optionally filtered by entity type.
*
* @param string $entity_type
* Optional machine-name of an entity type to filter the returned array by.
*
* @return array
* An array of address field mapping data.
*/
function addressfield_get_address_fields($entity_type = '') {
$fields = &drupal_static(__FUNCTION__ . '_' . $entity_type);
if (isset($fields)) {
return $fields;
}
// Get mapping data for all address fields.
$fields = array_filter(field_info_field_map(), 'addressfield_field_map_filter');
// Filter the list of fields by entity type if specified.
if (!empty($fields) && !empty($entity_type)) {
foreach ($fields as $field_name => $field) {
if (!isset($field['bundles'][$entity_type])) {
unset($fields[$field_name]);
}
}
}
return $fields;
}
/**
* Returns TRUE if a field map array value represents an addressfield.
*
@@ -305,7 +336,14 @@ function theme_addressfield_container($variables) {
if (strlen($element['#children']) > 0) {
$output = '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . '>';
$output .= $element['#children'];
$output .= '</' . $element['#tag'] . ">";
$output .= '</' . $element['#tag'] . '>';
// Add a linebreak to the HTML after a div. This is invisible on the
// rendered page but improves the appearance of address field output when
// HTML tags are stripped, such as by Views Data Export.
if ($element['#tag'] == 'div') {
$output .= PHP_EOL;
}
return $output;
}
else {
@@ -446,7 +484,7 @@ function addressfield_field_presave($entity_type, $entity, $field, $instance, $l
// spaces to single spaces.
foreach ($item as $key => &$value) {
if (!in_array($key, array('data')) && is_string($value)) {
$value = trim(str_replace(' ', ' ', $value));
$value = trim(preg_replace('/[[:blank:]]{2,}/u', ' ', $value));
}
}
}