function views_php_handler_field::php_post_execute in Views PHP 6
Same name and namespace in other branches
- 7.2 plugins/views/views_php_handler_field.inc \views_php_handler_field::php_post_execute()
- 7 plugins/views/views_php_handler_field.inc \views_php_handler_field::php_post_execute()
See also
views_php_views_post_execute()
File
- plugins/
views/ views_php_handler_field.inc, line 136
Class
- views_php_handler_field
- A handler to provide a field that is constructed by the administrator using PHP.
Code
function php_post_execute() {
// Don't do anything if displaying a summary.
if (!empty($this->view->build_info['summary'])) {
return;
}
// Ecexute value PHP code.
if (!empty($this->options['php_value'])) {
$function = create_function('$view, $handler, &$static, $row, $data', $this->options['php_value'] . ';');
ob_start();
foreach ($this->view->result as $i => &$row) {
$normalized_row = new stdClass();
foreach ($this->view->display_handler
->get_handlers('field') as $field => $handler) {
$normalized_row->{$field} = isset($row->{$handler->field_alias}) ? $row->{$handler->field_alias} : NULL;
}
// Add base field if found.
if (!empty($this->view->base_field) && isset($row->{$this->view->base_field})) {
$normalized_row->{$this->view->base_field} = $row->{$this->view->base_field};
}
$row->{$this->field_alias} = $function($this->view, $this, $this->php_static_variable, $normalized_row, $row);
}
ob_end_clean();
}
// If we're sorting, do the actual sorting then fix the results as per the pager info.
if (!empty($this->options['use_php_click_sortable']) && !empty($this->php_click_sort_order)) {
if ($this->options['use_php_click_sortable'] == self::CLICK_SORT_PHP) {
if (!empty($this->options['php_click_sortable'])) {
$this->php_click_sort_function = create_function('$view, $handler, &$static, $row1, $row2', $this->options['php_click_sortable'] . ';');
}
}
else {
$predefined = array(
self::CLICK_SORT_NUMERIC => array(
get_class($this),
'php_click_sort_numeric',
),
self::CLICK_SORT_ALPHA => 'strcasecmp',
self::CLICK_SORT_ALPHA_CASE => 'strcmp',
self::CLICK_SORT_NAT => 'strnatcasecmp',
self::CLICK_SORT_NAT_CASE => 'strnatcmp',
);
$this->php_click_sort_function = $predefined[$this->options['use_php_click_sortable']];
}
if (isset($this->php_click_sort_function)) {
usort($this->view->result, array(
$this,
'php_click_sort',
));
}
}
}