function views_handler_field_rules_link::render in Rules Link 7.2
Same name and namespace in other branches
- 7 rules_link.views.inc \views_handler_field_rules_link::render()
Render the field.
Parameters
array $values: The values retrieved from the database.
Overrides views_handler_field::render
File
- ./
rules_link.views.inc, line 31 - Provide views data.
Class
- views_handler_field_rules_link
- Renders the links for views.
Code
function render($value) {
$title = '';
$replacements = filter_xss_admin($this->options['rules_link']['rules_link_parameters']);
$token = $this
->get_render_tokens('');
$parameters = array_filter(explode(',', strtr($replacements, $token)));
// Trim the spaces from the
array_walk($parameters, 'rules_link_trim_parameters');
$rules_link = rules_link_load($this->definition['rules link name']);
$entity = $this
->get_value($value);
list($id, $rev, $bundle) = entity_extract_ids($rules_link->entity_type, $entity);
// If there are multiple bundle types, we only have to display the links to
// the entities which have the correct bundle.
if (empty($rules_link->settings['bundles']) || in_array($bundle, $rules_link->settings['bundles'])) {
$output = rules_link_render_link($rules_link, $id, drupal_get_destination(), $parameters);
if (!empty($output)) {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $output['#href'];
if (!empty($output['#options']['query']['destination'])) {
$this->options['alter']['path'] .= '?destination=' . $output['#options']['query']['destination'];
}
if (isset($output['#attr']['class'])) {
$this->options['alter']['link_class'] .= implode(' ', $output['#attr']['class']);
}
if ($this->options['rules_link']['rules_link_rewrite']) {
$output['#title'] = strtr($this->options['rules_link']['rules_link_rewrite'], $this
->get_render_tokens(''));
}
$title = $output['#title'];
}
}
return $title;
}