function profanity_views_handler_field::render_link in Profanity 7
Render whatever the data is as a link to the node.
Data should be made XSS safe prior to calling this function.
1 call to profanity_views_handler_field::render_link()
- profanity_views_handler_field::render in ./
profanity.views.inc - Render the field.
File
- ./
profanity.views.inc, line 125 - Provide additional Views fields for entity content.
Class
- profanity_views_handler_field
- Field handler to provide simple renderer that allows linking to a entity. Definition terms:
Code
function render_link($data, $values) {
if (!empty($this->options['link_to_entity']) && !empty($this->additional_fields['entity_info'])) {
if ($data !== NULL && $data !== '') {
// This isn't nice but no choice here as there isn't a path component
// to entity_info. Submit an issue to have other types added here.
// Recognised entity types which have known paths should bypass
// the long-ass entity load process.
if (in_array($this->entity_type, array(
'node',
'taxonomy_term',
'user',
'harmony_thread',
'harmony_post',
))) {
switch ($this->entity_type) {
case 'node':
$path = 'node';
break;
case 'taxonomy_term':
$path = 'taxonomy/term';
break;
case 'user':
$path = 'user';
break;
case 'harmony_thread':
$path = 'thread';
break;
case 'harmony_post':
$path = 'post';
break;
}
$this->options['alter']['path'] = $path . '/' . $values->{$this->entity_id_key};
$this->options['alter']['make_link'] = TRUE;
}
else {
$entity = entity_load_single($this->entity_type, $this
->get_value($values, $this->entity_id_key));
if ($entity) {
$url = entity_uri($this->entity_type, $entity);
$this->options['alter']['path'] = $url['path'];
$this->options['alter']['make_link'] = TRUE;
}
}
}
else {
$this->options['alter']['make_link'] = FALSE;
}
}
return $data;
}