html_title_handler_field_node_title.inc in HTML Title 6
Same filename and directory in other branches
The html_title_handler_field_node_title field handler re-renders title fields to enable allowed markup that would otherwise be transformed or stripped.
File
views/handlers/html_title_handler_field_node_title.incView source
<?php
/**
* @file
* The html_title_handler_field_node_title field handler re-renders title fields to enable allowed markup that would
* otherwise be transformed or stripped.
*
* @ingroup html_title
*/
/**
* Override the standard node title rendering to enable select HTML tags.
*/
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 = "/<(\\/?)(" . implode('|', $elements) . ")>/i";
return preg_replace($pattern, '<$1$2>', $output);
}
return $output;
}
}
Classes
Name | Description |
---|---|
html_title_handler_field_node_title | Override the standard node title rendering to enable select HTML tags. |