function lingotek_grid_build_filters in Lingotek Translation 7.7
Same name and namespace in other branches
- 7.4 lingotek.bulk_grid.inc \lingotek_grid_build_filters()
- 7.5 lingotek.bulk_grid.inc \lingotek_grid_build_filters()
- 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()
File
- ./
lingotek.bulk_grid.inc, line 1533
Code
function lingotek_grid_build_filters($form_state) {
$languages = language_list();
$source_languages = array();
foreach ($languages as $code => $language) {
$source_languages[$code] = t($language->name) . ' (' . $language->lingotek_locale . ')';
}
asort($source_languages);
$profiles = array();
$profiles[LingotekSync::PROFILE_DISABLED] = t('Disabled');
$profile_defaults = lingotek_get_profiles();
foreach ($profile_defaults as $key => $p) {
$profiles[$key] = $p
->getName();
}
unset($profiles['CONFIG']);
asort($profiles);
$entity_type = $form_state['entity_type'];
$filters = array(
'nid' => array(
'#type' => 'textfield',
'#default_value' => isset($_SESSION['grid_filters'][$entity_type]['nid']) ? $_SESSION['grid_filters'][$entity_type]['nid'] : '',
'#title' => t('Entity ID is'),
'#size' => 8,
),
'document_id' => array(
'#type' => 'textfield',
'#default_value' => isset($_SESSION['grid_filters'][$entity_type]['document_id']) ? $_SESSION['grid_filters'][$entity_type]['document_id'] : '',
'#title' => t('Doc ID is'),
'#size' => 10,
),
'source_language' => array(
'#type' => 'select',
'#default_value' => isset($_SESSION['grid_filters'][$entity_type]['source_language']) ? $_SESSION['grid_filters'][$entity_type]['source_language'] : 'all',
'#title' => t('Source Language'),
'#options' => array(
'all' => t('All Languages'),
) + $source_languages,
),
'profile' => array(
'#type' => 'select',
'#default_value' => isset($_SESSION['grid_filters'][$entity_type]['profile']) ? $_SESSION['grid_filters'][$entity_type]['profile'] : 'all',
'#title' => t('Translation Profile'),
'#options' => array(
'all' => 'All',
) + $profiles,
'#multiple' => TRUE,
),
'upload_status' => array(
'#type' => 'select',
'#default_value' => isset($_SESSION['grid_filters'][$entity_type]['upload_status']) ? $_SESSION['grid_filters'][$entity_type]['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'),
'uploaded' => t('Uploaded'),
'upload_failed' => t('Upload Failed'),
'never' => t('Never Uploaded'),
'disassoc' => t('Disassociated'),
),
'#multiple' => FALSE,
),
'marked_status' => array(
'#type' => 'select',
'#default_value' => isset($_SESSION['grid_filters'][$entity_type]['marked_status']) ? $_SESSION['grid_filters'][$entity_type]['marked_status'] : 'all',
'#title' => t('Marked status'),
'#options' => array(
'all' => t('All'),
'marked' => t('Marked'),
'unmarked' => t('Not marked'),
),
'#multiple' => FALSE,
),
);
// Include a content-type filter if there are bundles by which to filter.
$entity_info = entity_get_info($_SESSION['grid_entity_type']);
if (!empty($entity_info['bundles'])) {
$grid_bundles = array_map(function ($val) {
return $val['label'];
}, $entity_info['bundles']);
asort($grid_bundles);
$filters['content_type'] = array(
'#type' => 'select',
'#default_value' => isset($_SESSION['grid_filters'][$entity_type]['content_type']) ? $_SESSION['grid_filters'][$entity_type]['content_type'] : 'all',
'#title' => t('Content Type(s)'),
'#options' => array(
'all' => t('All'),
) + $grid_bundles,
'#multiple' => TRUE,
);
}
return lingotek_grid_process_elements($filters, '', '__filter');
// Add prefix and suffix to the name of each filter element
}