function views_handler_field_field::add_self_tokens

Overrides views_handler_field::add_self_tokens

File

modules/field/views_handler_field_field.inc, line 940

Class

views_handler_field_field
A field that displays fieldapi fields.

Code

public function add_self_tokens(&$tokens, $item) {
    $field = $this->field_info;
    foreach ($field['columns'] as $id => $column) {
        // Use filter_xss_admin because it's user data and we can't be sure it is
        // safe. We know nothing about the data, though, so we can't really do
        // much else.
        if (isset($item['raw'])) {
            // If $item['raw'] is an array then we can use as is, if it's an object
            // we cast it to an array, if it's neither, we can't use it.
            $raw = is_array($item['raw']) ? $item['raw'] : (is_object($item['raw']) ? (array) $item['raw'] : NULL);
        }
        if (isset($raw) && isset($raw[$id]) && is_scalar($raw[$id])) {
            $tokens['[' . $this->options['id'] . '-' . $id . ']'] = filter_xss_admin($raw[$id]);
        }
        else {
            // Take sure that empty values are replaced as well.
            $tokens['[' . $this->options['id'] . '-' . $id . ']'] = '';
        }
    }
}