You are here

function theme_name_formatter_default in Name Field 6

Theme function all name field formatters.

1 string reference to 'theme_name_formatter_default'
name_additional_content_theme in ./name.module

File

./name.module, line 861
Defines an API for displaying and inputing names.

Code

function theme_name_formatter_default($element) {

  // Prevents warnings.
  if (!isset($element['#formatter']) || $element['#formatter'] == 'default') {
    $element['#formatter'] = 'default_default';
  }
  list($type, $format) = explode('_', $element['#formatter'], 2);
  $format = name_get_format_by_machine_name($format);
  $parts = array();
  foreach (_name_translations() as $key => $title) {
    if (!empty($element['#item']['safe'][$key])) {
      $parts[$key] = $element['#item']['safe'][$key];
    }
    else {
      $parts[$key] = NULL;
    }
  }
  $output = name_format($parts, $format, array(
    'object' => $element['#node'],
    'type' => 'node',
  ));
  switch ($type) {
    case 'plain':
      return strip_tags($output);
    case 'raw':
      return $output;
    case 'default':
    default:
      return check_plain($output);
  }
}