function phone_process_field in Phone 7.2
Implements MODULE_process_HOOK().
We make use of this function to add RDF resource properties for foaf:phone.
We use process instead of preprocess, as we want to run after any other modules have done their thing so we have all the information.
File
- ./
phone.module, line 1162 - The phone module lets administrators use a phone number field type.
Code
function phone_process_field(&$variables) {
if ($variables['element']['#field_type'] == 'phone' && module_exists('rdf')) {
$element = $variables['element'];
$field_name = $element['#field_name'];
// Go over the attributes array if it exists and manuipulate it as required.
if (isset($variables['item_attributes_array'])) {
foreach ($variables['item_attributes_array'] as $delta => $attributes) {
// If rel="foaf:phone" isset, then add the resource property.
if (isset($attributes['rel']) && in_array('foaf:phone', $attributes['rel'])) {
$variables['item_attributes_array'][$delta]['resource'] = $variables['items'][$delta]['phone']['number']['#href'];
// We need to re-flatted our modified item_attributes_array.
$variables['item_attributes'][$delta] = drupal_attributes($variables['item_attributes_array'][$delta]);
}
}
}
}
}