You are here

function _name_value_sanitize in Name Field 8

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

Helper function to sanitize a name component or name string.

Parameters

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: The item column to look at.

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.

Return value

string Sanitized string (depending on type specified).

File

./name.module, line 711
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 Html::escape($value);
  }
}