You are here

function message_field_extra_fields in Message 7

Implements hook_field_extra_fields().

File

./message.module, line 647
API functions to manipulate messages.

Code

function message_field_extra_fields() {
  $return = array();
  foreach (message_type_load() as $message_type) {

    // Iterate over any "message-text" field.
    foreach (field_info_instances('message_type', $message_type->category) as $field_name => $value) {
      $field = field_info_field($field_name);
      if (empty($field['settings']['message_text'])) {
        continue;
      }
      $field_items = field_get_items('message_type', $message_type, $field_name);
      $count = is_array($field_items) ? count($field_items) : 1;
      for ($delta = 0; $delta < $count; $delta++) {
        $params = array(
          '@label' => $value['label'],
          '@delta' => $delta,
        );
        $return['message'][$message_type->name]['display']['message__' . $field['field_name'] . '__' . $delta] = array(
          'label' => $count == 1 ? $value['label'] : t('@label @delta partial', $params),
          'description' => $count == 1 ? t('Complete rendered message text.') : t('Rendered message text of the @delta partial', $params),
          'weight' => $delta,
        );
      }
    }
  }
  return $return;
}