You are here

function popup_views_integration_handler_field_popup::render in Popup Views integration 7

Render the trigger field and its linked popup information.

Overrides views_handler_field::render

File

./popup_views_integration_handler_field_popup.inc, line 157
Contain the integration with views A handler to provide a field for creating a configurable pop-up from the popup module.

Class

popup_views_integration_handler_field_popup
@file Contain the integration with views A handler to provide a field for creating a configurable pop-up from the popup module.

Code

function render($values) {

  // We need to have multiple unique IDs, one for each record.
  static $i = 0;
  static $link;
  if (!empty($this->options['title']) && !empty($this->options['text'])) {
    $tokens = $this
      ->get_render_tokens($this->options['alter']);
    $attributes = $this->options;

    // Title and text accepts HTML, other must be plain text.
    $attributes['title'] = filter_xss_admin($this->options['title']);
    $attributes['text'] = filter_xss_admin($this->options['text']);
    $attributes['height'] = strip_tags($this->options['height']);
    $attributes['height'] = check_plain($attributes['height']);
    $attributes['width'] = strip_tags($this->options['width']);
    $attributes['width'] = check_plain($attributes['width']);
    $attributes['path'] = strip_tags($this->options['path']);
    $attributes['path'] = check_plain($attributes['path']);
    $attributes['popup_class'] = strip_tags($this->options['popup_class']);
    $attributes['popup_class'] = check_plain($attributes['popup_class']);

    // Filter links (<a> tags) because it breaks the popup.
    $title = strtr($attributes['title'], $tokens);
    $attributes['title'] = preg_replace(array(
      '/<a [^>]+>/i',
      '</a>',
    ), '', $title);
    $attributes['text'] = strtr($attributes['text'], $tokens);

    // TODO : use $this->['empty'] if empty.
    if (!$attributes['text'] || !$attributes['title']) {
      return;
    }
    $attributes['path'] = strtr($attributes['path'], $tokens);
    if (isset($attributes['popup_class'])) {
      $attributes['popup_class'] = strtr($attributes['popup_class'], $tokens);
    }
    $attributes['height'] = strtr($attributes['height'], $tokens);
    $attributes['width'] = strtr($attributes['width'], $tokens);
    module_load_include('inc', 'popup', 'includes/popup.api');
    return popup($attributes);
  }
  else {
    return;
  }
}