You are here

function views_php_handler_filter::php_post_execute in Views PHP 6

Same name and namespace in other branches
  1. 7 plugins/views/views_php_handler_filter.inc \views_php_handler_filter::php_post_execute()

See also

views_php_views_post_execute()

File

plugins/views/views_php_handler_filter.inc, line 105

Class

views_php_handler_filter
A handler to filter a view using PHP defined by the administrator.

Code

function php_post_execute() {

  // Don't do anything if displaying a summary.
  if (!empty($this->view->build_info['summary'])) {
    return;
  }

  // Evaluate the PHP code.
  if (!empty($this->options['php_filter'])) {
    $function = create_function('$view, $handler, &$static, $row, $data', $this->options['php_filter'] . ';');
    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};
      }
      if ($function($this->view, $this, $this->php_static_variable, $normalized_row, $row)) {
        unset($this->view->result[$i]);
        $this->view->total_rows--;
      }
    }
    ob_end_clean();
  }
}