You are here

function views_bulk_operations_handler_field_operations::options_form in Views Bulk Operations (VBO) 7.3

Default options form provides the label widget that all fields should have.

Overrides views_handler_field::options_form

File

views/views_bulk_operations_handler_field_operations.inc, line 110
Views field handler. Contains all relevant VBO options and related logic. Implements the Views Form API.

Class

views_bulk_operations_handler_field_operations
@file Views field handler. Contains all relevant VBO options and related logic. Implements the Views Form API.

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $form['vbo_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Bulk operations settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['vbo_settings']['display_type'] = array(
    '#type' => 'radios',
    '#title' => t('Display operations as'),
    '#default_value' => $this->options['vbo_settings']['display_type'],
    '#options' => array(
      t('Dropdown selectbox with Submit button'),
      t('Each action as a separate button'),
    ),
  );
  $form['vbo_settings']['enable_select_all_pages'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable "Select all items on all pages"'),
    '#default_value' => $this->options['vbo_settings']['enable_select_all_pages'],
    '#description' => t('Check this box to enable the ability to select all items on all pages.'),
  );
  $form['vbo_settings']['enable_select_this_page'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable "Select all items on this page"'),
    '#default_value' => $this->options['vbo_settings']['enable_select_this_page'],
    '#description' => t('Check this box to enable the ability to select all items on current page.'),
  );
  $form['vbo_settings']['row_clickable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Make the whole row clickable'),
    '#default_value' => $this->options['vbo_settings']['row_clickable'],
    '#description' => t('Check this box to select an item when its row has been clicked. Requires JavaScript.'),
  );
  $form['vbo_settings']['force_single'] = array(
    '#type' => 'checkbox',
    '#title' => t('Force single'),
    '#default_value' => $this->options['vbo_settings']['force_single'],
    '#description' => t('Check this box to restrict selection to a single value.'),
  );
  $form['vbo_settings']['entity_load_capacity'] = array(
    '#type' => 'textfield',
    '#title' => t('Number of entities to load at once'),
    '#description' => t("Improve execution performance at the cost of memory usage. Set to '1' if you're having problems."),
    '#default_value' => $this->options['vbo_settings']['entity_load_capacity'],
  );
  $form['vbo_settings']['skip_batching'] = array(
    '#type' => 'checkbox',
    '#title' => t('Skip batching'),
    '#default_value' => $this->options['vbo_settings']['skip_batching'],
    '#description' => '<b>' . t('Warning:') . '</b> ' . t('This will cause timeouts for larger amounts of selected items.'),
  );
  $form['vbo_settings']['save_view_object_when_batching'] = array(
    '#type' => 'checkbox',
    '#title' => t('Save the whole view object when batching'),
    '#default_value' => $this->options['vbo_settings']['save_view_object_when_batching'],
    '#description' => '<b>' . t('Warning:') . '</b> ' . t('Use this option when your view contains query conditions which are not defined as arguments.'),
  );

  // Display operations and their settings.
  $form['vbo_operations'] = array(
    '#tree' => TRUE,
    '#type' => 'fieldset',
    '#title' => t('Selected bulk operations'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $entity_type = $this
    ->get_entity_type();
  $options = $this->options['vbo_operations'];
  foreach (views_bulk_operations_get_applicable_operations($entity_type, $options) as $operation_id => $operation) {
    $operation_options = !empty($options[$operation_id]) ? $options[$operation_id] : array();
    $dom_id = 'edit-options-vbo-operations-' . str_replace(array(
      '_',
      ':',
    ), array(
      '-',
      '',
    ), $operation_id);
    $form['vbo_operations'][$operation_id]['selected'] = array(
      '#type' => 'checkbox',
      '#title' => $operation
        ->adminLabel(),
      '#default_value' => !empty($operation_options['selected']),
    );
    if (!$operation
      ->aggregate()) {
      $form['vbo_operations'][$operation_id]['postpone_processing'] = array(
        '#type' => 'checkbox',
        '#title' => t('Enqueue the operation instead of executing it directly'),
        '#default_value' => !empty($operation_options['postpone_processing']),
        '#dependency' => array(
          $dom_id . '-selected' => array(
            1,
          ),
        ),
      );
    }
    $form['vbo_operations'][$operation_id]['skip_confirmation'] = array(
      '#type' => 'checkbox',
      '#title' => t('Skip confirmation step'),
      '#default_value' => !empty($operation_options['skip_confirmation']),
      '#dependency' => array(
        $dom_id . '-selected' => array(
          1,
        ),
      ),
    );
    $form['vbo_operations'][$operation_id]['skip_permission_check'] = array(
      '#type' => 'checkbox',
      '#title' => t('Skip permission step'),
      '#default_value' => !empty($operation_options['skip_permission_check']),
      '#dependency' => array(
        $dom_id . '-selected' => array(
          1,
        ),
      ),
    );
    $form['vbo_operations'][$operation_id] += $operation
      ->adminOptionsForm($dom_id, $this);
  }
}