You are here

class html_title_handler_field_node_title in HTML Title 6

Same name and namespace in other branches
  1. 7 views/handlers/html_title_handler_field_node_title.inc \html_title_handler_field_node_title

Override the standard node title rendering to enable select HTML tags.

Hierarchy

Expanded class hierarchy of html_title_handler_field_node_title

1 string reference to 'html_title_handler_field_node_title'
html_title_views_data_alter in views/html_title.views.inc
Implementation of hook_views_data_alter()

File

views/handlers/html_title_handler_field_node_title.inc, line 14
The html_title_handler_field_node_title field handler re-renders title fields to enable allowed markup that would otherwise be transformed or stripped.

View source
class html_title_handler_field_node_title extends views_handler_field_node {

  /**
   * Renders the field handler.
   */
  function render($values) {
    $output = parent::render($values);
    $elements = variable_get('html_title_allowed_elements', array(
      'em',
      'sub',
      'sup',
    ));
    if (count($elements)) {
      static $done = FALSE;

      // Ensure this block executes only once
      if (!$done) {

        // Add permitted elements to options so they are not stripped later
        $tags = array();
        foreach ($elements as $element) {
          $tags[] = '<' . $element . '>';
        }
        $this->options['alter']['preserve_tags'] .= ' ' . implode(' ', $tags);
        $done = TRUE;
      }

      // Decode permitted HTML elements
      $pattern = "/&lt;(\\/?)(" . implode('|', $elements) . ")&gt;/i";
      return preg_replace($pattern, '<$1$2>', $output);
    }
    return $output;
  }

}

Members