You are here

function page_manager_list_pages_form in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 page_manager/page_manager.admin.inc \page_manager_list_pages_form()

Provide a form for sorting and filtering the list of pages.

1 string reference to 'page_manager_list_pages_form'
page_manager_list_page in page_manager/page_manager.admin.inc
Output a list of pages that are managed.

File

page_manager/page_manager.admin.inc, line 248
Administrative functions for the page manager.

Code

function page_manager_list_pages_form($form, &$form_state) {

  // This forces the form to *always* treat as submitted which is
  // necessary to make it work.
  if (empty($_POST)) {
    $form["#programmed"] = TRUE;
  }
  $form['#action'] = url('admin/structure/pages/nojs/', array(
    'absolute' => TRUE,
  ));
  if (!variable_get('clean_url', FALSE)) {
    $form['q'] = array(
      '#type' => 'hidden',
      '#value' => $_GET['q'],
    );
  }
  $all = array(
    'all' => t('<All>'),
  );
  $form['type'] = array(
    '#type' => 'select',
    '#title' => t('Type'),
    '#options' => $all + $form_state['pages']['types'],
    '#default_value' => 'all',
  );
  $form['storage'] = array(
    '#type' => 'select',
    '#title' => t('Storage'),
    '#options' => $all + $form_state['pages']['storages'],
    '#default_value' => 'all',
  );
  $form['disabled'] = array(
    '#type' => 'select',
    '#title' => t('Enabled'),
    '#options' => $all + array(
      '0' => t('Enabled'),
      '1' => t('Disabled'),
    ),
    '#default_value' => 'all',
  );
  $form['search'] = array(
    '#type' => 'textfield',
    '#title' => t('Search'),
  );
  $form['order'] = array(
    '#type' => 'select',
    '#title' => t('Sort by'),
    '#options' => array(
      'disabled' => t('Enabled, title'),
      'title' => t('Title'),
      'name' => t('Name'),
      'path' => t('Path'),
      'type' => t('Type'),
      'storage' => t('Storage'),
    ),
    '#default_value' => 'disabled',
  );
  $form['sort'] = array(
    '#type' => 'select',
    '#title' => t('Order'),
    '#options' => array(
      'asc' => t('Up'),
      'desc' => t('Down'),
    ),
    '#default_value' => 'asc',
  );
  $form['submit'] = array(
    '#name' => '',
    // so it won't in the $_GET args
    '#type' => 'submit',
    '#id' => 'edit-pages-apply',
    '#value' => t('Apply'),
    '#attributes' => array(
      'class' => array(
        'use-ajax-submit ctools-auto-submit-click',
      ),
    ),
  );
  $form['reset'] = array(
    '#type' => 'submit',
    '#id' => 'edit-pages-reset',
    '#value' => t('Reset'),
    '#attributes' => array(
      'class' => array(
        'use-ajax-submit',
      ),
    ),
  );
  $form['#attached']['js'] = array(
    ctools_attach_js('auto-submit'),
    ctools_attach_js('page-list', 'page_manager'),
  );
  $form['#attached']['library'][] = array(
    'system',
    'drupal.ajax',
  );
  $form['#attached']['library'][] = array(
    'system',
    'jquery.form',
  );
  $form['#prefix'] = '<div class="clearfix">';
  $form['#suffix'] = '</div>';
  $form['#attributes'] = array(
    'class' => array(
      'ctools-auto-submit-full-form',
    ),
  );
  return $form;
}