root / drupal7 / sites / all / modules / addressfield / addressfield.api.php @ f066bdb5
1 |
<?php
|
---|---|
2 |
|
3 |
/**
|
4 |
* @file
|
5 |
* API documentation for Addressfield.
|
6 |
*/
|
7 |
|
8 |
/**
|
9 |
* Format generation callback.
|
10 |
*
|
11 |
* @param $format
|
12 |
* The address format being generated.
|
13 |
* @param $address
|
14 |
* The address this format is generated for.
|
15 |
* @param $context
|
16 |
* An associative array of context information pertaining to how the address
|
17 |
* format should be generated. If no mode is given, it will initialize to the
|
18 |
* default value. The remaining context keys should only be present when the
|
19 |
* address format is being generated for a field:
|
20 |
* - mode: either 'form' or 'render'; defaults to 'render'.
|
21 |
* - field: the field info array.
|
22 |
* - instance: the field instance array.
|
23 |
* - langcode: the langcode of the language the field is being rendered in.
|
24 |
* - delta: the delta value of the given address.
|
25 |
*
|
26 |
* @ingroup addressfield_format
|
27 |
*/
|
28 |
function CALLBACK_addressfield_format_callback(&$format, $address, $context = array()) { |
29 |
// No example.
|
30 |
} |
31 |
|
32 |
/**
|
33 |
* Allows modules to alter the predefined address formats.
|
34 |
*
|
35 |
* @param $address_formats
|
36 |
* The array of all predefined address formats.
|
37 |
*
|
38 |
* @see addressfield_get_address_format()
|
39 |
*/
|
40 |
function hook_addressfield_address_formats_alter(&$address_formats) { |
41 |
// Remove the postal_code from the list of required fields for China.
|
42 |
$address_formats['CN']['required_fields'] = array('locality', 'administrative_area'); |
43 |
} |
44 |
|
45 |
/**
|
46 |
* Allows modules to alter the predefined administrative areas.
|
47 |
*
|
48 |
* @param $administrative_areas
|
49 |
* The array of all predefined administrative areas.
|
50 |
*
|
51 |
* @see addressfield_get_administrative_areas()
|
52 |
*/
|
53 |
function hook_addressfield_administrative_areas_alter(&$administrative_areas) { |
54 |
// Alter the label of the Spanish administrative area with the iso code PM.
|
55 |
$administrative_areas['ES']['PM'] = t('Balears / Baleares'); |
56 |
|
57 |
// Add administrative areas for imaginary country XT, keyed by their
|
58 |
// imaginary ISO codes.
|
59 |
$administrative_areas['XT'] = array( |
60 |
'A' => t('Aland'), |
61 |
'B' => t('Bland'), |
62 |
); |
63 |
} |
64 |
|
65 |
/**
|
66 |
* Allows modules to add arbitrary AJAX commands to the array returned from the
|
67 |
* standard address field widget refresh.
|
68 |
*
|
69 |
* @param &$commands
|
70 |
* The array of AJAX commands used to refresh the address field widget.
|
71 |
* @param $form
|
72 |
* The rebuilt form array.
|
73 |
* @param $form_state
|
74 |
* The form state array from the form.
|
75 |
*
|
76 |
* @see addressfield_standard_widget_refresh()
|
77 |
*/
|
78 |
function hook_addressfield_standard_widget_refresh_alter(&$commands, $form, $form_state) { |
79 |
// Display an alert message.
|
80 |
$commands[] = ajax_command_alert(t('The address field widget has been updated.')); |
81 |
} |