You are here

function views_node_selector_process in Views Bulk Operations (VBO) 6

Same name and namespace in other branches
  1. 6.3 views_bulk_operations.module \views_node_selector_process()

Process function for views_node_selector element.

See also

views_bulk_operations_elements()

1 string reference to 'views_node_selector_process'
views_bulk_operations_elements in ./views_bulk_operations.module
Implementation of hook_elements().

File

./views_bulk_operations.module, line 227
Allows operations to be performed on items selected in a view.

Code

function views_node_selector_process($element, $edit) {
  $view = $element['#view'];
  $view_id = _views_bulk_operations_view_id($view);
  $view_name = $view->name;

  // Gather options.
  $result = $view->style_plugin->options['preserve_selection'] ? $_SESSION['vbo_values'][$view_name][$view_id]['result'] : $view->style_plugin->result;
  $options = array();
  foreach ($result as $k => $v) {
    $options[$k] = '';
  }

  // Fix default value.
  $element['#default_value'] += array(
    'selection' => array(),
    'selectall' => FALSE,
  );
  $element['#default_value']['selection'] = $element['#default_value']['selectall'] ? array_diff_key($options, array_filter($element['#default_value']['selection'], '_views_bulk_operations_filter_invert')) : array_intersect_key($options, array_filter($element['#default_value']['selection']));

  // Create selection FAPI elements.
  $element['#tree'] = TRUE;
  $element['selection'] = array(
    '#options' => $options,
    '#value' => $element['#default_value']['selection'],
    '#attributes' => array(
      'class' => 'select',
    ),
  );
  $element['selection'] = expand_checkboxes($element['selection']);
  $element['selectall'] = array(
    '#type' => 'hidden',
    '#default_value' => $element['#default_value']['selectall'],
  );
  return $element;
}