function views_php_handler_field::render in Views PHP 7.2
Same name and namespace in other branches
- 6 plugins/views/views_php_handler_field.inc \views_php_handler_field::render()
- 7 plugins/views/views_php_handler_field.inc \views_php_handler_field::render()
Implements views_handler_field#render().
Overrides views_handler_field::render
File
- plugins/
views/ views_php_handler_field.inc, line 218
Class
- views_php_handler_field
- A handler to provide a field that is constructed by the administrator using PHP.
Code
function render($values) {
if (!empty($this->options['php_output'])) {
$normalized_row = new stdClass();
if (empty($this->view->style_plugin->rendered_fields)) {
foreach ($this->view->field as $id => $field) {
if ($field->field_alias != $this->field_alias) {
$normalized_row->{$id} = $field
->get_value($values);
}
}
}
else {
foreach ($this->view->style_plugin->rendered_fields[$this->view->row_index] as $field => $value) {
$normalized_row->{$field} = $value;
}
}
$code = ' ?>' . $this->options['php_output'];
$function = function ($view, $handler, &$static, $row, $data, $value) use ($code) {
eval($code);
};
ob_start();
$function($this->view, $this, $this->php_static_variable, $normalized_row, $values, isset($values->{$this->field_alias}) ? $values->{$this->field_alias} : NULL);
$value = ob_get_clean();
}
else {
if (isset($values->{$this->field_alias})) {
$value = check_plain($values->{$this->field_alias});
}
}
if (isset($value)) {
return $value;
}
}