function lineage_handler_field::render in Taxonomy Lineage 7
Same name and namespace in other branches
- 6 lineage_handler_field.inc \lineage_handler_field::render()
Render the field.
Overrides views_handler_field::render
File
- handlers/
lineage_handler_field.inc, line 82 - Views field plugin for lineage's field handler.
Class
- lineage_handler_field
- Field handler for Taxonomy: Hierarchy.
Code
function render($values) {
$options = $this->options ? $this->options : array();
if ($options['lineage']) {
extract($options['lineage']);
}
$lineage_string = $values->{$this->field_alias};
if ($lineage_string == '') {
return '';
}
// Split hierarchy string into hierarchical path pieces.
// Term entries are separated by \n; trim so we don't add empty pieces.
$term_strings = explode("\n", trim($lineage_string));
// Compose the rendered hierarchy according to handler form options.
if ($strip_weights) {
$term_strings = array_map("lineage_strip_weight", $term_strings);
}
if ($machine_safe) {
// Replace non-alphanumeric characters with a hyphen.
$non_alphanumeric = '/[^a-zA-Z0-9]+/ ';
$term_strings = preg_replace($non_alphanumeric, '-', $term_strings);
}
if ($prefix || $suffix) {
foreach ($term_strings as $key => $term_string) {
$term_string = $prefix . $term_string . $suffix;
$term_strings[$key] = $term_string;
}
}
// The user may enter "\n" for a linebreak delimiter;
// replace with actual linebreak character.
$delimiter = str_replace("\\n", "\n", $delimiter);
$rendered = implode($delimiter, $term_strings);
// Be sure to validate and sanitize markup since we allow HTML.
return filter_xss_admin($rendered);
}