You are here

function lingotek_grid_build_filters in Lingotek Translation 7.4

Same name and namespace in other branches
  1. 7.7 lingotek.bulk_grid.inc \lingotek_grid_build_filters()
  2. 7.5 lingotek.bulk_grid.inc \lingotek_grid_build_filters()
  3. 7.6 lingotek.bulk_grid.inc \lingotek_grid_build_filters()

Builds the form elements for the filters.

Return value

array The full list of filters is later filtered so that there is exactly one column for every filter

1 call to lingotek_grid_build_filters()
lingotek_filters_popup_form in ./lingotek.bulk_grid.inc

File

./lingotek.bulk_grid.inc, line 772
Bulk Grid form

Code

function lingotek_grid_build_filters($form_state) {
  $languages = language_list();
  $source_languages = array(
    'all' => 'All Languages',
  );
  foreach ($languages as $code => $language) {
    $source_languages[$code] = $language->name . ' (' . $language->lingotek_locale . ')';
  }
  $profiles = array();
  $profiles['all'] = 'All';
  $profiles[LingotekSync::PROFILE_CUSTOM] = 'Custom';
  $profiles[LingotekSync::PROFILE_DISABLED] = 'Disabled';
  $profile_defaults = lingotek_get_profiles();
  foreach ($profile_defaults as $key => $p) {
    $profiles[$key] = $p['name'];
  }
  $filters = array(
    'nid' => array(
      '#type' => 'textfield',
      '#default_value' => isset($_SESSION['grid_filters']['nid']) ? $_SESSION['grid_filters']['nid'] : '',
      '#title' => t('Node ID is'),
      '#size' => 8,
    ),
    'document_id' => array(
      '#type' => 'textfield',
      '#default_value' => isset($_SESSION['grid_filters']['document_id']) ? $_SESSION['grid_filters']['document_id'] : '',
      '#title' => t('Doc ID is'),
      '#size' => 10,
    ),
    'source_language' => array(
      '#type' => 'select',
      '#default_value' => isset($_SESSION['grid_filters']['source_language']) ? $_SESSION['grid_filters']['source_language'] : 'all',
      '#title' => t('Source Language'),
      '#options' => $source_languages,
    ),
    'profile' => array(
      '#type' => 'select',
      '#default_value' => isset($_SESSION['grid_filters']['profile']) ? $_SESSION['grid_filters']['profile'] : 'all',
      '#title' => t('Translation Profile'),
      '#options' => $profiles,
    ),
    /*'title' => array(
        '#type' => 'textfield',
        '#default_value' => isset($_SESSION['grid_filters']['title']) ? $_SESSION['grid_filters']['title'] : '',
        '#title' => t('Title Includes'),
        '#size' => 30,
      ),
      'body' => array(
        '#type' => 'textfield',
        '#default_value' => isset($_SESSION['grid_filters']['body']) ? $_SESSION['grid_filters']['body'] : '',
        '#title' => t('Body Includes'),
        '#size' => 30,
      ),*/
    'upload_status' => array(
      '#type' => 'select',
      '#default_value' => isset($_SESSION['grid_filters']['upload_status']) ? $_SESSION['grid_filters']['upload_status'] : 'all',
      '#title' => t('Upload Status'),
      '#options' => array(
        'all' => t('All'),
        LingotekSync::STATUS_EDITED => t('Out of Sync'),
        LingotekSync::STATUS_CURRENT => t('In Sync'),
        LingotekSync::STATUS_DISABLED => t('Disabled'),
      ),
      '#multiple' => FALSE,
    ),
    'content_type' => array(
      '#type' => 'select',
      '#default_value' => isset($_SESSION['grid_filters']['content_type']) ? $_SESSION['grid_filters']['content_type'] : 'all',
      '#title' => t('Content Type(s)'),
      '#options' => array(
        'all' => t('All'),
      ) + node_type_get_names(),
      '#multiple' => TRUE,
    ),
  );
  return lingotek_grid_process_elements($filters, '', '__filter');

  // Add prefix and suffix to the name of each filter element
}