function uc_addresses_preprocess_address in Ubercart Addresses 7
Same name and namespace in other branches
- 6.2 uc_addresses.module \uc_addresses_preprocess_address()
Prepare address fields for display.
Parameters
UcAddressesSchemaAddress $address: The address object.
string $context: The context in which the fields will be displayed.
Return value
array An array with fieldname => data.
3 calls to uc_addresses_preprocess_address()
- template_preprocess_uc_addresses_list_address in ./
uc_addresses.pages.inc - Prepares variables for one address.
- uc_addresses_checkout_pane_address in ./
uc_addresses.ubercart.inc - Generic address pane handler.
- uc_addresses_order_pane_address in ./
uc_addresses.ubercart.inc - Callback for an address order pane.
File
- ./
uc_addresses.module, line 907 - Adds user profile address support to Ubercart.
Code
function uc_addresses_preprocess_address(UcAddressesSchemaAddress $address, $context = 'default') {
// Build field list.
$fields = array();
$weight = 1;
$weights = uc_addresses_address_field_weights();
$handlers = uc_addresses_get_address_field_handler_instances($address, $context);
foreach ($handlers as $fieldname => $handler) {
if ($handler
->isFieldEnabled() && $handler
->checkContext()) {
$value = $handler
->outputValue();
if ($value !== '') {
$weight = isset($weights[$fieldname]) ? $weights[$fieldname] : $weight++;
$fields[$fieldname] = array(
'title' => $handler
->getFieldTitle(),
'data' => $value,
'#weight' => $weight,
);
}
}
}
// Set weight of address name (if available).
if (isset($fields['address_name'])) {
$fields['address_name']['#weight'] = -40;
}
// Address format.
$fields['address'] = array(
'title' => t('Address'),
'data' => uc_addresses_format_address($address, $context),
'#weight' => -35,
);
if ($context == 'order_view') {
// Don't show address label when viewing the order.
unset($fields['address']['title']);
}
// Allow other modules to alter the preprocessed address fields.
drupal_alter('uc_addresses_preprocess_address', $fields, $address, $context);
// Sort fields.
uasort($fields, 'element_sort');
return $fields;
}