function lingotek_grid_build_filters in Lingotek Translation 7.5
Same name and namespace in other branches
- 7.7 lingotek.bulk_grid.inc \lingotek_grid_build_filters()
- 7.4 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 835 - Bulk Grid form
Code
function lingotek_grid_build_filters($form_state) {
$languages = language_list();
$source_languages = array(
'all' => t('All Languages'),
);
foreach ($languages as $code => $language) {
$source_languages[$code] = t($language->name) . ' (' . $language->lingotek_locale . ')';
}
$profiles = array();
$profiles['all'] = 'All';
$profiles[LingotekSync::PROFILE_CUSTOM] = t('Custom');
$profiles[LingotekSync::PROFILE_DISABLED] = t('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('Entity 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,
'#multiple' => TRUE,
),
/*'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'),
),
'#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']);
$filters['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'),
) + $grid_bundles,
'#multiple' => TRUE,
);
}
return lingotek_grid_process_elements($filters, '', '__filter');
// Add prefix and suffix to the name of each filter element
}