1 views_handler_sort.inc views_handler_sort::show_expose_button(&$form, &$form_state)

Shortcut to display the expose/hide button.

Overrides views_handler::show_expose_button

File

core/modules/views/handlers/views_handler_sort.inc, line 86
@todo.

Class

views_handler_sort
Base sort handler that has no options and performs a simple sort.

Code

function show_expose_button(&$form, &$form_state) {
  $form['expose_button'] = array(
    '#prefix' => '<div class="views-expose clearfix">',
    '#suffix' => '</div>',
    // Should always come first
    '#weight' => -1000,
  );

  // Add a checkbox for JS users, which will have behavior attached to it
  // so it can replace the button.
  $form['expose_button']['checkbox'] = array(
    '#theme_wrappers' => array('container'),
    '#attributes' => array('class' => array('js-show')),
  );
  $form['expose_button']['checkbox']['checkbox'] = array(
    '#title' => t('Expose this sort to visitors, to allow them to change it'),
    '#type' => 'checkbox',
  );

  // Then add the button itself.
  if (empty($this->options['exposed'])) {
    $form['expose_button']['markup'] = array(
      '#markup' => '<div class="description exposed-description" style="float: left; margin-right:10px">' . t('This sort is not exposed. Expose it to allow the users to change it.') . '</div>',
    );
    $form['expose_button']['button'] = array(
      '#limit_validation_errors' => array(),
      '#type' => 'submit',
      '#value' => t('Expose sort'),
      '#submit' => array('views_ui_config_item_form_expose'),
      '#ajax' => array(
        'path' => empty($form_state['path']) ? current_path() : $form_state['path'],
      ),
    );
    $form['expose_button']['checkbox']['checkbox']['#default_value'] = 0;
  }
  else {
    $form['expose_button']['markup'] = array(
      '#markup' => '<div class="description exposed-description">' . t('This sort is exposed. If you hide it, users will not be able to change it.') . '</div>',
    );
    $form['expose_button']['button'] = array(
      '#limit_validation_errors' => array(),
      '#type' => 'submit',
      '#value' => t('Hide sort'),
      '#submit' => array('views_ui_config_item_form_expose'),
      '#ajax' => array(
        'path' => empty($form_state['path']) ? current_path() : $form_state['path'],
      ),
    );
    $form['expose_button']['checkbox']['checkbox']['#default_value'] = 1;
  }
}