You are here

function draggableviews_handler_sort::options_form in DraggableViews 7.2

Basic options for all sort criteria

Overrides views_handler_sort::options_form

File

views/draggableviews_handler_sort.inc, line 40
Draggableviews views native handler sort.

Class

draggableviews_handler_sort
Sort handler for ordering by weight.

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $form['expose_button']['#access'] = FALSE;
  $form['order']['#description'] = t('Please remember to override settings of the sort criterion if you have display that sets weights and you choose descending order.');

  // Grab all of the views and their display that contain a draggableviews
  // field. If this display has one then 'view->name:view->current_display'
  // is returned.
  $options = _draggableviews_get_views_options($this->view);

  // If it is setting view.
  if (!is_array($options)) {
    $form['order']['#access'] = FALSE;
    $form['draggableviews_setting_view'] = array(
      '#type' => 'value',
      '#value' => $options,
    );
  }
  else {
    $form['draggableviews_setting_view'] = array(
      '#type' => 'select',
      '#title' => t('Display sort as'),
      '#default_value' => $this->options['draggableviews_setting_view'],
      '#options' => $options,
      '#description' => t('Please choose the view and display that sets the order.'),
    );

    // If there is no setting views available, show error message.
    if (empty($options)) {
      drupal_set_message(t('First you should create a view that sets sorting order.'), 'error');
    }
  }
  $form['draggableviews_setting_arguments'] = array(
    '#title' => t('Arguments handling'),
    '#type' => 'radios',
    '#options' => array(
      'all' => t('Use all arguments'),
      'none' => t('Do not use any arguments (use empty arguments)'),
      'php' => t('Prepare arguments with PHP code'),
    ),
    '#default_value' => $this->options['draggableviews_setting_arguments'],
    '#description' => t('When sorting order is saved all arguments passed are saved with order.
          In display view we can choose how to use these arguments.'),
  );
  $form['draggableviews_setting_arguments_php'] = array(
    '#title' => t('PHP code to prepare arguments'),
    '#type' => 'textarea',
    '#default_value' => $this->options['draggableviews_setting_arguments_php'],
    '#description' => t('Enter the php code to prepare the arguments. Do not enter <?php ?> tags.
          The following variables are available - $view (the view), $arguments (existing arguments -
          manipulate these, and then return them, to alter the arguments used to sort). See README.txt for more details.'),
    '#states' => array(
      'visible' => array(
        'input[name="options[draggableviews_setting_arguments]"]' => array(
          'value' => 'php',
        ),
      ),
    ),
  );
  $form['draggableviews_setting_new_items_bottom_list'] = array(
    '#type' => 'checkbox',
    '#title' => t('New items appear bottom of the list'),
    '#description' => t('New items means elements (for example nodes) that do not have saved weight (newly created).'),
    '#default_value' => $this->options['draggableviews_setting_new_items_bottom_list'],
  );
}