You are here

function drupagram_views_handler_field_xss::render in Drupagram 7

Render the field.

Parameters

array $values: The values retrieved from the database.

Overrides views_handler_field::render

File

./drupagram_views_field_handlers.inc, line 48
Drupagram views field handlers.

Class

drupagram_views_handler_field_xss
Process Instagram-style @usernames and URLs before filtering XSS.

Code

function render($values) {
  $value = $values->{$this->field_alias};
  if (!empty($this->options['link_urls'])) {
    $filter = new stdClass();
    $filter->settings = array(
      'filter_url_length' => 496,
    );
    $value = _filter_url($value, $filter);
  }
  if (!empty($this->options['link_usernames'])) {
    $conf = InstagramConf::instance();
    $value = _drupagram_filter_text($value, '@', 'http://' . $conf
      ->get('host') . '/');
  }
  if (!empty($this->options['link_hashtags']) && valid_url($this->options['hashtags_url'])) {
    $value = _drupagram_filter_text($value, '#', url($this->options['hashtags_url']));
  }
  return filter_xss($value);
}