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

@@ -3,7 +3,7 @@
/**
* Contains the predefined address formats.
*
* Derived from Google's dataset: https://i18napis.appspot.com/address.
* Derived from Google's dataset: https://chromium-i18n.appspot.com/ssl-address.
*/
/**
@@ -40,12 +40,13 @@ function addressfield_get_address_format($country_code) {
// These formats differ from the default only by the presence of the
// postal code in 'used_fields'.
$countries_with_optional_postal_code = array(
'AC', 'AD', 'AL', 'AZ', 'BA', 'BB', 'BD', 'BG', 'BH', 'BM', 'BN', 'BT',
'CR', 'CY', 'DO', 'DZ', 'EC', 'EH', 'ET', 'FO', 'GE', 'GN', 'GT',
'GW', 'HR', 'HT', 'IL', 'IS', 'JO', 'KE', 'KG', 'KH', 'KW', 'LA',
'LA', 'LB', 'LK', 'LR', 'LS', 'MA', 'MC', 'MD', 'ME', 'MG', 'MK', 'MM',
'MT', 'MU', 'MV', 'NE', 'NP', 'OM', 'PK', 'PY', 'RO', 'RS', 'SA', 'SI',
'SN', 'SZ', 'TA', 'TJ', 'TM', 'TN', 'VA', 'VC', 'VG', 'XK', 'ZM',
'AC', 'AD', 'AF', 'AI', 'AL', 'AZ', 'BA', 'BB', 'BD', 'BG', 'BH', 'BM',
'BN', 'BT', 'CU', 'CR', 'CY', 'DO', 'DZ', 'EC', 'EH', 'ET', 'FO', 'GE',
'GN', 'GT', 'GW', 'HR', 'HM', 'HT', 'IL', 'IS', 'JO', 'KE', 'KG', 'KH',
'KP', 'KW', 'LA', 'LB', 'LK', 'LR', 'LS', 'MA', 'MC', 'MD', 'ME', 'MG',
'MK', 'MM', 'MT', 'MU', 'MV', 'NE', 'NP', 'OM', 'PK', 'PY', 'RO', 'RS',
'SA', 'SD', 'SI', 'SN', 'SZ', 'TA', 'TJ', 'TM', 'TN', 'TZ', 'VA', 'VC',
'VG', 'XK', 'ZM',
);
foreach ($countries_with_optional_postal_code as $code) {
$address_formats[$code] = array(
@@ -71,6 +72,8 @@ function addressfield_get_address_format($country_code) {
$address_formats['AE'] = array(
'used_fields' => array('administrative_area'),
'administrative_area_label' => t('Emirate'),
'render_administrative_area_value' => TRUE,
'required_fields' => array('administrative_area'),
);
$address_formats['AM'] = array(
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
@@ -114,7 +117,7 @@ function addressfield_get_address_format($country_code) {
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
);
$address_formats['CL'] = array(
'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
'render_administrative_area_value' => TRUE,
);
@@ -122,9 +125,11 @@ function addressfield_get_address_format($country_code) {
'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
'required_fields' => array('locality', 'administrative_area'),
'dependent_locality_label' => t('District'),
'render_administrative_area_value' => TRUE,
);
$address_formats['CO'] = array(
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
'required_fields' => array('locality', 'administrative_area'),
'administrative_area_label' => t('Department', array(), array('context' => 'Territory of a country')),
);
$address_formats['CV'] = array(
@@ -142,6 +147,7 @@ function addressfield_get_address_format($country_code) {
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
'required_fields' => array('locality', 'postal_code'),
'administrative_area_label' => t('County'),
'render_administrative_area_value' => TRUE,
);
$address_formats['ES'] = array(
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
@@ -155,7 +161,7 @@ function addressfield_get_address_format($country_code) {
'postal_code_label' => t('ZIP code'),
);
$address_formats['GB'] = array(
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
'used_fields' => array('locality', 'postal_code'),
'required_fields' => array('locality', 'postal_code'),
'locality_label' => t('Town/City'),
'administrative_area_label' => t('County'),
@@ -165,8 +171,8 @@ function addressfield_get_address_format($country_code) {
'used_fields' => array('postal_code'),
);
$address_formats['GU'] = array(
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
'used_fields' => array('locality', 'postal_code'),
'required_fields' => array('locality', 'postal_code'),
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
'postal_code_label' => t('ZIP code'),
);
@@ -182,13 +188,15 @@ function addressfield_get_address_format($country_code) {
);
$address_formats['ID'] = array(
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
'required_fields' => array('administrative_area'),
'locality_label' => t('City/Regency'),
'render_administrative_area_value' => TRUE,
);
$address_formats['IE'] = array(
'used_fields' => array('locality', 'administrative_area'),
'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
'locality_label' => t('Town/City'),
'administrative_area_label' => t('County'),
'postal_code_label' => t('Eircode'),
'render_administrative_area_value' => TRUE,
);
$address_formats['IN'] = array(
@@ -293,7 +301,7 @@ function addressfield_get_address_format($country_code) {
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
);
$address_formats['NG'] = array(
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
);
$address_formats['NI'] = array(
@@ -330,6 +338,7 @@ function addressfield_get_address_format($country_code) {
);
$address_formats['PH'] = array(
'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
'render_administrative_area_value' => TRUE,
);
$address_formats['PR'] = array(
'used_fields' => array('locality', 'postal_code'),
@@ -344,7 +353,7 @@ function addressfield_get_address_format($country_code) {
);
$address_formats['RU'] = array(
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
'required_fields' => array('locality', 'postal_code'),
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
'render_administrative_area_value' => TRUE,
);
$address_formats['SC'] = array(
@@ -389,7 +398,7 @@ function addressfield_get_address_format($country_code) {
);
$address_formats['UA'] = array(
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
'required_fields' => array('locality', 'postal_code'),
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
'administrative_area_label' => t('Region', array(), array('context' => 'Territory of a country')),
);
$address_formats['UM'] = array(

View File

@@ -132,7 +132,7 @@ function _addressfield_get_administrative_areas_defaults() {
'AT' => 'Atacama',
'BI' => 'Biobío',
'CO' => 'Coquimbo',
'LI' => 'Libertador General Bernardo O\'Higgins',
'LI' => "Libertador General Bernardo O'Higgins",
'LL' => 'Los Lagos',
'LR' => 'Los Ríos',
'MA' => 'Magallanes y de la Antártica Chilena',
@@ -449,112 +449,112 @@ function _addressfield_get_administrative_areas_defaults() {
'AL' => 'Alessandria',
'AN' => 'Ancona',
'AO' => 'Aosta',
'AP' => 'Ascoli Piceno',
'AQ' => "L'Aquila",
'AR' => 'Arezzo',
'AP' => 'Ascoli Piceno',
'AT' => 'Asti',
'AV' => 'Avellino',
'BA' => 'Bari',
'BG' => 'Bergamo',
'BI' => 'Biella',
'BT' => 'Barletta-Andria-Trani',
'BL' => 'Belluno',
'BN' => 'Benevento',
'BG' => 'Bergamo',
'BI' => 'Biella',
'BO' => 'Bologna',
'BR' => 'Brindisi',
'BS' => 'Brescia',
'BT' => 'Barletta-Andria-Trani',
'BZ' => 'Bolzano/Bozen',
'BS' => 'Brescia',
'BR' => 'Brindisi',
'CA' => 'Cagliari',
'CB' => 'Campobasso',
'CE' => 'Caserta',
'CH' => 'Chieti',
'CI' => 'Carbonia-Iglesias',
'CL' => 'Caltanissetta',
'CN' => 'Cuneo',
'CO' => 'Como',
'CR' => 'Cremona',
'CS' => 'Cosenza',
'CB' => 'Campobasso',
'CI' => 'Carbonia-Iglesias',
'CE' => 'Caserta',
'CT' => 'Catania',
'CZ' => 'Catanzaro',
'CH' => 'Chieti',
'CO' => 'Como',
'CS' => 'Cosenza',
'CR' => 'Cremona',
'KR' => 'Crotone',
'CN' => 'Cuneo',
'EN' => 'Enna',
'FC' => 'Forlì-Cesena',
'FE' => 'Ferrara',
'FG' => 'Foggia',
'FI' => 'Firenze',
'FM' => 'Fermo',
'FE' => 'Ferrara',
'FI' => 'Firenze',
'FG' => 'Foggia',
'FC' => 'Forlì-Cesena',
'FR' => 'Frosinone',
'GE' => 'Genova',
'GO' => 'Gorizia',
'GR' => 'Grosseto',
'IM' => 'Imperia',
'IS' => 'Isernia',
'KR' => 'Crotone',
'LC' => 'Lecco',
'AQ' => "L'Aquila",
'SP' => 'La Spezia',
'LT' => 'Latina',
'LE' => 'Lecce',
'LC' => 'Lecco',
'LI' => 'Livorno',
'LO' => 'Lodi',
'LT' => 'Latina',
'LU' => 'Lucca',
'MB' => 'Monza e Brianza',
'MC' => 'Macerata',
'ME' => 'Messina',
'MI' => 'Milano',
'MN' => 'Mantova',
'MO' => 'Modena',
'MS' => 'Massa-Carrara',
'MT' => 'Matera',
'VS' => 'Medio Campidano',
'ME' => 'Messina',
'MI' => 'Milano',
'MO' => 'Modena',
'MB' => 'Monza e Brianza',
'NA' => 'Napoli',
'NO' => 'Novara',
'NU' => 'Nuoro',
'OG' => 'Ogliastra',
'OR' => 'Oristano',
'OT' => 'Olbia-Tempio',
'PA' => 'Palermo',
'PC' => 'Piacenza',
'OR' => 'Oristano',
'PD' => 'Padova',
'PE' => 'Pescara',
'PG' => 'Perugia',
'PI' => 'Pisa',
'PN' => 'Pordenone',
'PO' => 'Prato',
'PA' => 'Palermo',
'PR' => 'Parma',
'PT' => 'Pistoia',
'PU' => 'Pesaro e Urbino',
'PV' => 'Pavia',
'PG' => 'Perugia',
'PU' => 'Pesaro e Urbino',
'PE' => 'Pescara',
'PC' => 'Piacenza',
'PI' => 'Pisa',
'PT' => 'Pistoia',
'PN' => 'Pordenone',
'PZ' => 'Potenza',
'PO' => 'Prato',
'RG' => 'Ragusa',
'RA' => 'Ravenna',
'RC' => 'Reggio Calabria',
'RE' => 'Reggio Emilia',
'RG' => 'Ragusa',
'RI' => 'Rieti',
'RM' => 'Roma',
'RN' => 'Rimini',
'RM' => 'Roma',
'RO' => 'Rovigo',
'SA' => 'Salerno',
'SI' => 'Siena',
'SO' => 'Sondrio',
'SP' => 'La Spezia',
'SR' => 'Siracusa',
'SS' => 'Sassari',
'SV' => 'Savona',
'SI' => 'Siena',
'SR' => 'Siracusa',
'SO' => 'Sondrio',
'TA' => 'Taranto',
'TE' => 'Teramo',
'TN' => 'Trento',
'TR' => 'Terni',
'TO' => 'Torino',
'TP' => 'Trapani',
'TR' => 'Terni',
'TS' => 'Trieste',
'TN' => 'Trento',
'TV' => 'Treviso',
'TS' => 'Trieste',
'UD' => 'Udine',
'VA' => 'Varese',
'VE' => 'Venezia',
'VB' => 'Verbano-Cusio-Ossola',
'VC' => 'Vercelli',
'VE' => 'Venezia',
'VI' => 'Vicenza',
'VR' => 'Verona',
'VS' => 'Medio Campidano',
'VT' => 'Viterbo',
'VV' => 'Vibo Valentia',
'VI' => 'Vicenza',
'VT' => 'Viterbo',
);
$administrative_areas['JM'] = array(
'13' => 'Clarendon',
@@ -663,11 +663,11 @@ function _addressfield_get_administrative_areas_defaults() {
'BCN' => 'Baja California',
'BCS' => 'Baja California Sur',
'CAM' => 'Campeche',
'CMX' => 'Ciudad de México',
'COA' => 'Coahuila',
'COL' => 'Colima',
'CHP' => 'Chiapas',
'CHH' => 'Chihuahua',
'DIF' => 'Distrito Federal',
'DUG' => 'Durango',
'MEX' => 'Estado de México',
'GUA' => 'Guanajuato',
@@ -709,7 +709,7 @@ function _addressfield_get_administrative_areas_defaults() {
'13' => t('Sarawak'),
'10' => t('Selangor'),
'11' => t('Terengganu'),
);
);
$administrative_areas['PE'] = array(
'AMA' => 'Amazonas',
'ANC' => 'Ancash',
@@ -737,6 +737,90 @@ function _addressfield_get_administrative_areas_defaults() {
'TUM' => 'Tumbes',
'UCA' => 'Ucayali',
);
$administrative_areas['PH'] = array(
'ABR' => 'Abra',
'AGN' => 'Agusan del Norte',
'AGS' => 'Agusan del Sur',
'AKL' => 'Aklan',
'ALB' => 'Albay',
'ANT' => 'Antique',
'APA' => 'Apayao',
'AUR' => 'Aurora',
'BAS' => 'Basilan',
'BAN' => 'Bataan',
'BTN' => 'Batanes',
'BTG' => 'Batangas',
'BEN' => 'Benguet',
'BIL' => 'Biliran',
'BOH' => 'Bohol',
'BUK' => 'Bukidnon',
'BUL' => 'Bulacan',
'CAG' => 'Cagayan',
'CAN' => 'Camarines Norte',
'CAS' => 'Camarines Sur',
'CAM' => 'Camiguin',
'CAP' => 'Capiz',
'CAT' => 'Catanduanes',
'CAV' => 'Cavite',
'CEB' => 'Cebu',
'COM' => 'Compostela Valley',
'NCO' => 'Cotabato',
'DAV' => 'Davao del Norte',
'DAS' => 'Davao del Sur',
'a9d' => 'Davao Occidental',
'DAO' => 'Davao Oriental',
'DIN' => 'Dinagat Islands',
'EAS' => 'Eastern Samar',
'GUI' => 'Guimaras',
'IFU' => 'Ifugao',
'ILN' => 'Ilocos Norte',
'ILS' => 'Ilocos Sur',
'ILI' => 'Iloilo',
'ISA' => 'Isabela',
'KAL' => 'Kalinga',
'LUN' => 'La Union',
'LAG' => 'Laguna',
'LAN' => 'Lanao del Norte',
'LAS' => 'Lanao del Sur',
'LEY' => 'Leyte',
'MAG' => 'Maguindanao',
'MAD' => 'Marinduque',
'MAS' => 'Masbate',
'00' => 'Metro Manila',
'MDC' => 'Mindoro Occidental',
'MDR' => 'Mindoro Oriental',
'MSC' => 'Misamis Occidental',
'MSR' => 'Misamis Oriental',
'MOU' => 'Mountain Province',
'NEC' => 'Negros Occidental',
'NER' => 'Negros Oriental',
'NSA' => 'Northern Samar',
'NUE' => 'Nueva Ecija',
'NUV' => 'Nueva Vizcaya',
'PLW' => 'Palawan',
'PAM' => 'Pampanga',
'PAN' => 'Pangasinan',
'QUE' => 'Quezon Province',
'QUI' => 'Quirino',
'RIZ' => 'Rizal',
'ROM' => 'Romblon',
'WSA' => 'Samar',
'SAR' => 'Sarangani',
'SIG' => 'Siquijor',
'SOR' => 'Sorsogon',
'SCO' => 'South Cotabato',
'SLE' => 'Southern Leyte',
'SUK' => 'Sultan Kudarat',
'SLU' => 'Sulu',
'SUN' => 'Surigao del Norte',
'SUR' => 'Surigao del Sur',
'TAR' => 'Tarlac',
'TAW' => 'Tawi-Tawi',
'ZMB' => 'Zambales',
'ZAN' => 'Zamboanga del Norte',
'ZAS' => 'Zamboanga del Sur',
'ZSI' => 'Zamboanga Sibuguey',
);
$administrative_areas['RU'] = array(
'MOW' => t('Moskva'),
'SPE' => t('Sankt-Peterburg'),
@@ -931,31 +1015,31 @@ function _addressfield_get_administrative_areas_defaults() {
);
$administrative_areas['UA'] = array(
'43' => t('Crimea'),
'05' => t('Vinnyts\'ka oblast'),
'07' => t('Volyns\'ka oblast'),
'05' => t("Vinnyts'ka oblast"),
'07' => t("Volyns'ka oblast"),
'12' => t('Dnipropetrovsk Oblast'),
'14' => t('Donetsk Oblast'),
'18' => t('Zhytomyrs\'ka oblast'),
'21' => t('Zakarpats\'ka oblast'),
'23' => t('Zaporiz\'ka oblast'),
'26' => t('Ivano-Frankivs\'ka oblast'),
'30' => t('Kiev Oblast'),
'35' => t('Kirovohrads\'ka oblast'),
'09' => t('Luhans\'ka oblast'),
'18' => t("Zhytomyrs'ka oblast"),
'21' => t("Zakarpats'ka oblast"),
'23' => t("Zaporiz'ka oblast"),
'26' => t("Ivano-Frankivs'ka oblast"),
'30' => t('Kyiv Oblast'),
'35' => t("Kirovohrads'ka oblast"),
'09' => t("Luhans'ka oblast"),
'46' => t('Lviv Oblast'),
'48' => t('Mykolaivs\'ka oblast'),
'48' => t("Mykolaivs'ka oblast"),
'51' => t('Odessa Oblast'),
'53' => t('Poltavs\'ka oblast'),
'56' => t('Rivnens\'ka oblast'),
'40' => t('Sevastopol\' city'),
'59' => t('Sums\'ka oblast'),
'61' => t('Ternopil\'s\'ka oblast'),
'53' => t("Poltavs'ka oblast"),
'56' => t("Rivnens'ka oblast"),
'40' => t("Sevastopol' city"),
'59' => t("Sums'ka oblast"),
'61' => t("Ternopil's'ka oblast"),
'63' => t('Kharkiv Oblast'),
'65' => t('Khersons\'ka oblast'),
'68' => t('Khmel\'nyts\'ka oblast'),
'71' => t('Cherkas\'ka oblast'),
'77' => t('Chernivets\'ka oblast'),
'74' => t('Chernihivs\'ka oblast'),
'65' => t("Khersons'ka oblast"),
'68' => t("Khmel'nyts'ka oblast"),
'71' => t("Cherkas'ka oblast"),
'77' => t("Chernivets'ka oblast"),
'74' => t("Chernihivs'ka oblast"),
);
$administrative_areas['US'] = array(
'AL' => t('Alabama'),

View File

@@ -41,9 +41,9 @@ function _addressfield_sample_addresses() {
if (!isset($fields)) {
$filepath = DRUPAL_ROOT . '/' . drupal_get_path('module', 'addressfield');
$fields = array();
if ($handle = @fopen("$filepath/addresses.txt",'r')) {
if ($handle = @fopen("$filepath/addresses.txt", 'r')) {
if (is_resource($handle)) {
while (($buffer = fgets($handle)) !== false) {
while (($buffer = fgets($handle)) !== FALSE) {
list($country, $administrative_area, $sub_administrative_area, $locality, $dependent_locality, $postal_code, $thoroughfare, $premise, $sub_premise) = explode("\t", $buffer);
$fields[] = array(
'country' => ($country == 'NULL') ? NULL : trim($country),

View File

@@ -36,10 +36,20 @@ function addressfield_feeds_processor_targets_alter(&$targets, $entity_type, $bu
* A string identifying the target on the node.
* @param $values
* The value to populate the target with.
* @param array $mapping
* Associative array of the mapping settings from the per mapping
* configuration form.
*/
function addressfield_set_target($source, $entity, $target, $values) {
function addressfield_set_target($source, $entity, $target, $values, $mapping) {
$language = $mapping['language'];
list($field_name, $sub_field) = explode(':', $target, 2);
// Field info and instance are required for setting default values.
$entity_type = $source->importer->processor->entityType();
list(, , $bundle_name) = entity_extract_ids($entity_type, $entity);
$info = field_info_field($field_name);
$instance = field_info_instance($entity_type, $field_name, $bundle_name);
// Convert the values into an array if it isn't one already to correspond to
// Drupal's handling of field value arrays.
if (!is_array($values)) {
@@ -48,12 +58,16 @@ function addressfield_set_target($source, $entity, $target, $values) {
// If the field is already set on the given entity, update the existing value
// array. Otherwise start with a fresh field value array.
$field = isset($entity->$field_name) ? $entity->$field_name : array();
$field = isset($entity->{$field_name}) ? $entity->{$field_name} : array();
// Loop over the field values array...
foreach ($values as $delta => $value) {
$field[LANGUAGE_NONE][$delta][$sub_field] = $value;
// Set defaults for new values.
if (!isset($field[$language][$delta])) {
$field[$language][$delta] = addressfield_default_values($info, $instance);
}
$field[$language][$delta][$sub_field] = $value;
}
$entity->$field_name = $field;
$entity->{$field_name} = $field;
}

View File

@@ -10,9 +10,8 @@ files[] = views/addressfield_views_handler_field_administrative_area.inc
files[] = views/addressfield_views_handler_field_country.inc
files[] = views/addressfield_views_handler_filter_country.inc
; Information added by Drupal.org packaging script on 2015-10-07
version = "7.x-1.2"
; Information added by Drupal.org packaging script on 2018-10-26
version = "7.x-1.3"
core = "7.x"
project = "addressfield"
datestamp = "1444254070"
datestamp = "1540579391"

View File

@@ -5,6 +5,11 @@
* Base integration with the Migrate API class.
*/
// Avoid issues when migrate module is disabled.
if (!class_exists('MigrateFieldHandler')) {
return;
}
/**
* Implements hook_migrate_api().
*/

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));
}
}
}

View File

@@ -89,11 +89,13 @@ function addressfield_token_info() {
*/
function addressfield_token_info_alter(&$data) {
// Loop over every address field on the site.
foreach (array_filter(field_info_field_map(), 'addressfield_field_map_filter') as $field_name => $field) {
foreach ($data['tokens'] as $group => $token){
if (isset($data['tokens'][$group][$field_name]) && is_array($data['tokens'][$group][$field_name])) {
// Set the token type for the field to use the addressfield child tokens.
$data['tokens'][$group][$field_name]['type'] = 'address-field';
foreach (addressfield_get_address_fields() as $field_name => $field) {
foreach (array($field_name, strtr($field_name, '_', '-')) as $name) {
foreach ($data['tokens'] as $group => $token) {
if (isset($data['tokens'][$group][$name]) && is_array($data['tokens'][$group][$name])) {
// Set the token type for the field to use the addressfield child tokens.
$data['tokens'][$group][$name]['type'] = 'address-field';
}
}
}
}
@@ -212,19 +214,27 @@ function addressfield_tokens($type, $tokens, array $data = array(), array $optio
// and helps us avoid having to do the entity detection ourselves.
if ($type == 'entity') {
// Loop over the address fields defined on the site.
foreach (array_filter(field_info_field_map(), 'addressfield_field_map_filter') as $field_name => $field) {
// If there are any address field tokens in the token list...
if ($addressfield_tokens = token_find_with_prefix($tokens, $field_name)) {
// If the current field is on the matching entity type...
if (!empty($field['bundles'][$data['entity_type']])) {
// Extract the format handlers selected in a representative instance
// settings form for use in formatting tokens.
$instance = field_info_instance($data['entity_type'], $field_name, reset($field['bundles'][$data['entity_type']]));
$format_handlers = $instance['widget']['settings']['format_handlers'];
foreach (addressfield_get_address_fields($data['entity_type']) as $field_name => $field) {
// If the current field is on the matching entity type...
if (!empty($field['bundles'][$data['entity_type']])) {
// Extract the format handlers selected in a representative instance
// settings form for use in formatting tokens.
$instance = field_info_instance($data['entity_type'], $field_name, reset($field['bundles'][$data['entity_type']]));
$format_handlers = $instance['widget']['settings']['format_handlers'];
}
foreach (array($field_name, strtr($field_name, '_', '-')) as $prefix) {
// If there are any address field tokens in the token list...
$addressfield_tokens = token_find_with_prefix($tokens, $prefix);
if (!$addressfield_tokens) {
continue;
}
// Generate the necessary address field tokens for the entity.
$replacements += token_generate('address-field', $addressfield_tokens, array('address-field' => $data['entity']->$field_name, 'format_handlers' => $format_handlers), $options);
if (property_exists($data['entity'], $field_name)) {
// Generate the necessary address field tokens for the entity.
$replacements += token_generate('address-field', $addressfield_tokens, array('address-field' => $data['entity']->$field_name, 'format_handlers' => $format_handlers), $options);
}
}
}
}

View File

@@ -7,9 +7,8 @@ hidden = TRUE
dependencies[] = ctools
dependencies[] = addressfield
; Information added by Drupal.org packaging script on 2015-10-07
version = "7.x-1.2"
; Information added by Drupal.org packaging script on 2018-10-26
version = "7.x-1.3"
core = "7.x"
project = "addressfield"
datestamp = "1444254070"
datestamp = "1540579391"

View File

@@ -0,0 +1,24 @@
<?php
/**
* @file
* Hide the administrative area field.
*/
$plugin = array(
'title' => t('Hide the administrative area'),
'format callback' => 'addressfield_format_address_hide_administrative_area',
'type' => 'address',
'weight' => -84,
);
/**
* Format callback.
*
* @see CALLBACK_addressfield_format_callback()
*/
function addressfield_format_address_hide_administrative_area(&$format, $address, $context = array()) {
if (isset($format['locality_block']['administrative_area'])) {
$format['locality_block']['administrative_area']['#access'] = FALSE;
}
}

View File

@@ -20,7 +20,7 @@ $plugin = array(
function addressfield_format_address_hide_country(&$format, $address, $context = array()) {
// Hide the country element only if the whole field is required, otherwise
// there will always be an additional None option.
if ($context['mode'] == 'form' && $context['instance']['required']) {
if ($context['mode'] == 'form' && (empty($context['instance']) || $context['instance']['required'])) {
if (!empty($format['country']['#options']) && count($format['country']['#options']) == 1) {
$format['country']['#access'] = FALSE;
}

View File

@@ -0,0 +1,24 @@
<?php
/**
* @file
* Hide the locality field.
*/
$plugin = array(
'title' => t('Hide the locality'),
'format callback' => 'addressfield_format_address_hide_locality',
'type' => 'address',
'weight' => -84,
);
/**
* Format callback.
*
* @see CALLBACK_addressfield_format_callback()
*/
function addressfield_format_address_hide_locality(&$format, $address, $context = array()) {
if (isset($format['locality_block']['locality'])) {
$format['locality_block']['locality']['#access'] = FALSE;
}
}

View File

@@ -240,7 +240,12 @@ function addressfield_format_address_generate(&$format, $address, $context = arr
if (in_array($address['country'], $countries_postal_code_after_locality)) {
// Take the widget out of the array.
$postal_code_widget = $format['locality_block']['postal_code'];
$postal_code_widget['#prefix'] = ' ';
// If the postal code not in its own row, add a separating space.
if (empty($postal_code_widget['#tag'])) {
$postal_code_widget['#prefix'] = ' ';
}
unset($format['locality_block']['postal_code']);
// Add it back.

View File

View File

@@ -1,5 +1,4 @@
<?php
// $Id$
/**
* @file
@@ -12,24 +11,26 @@
* When you want to use the Autocomplete Deluxe element, you have to choose
* between two types sources for the suggestion data: Ajax Callbacks or Lists.
* You can set the source type by using the appropriate options:
* - #autocomplete_deluxe_path expects a string with an url, that points to the ajax
* callback. The response should be encoded as json(like for the core
* - #autocomplete_deluxe_path expects a string with an url, that points to the
* ajax callback. The response should be encoded as json (like for the core
* autocomplete).
* - #autocomplete_options needs an array in the form of an array(similar to #options in core
* for selects or checkboxes): array('a', 'b', 'c') or array(1 => 'a', 2 =>
* 'b', 3 => 'c').
* - #autocomplete_options needs an array in the form of an array (similar to
* #options in core for selects or checkboxes): array('a', 'b', 'c') or
* array(1 => 'a', 2 => 'b', 3 => 'c').
*
* Besides this two, there are three other options, wich autocomplete deluxe
* Besides these two, there are four other options which autocomplete deluxe
* accepts:
* - #multiple Indicates whether the user may select more than one item. Expects
* TRUE or FALSE, by default it is set to FALSE.
* - #autocomplete_multiple_delimiter If #multiple is TRUE, then you can use
* this option to set a seperator for multiple values. By default a string
* with the follwing content will be used: ', '.
* - #autocomplete_min_length Indicates how many characters must be entered
* until, the suggesion list can be opened. Especially helpfull, when your
* - #delimiter If #multiple is TRUE, then you can use this option to set a
* seperator for multiple values. By default a string with the following
* content will be used: ', '.
* - #min_length Indicates how many characters must be entered
* until, the suggesion list can be opened. Especially helpful, when your
* ajax callback returns only valid suggestion for a minimum characters.
* The default is 0.
* - #not_found_message A message text which will be displayed, if the entered
* term was not found.
*/
function somefunction() {
switch ($type) {
@@ -38,16 +39,18 @@ function somefunction() {
'#type' => 'autocomplete_deluxe',
'#autocomplete_options' => $options,
'#multiple' => FALSE,
'#autocomplete_min_length' => 0,
'#min_length' => 0,
);
break;
case 'ajax':
$element = array(
'#type' => 'autocomplete_deluxe',
'#autocomplete_deluxe_path' => url('some_uri', array('absolute' => TRUE)),
'#multiple' => TRUE,
'#autocomplete_min_length' => 1,
'#autocomplete_multiple_delimiter' => '|',
'#min_length' => 1,
'#delimiter' => '|',
'#not_found_message' => "The term '@term' will be added.",
);
break;
}

View File

@@ -5,9 +5,9 @@ core = 7.x
files[] = autocomplete_deluxe.module
dependencies[] = taxonomy
; Information added by Drupal.org packaging script on 2017-01-11
version = "7.x-2.2"
; Information added by Drupal.org packaging script on 2017-07-25
version = "7.x-2.3"
core = "7.x"
project = "autocomplete_deluxe"
datestamp = "1484128687"
datestamp = "1501005546"