You are here

function views_bulk_operations_plugin_style::render in Views Bulk Operations (VBO) 6

Same name and namespace in other branches
  1. 6.3 views_bulk_operations_plugin_style.inc \views_bulk_operations_plugin_style::render()

Implementation of views_plugin::render().

File

./views_bulk_operations_plugin_style.inc, line 203

Class

views_bulk_operations_plugin_style

Code

function render() {

  // Client code might flag to skip rendering if we just want to build complete results.
  if (!empty($this->view->skip_render)) {
    return;
  }

  // We build the groups here to pass them to the node_selector function through the form.
  $this->sets = $this
    ->render_grouping($this->view->result, $this->options['grouping']);

  // Create a form ID for the form using the name and display of the view.
  $parts = array(
    'views_bulk_operations_form',
    $this->view->name,
    $this->view->current_display,
  );
  $this->form_id = implode('_', $parts);

  // Populate hashed results for selection.
  $this->result = array();
  foreach ($this->view->result as $row) {
    $this->result[_views_bulk_operations_hash_object($row, $this->view)] = $row;
  }
  if ($this->options['preserve_selection']) {
    $view_id = _views_bulk_operations_view_id($this->view);
    $view_name = $this->view->name;
    if (empty($_SESSION['vbo_values'][$view_name][$view_id]['result'])) {
      $_SESSION['vbo_values'][$view_name][$view_id]['result'] = array();
    }
    $_SESSION['vbo_values'][$view_name][$view_id]['result'] += $this->result;
  }

  // Copy the plugin globally because we might need it during form validation.
  global $vbo_plugins;
  $vbo_plugins[$this->form_id] = $this;

  // Rendering the plugin as a form.
  return drupal_get_form($this->form_id, $this);
}