You are here

function _name_value_sanitize in Name Field 7

Same name and namespace in other branches
  1. 8 name.module \_name_value_sanitize()

Helper function to sanitize a name component or name string.

Parameters

string $langcode:

mixed $item: If this is a string, then the processing happens on this. If this is an array, the processing happens on the column index.

string $column:

string $type: Tells the function how to handle the text processing: 'default' runs through check_plain() 'plain' runs through strip_tags() 'raw' has no processing applied to it.

3 calls to _name_value_sanitize()
name_field_diff_view in ./name.diff.inc
Diff field callback for parsing name field comparative values.
name_field_formatter_view in ./name.module
Implements hook_field_formatter_view().
name_field_load in ./name.module
Implements hook_field_load().

File

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

Code

function _name_value_sanitize($item, $column = NULL, $type = 'default') {
  $safe_key = 'safe' . ($type == 'default' ? '' : '_' . $type);
  if (is_array($item) && isset($item[$safe_key])) {
    return $item[$safe_key][$column];
  }
  $value = is_array($item) ? (string) $item[$column] : $item;
  switch ($type) {
    case 'plain':
      return strip_tags($value);
    case 'raw':
      return $value;
    default:
      return check_plain($value);
  }
}