function globallink_entity_dashboard_filter_form in GlobalLink Connect for Drupal 7.5
Same name and namespace in other branches
- 7.7 globallink_entity/globallink_entity_send.inc \globallink_entity_dashboard_filter_form()
- 7.6 globallink_entity/globallink_entity_send.inc \globallink_entity_dashboard_filter_form()
Builds form to filter entities to send for translation on dashboard.
1 string reference to 'globallink_entity_dashboard_filter_form'
- globallink_entity_dashboard in globallink_entity/
globallink_entity_send.inc - Builds forms on entity send dashboard.
File
- globallink_entity/
globallink_entity_send.inc, line 30
Code
function globallink_entity_dashboard_filter_form($form, &$form_state) {
module_load_include('inc', 'globallink', 'globallink');
$form = array();
$redirect_nid = isset($_GET['rnid']) ? $_GET['rnid'] : '';
if (!empty($redirect_nid)) {
$_SESSION['globallink_entity_source_locale'] = '';
$_SESSION['globallink_entity_filter'] = array();
$_SESSION['globallink_entity_source_locale'] = globallink_get_node_source_languages($redirect_nid);
}
$locales = globallink_get_mapped_drupal_locales(FALSE);
$node_types = globallink_get_translatable_node_types(FALSE);
if (isset($locales) && count($locales) > 1) {
if (isset($node_types) && count($node_types) > 0) {
$session = isset($_SESSION['globallink_entity_filter']) ? $_SESSION['globallink_entity_filter'] : array();
$filters = globallink_build_filters(FALSE);
$form['filters'] = array(
'#type' => 'fieldset',
'#title' => t('FILTER RECORDS'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$selected_arr = array();
$selected_source_lang = '';
foreach ($session as $filter) {
list($type, $value) = $filter;
$selected_arr[$type] = $value;
}
$form['filters']['status']['filters'] = array(
'#type' => 'container',
'#attributes' => array(
'style' => 'padding: 0px;',
),
);
$module_path = drupal_get_path('module', 'globallink');
drupal_add_css($module_path . '/css/globallink.css');
foreach ($filters as $key => $filter) {
$disabled = FALSE;
$default = '[Any]';
switch ($filter['form-type']) {
case 'select':
if ($key == 'language_name') {
$default_language = language_default();
$default = $default_language->language;
if (isset($_SESSION['globallink_entity_source_locale']) && $_SESSION['globallink_entity_source_locale'] != '') {
$default = $_SESSION['globallink_entity_source_locale'];
}
$selected_source_lang = $default;
$form['filters']['status']['filters'][$key] = array(
'#type' => $filter['form-type'],
'#options' => $filter['options'],
'#title' => check_plain($filter['title']),
'#default_value' => $default,
'#disabled' => $disabled,
'#attributes' => array(
'style' => array(
'padding:5px;',
),
),
'#prefix' => '<tr><td style="text-align: left;width: 15%;vertical-align: middle;border: none;">',
'#field_prefix' => '</td><td>',
'#ajax' => array(
'event' => 'change',
'callback' => 'globallink_entity_dashboard_filter_target',
'wrapper' => 'replace-target',
),
);
$form['filters']['status']['filters']['node_parent'] = array(
'#type' => 'checkbox',
'#return_value' => 1,
'#default_value' => 1,
'#prefix' => '<span style="display:block;padding-top:10px;">',
'#suffix' => '</span></td></tr>',
'#field_suffix' => 'Show Source Language Only</td>',
);
}
elseif ($key == 'target_language') {
if (isset($form_state['values']['language_name'])) {
$form['filters']['status']['filters'][$key] = array(
'#type' => $filter['form-type'],
'#options' => globallink_entity_get_target_options($form_state['values']['language_name']),
'#disabled' => $disabled,
'#default_value' => isset($form_state['values']['target_language']) ? $form_state['values']['target_language'] : '',
'#attributes' => array(
'style' => array(
'padding:0px;',
),
),
'#field_prefix' => '<td><div id="replace-target">',
'#field_suffix' => '</div></td>',
);
}
else {
$form['filters']['status']['filters'][$key] = array(
'#type' => $filter['form-type'],
'#options' => globallink_entity_get_target_options($selected_source_lang),
'#title' => check_plain($filter['title']),
'#disabled' => $disabled,
'#default_value' => isset($form_state['values']['target_language']) ? $form_state['values']['target_language'] : '',
'#attributes' => array(
'style' => array(
'padding:0px;',
),
),
'#prefix' => '<tr><td style="text-align: left;width: 15%;vertical-align: middle;border: none;">',
'#suffix' => '</tr>',
'#field_prefix' => '</td><td><div id="replace-target">',
'#field_suffix' => '</div></td>',
);
}
}
else {
if ($key == 'status' && module_exists('revisioning')) {
$default = 'status-1';
}
$form['filters']['status']['filters'][$key] = array(
'#type' => $filter['form-type'],
'#options' => $filter['options'],
'#title' => check_plain($filter['title']),
'#disabled' => $disabled,
'#default_value' => isset($selected_arr[$key]) ? $selected_arr[$key] : $default,
'#attributes' => array(
'style' => array(
'padding:0px;',
),
),
'#prefix' => '<tr><td style="text-align: left;width: 15%;vertical-align: middle;border: none;">',
'#suffix' => '</tr>',
'#field_suffix' => '</td>',
'#field_prefix' => '</td><td>',
);
}
break;
case 'modified-after':
drupal_add_library('system', 'ui.datepicker');
drupal_add_js('jQuery(document).ready(function(){
jQuery( ".pickadate" ).datepicker({
dateFormat: "mm/dd/yy",
maxDate: 0,
autoSize: true,
showOn: "button",
buttonImage: "' . $GLOBALS['base_url'] . '/' . $module_path . '/css/icon-calendar.png",
buttonImageOnly: true,
buttonText: "Click to select date"
});});', 'inline');
$form['filters']['status']['filters'][$key] = array(
'#type' => $filter['form-type'],
'#title' => check_plain($filter['title']),
'#disabled' => $disabled,
'#attributes' => array(
'class' => array(
'pickadate',
),
'style' => array(
'padding:0px;',
),
),
'#default_value' => isset($selected_arr[$key]) ? format_date($selected_arr[$key], 'custom', 'm/d/Y') : '',
'#prefix' => '<tr><td style="text-align: left;width: 15%;vertical-align: middle;border: none;">',
'#suffix' => '</tr></table></div>',
'#field_suffix' => '</td>',
'#field_prefix' => '</td><td>',
);
break;
case 'modified':
$form['filters']['status']['filters'][$key] = array(
'#type' => $filter['form-type'],
'#title' => check_plain($filter['title']),
'#options' => $filter['options'],
'#disabled' => $disabled,
'#default_value' => isset($selected_arr[$key]) ? $selected_arr[$key] : 0,
'#attributes' => array(
'class' => array(
'container-inline',
),
'style' => array(
'padding:0px;',
),
),
'#prefix' => '<div class="container-inline"><table><tr><td style="text-align: left;width: 15%;vertical-align: middle;border: none;">',
'#suffix' => '</tr>',
'#field_suffix' => '</td>',
'#field_prefix' => '</td><td>',
);
break;
case 'title':
$form['filters']['status']['filters'][$key] = array(
'#type' => $filter['form-type'],
'#title' => check_plain($filter['title']),
'#disabled' => $disabled,
'#default_value' => isset($selected_arr[$key]) ? $selected_arr[$key] : '',
'#attributes' => array(
'size' => 30,
),
'#prefix' => '<tr><td style="text-align: left;width: 15%;vertical-align: middle;border: none;">',
'#suffix' => '</tr>',
'#field_suffix' => '</td>',
'#field_prefix' => '</td><td>',
);
break;
}
}
$form['filters']['status']['actions'] = array(
'#type' => 'actions',
'#attributes' => array(
'class' => array(
'container-inline',
),
),
);
$disable_submit = FALSE;
if (isset($_SESSION['globallink_entity_filter'])) {
if (count($_SESSION['globallink_entity_filter']) > 0) {
$disable_submit = TRUE;
}
}
$form['filters']['status']['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Filter'),
'#disabled' => $disable_submit,
);
if (count($session)) {
$form['filter-search'] = array(
'#type' => 'fieldset',
'#title' => t('FILTER CRITERIA'),
);
$form['filter-search']['filter-markup'] = array(
'#type' => 'container',
);
$form['filter-search']['filter-markup'][] = array(
'#markup' => '<table>',
);
$filters = globallink_build_filters(FALSE);
foreach ($session as $filter) {
list($type, $value) = $filter;
$selected_arr[$type] = $value;
$label = '';
if ($type == 'node_parent') {
continue;
}
if (isset($filters[$type]['options'])) {
$label = $filters[$type]['options'][$value];
}
elseif ($filters[$type]['field'] == 'changed') {
$label = format_date($value, 'custom', 'm/d/Y');
}
else {
$label = $value;
}
$form['filter-search']['filter-markup'][] = array(
'#markup' => '<tr><td style="text-align: left;width: 15%;vertical-align: middle;border: none;"><b>' . $filters[$type]['title'] . '</b>: </td><td style="text-align: left;width: 85%;vertical-align: middle;border: none;">' . str_replace(' ', '', $label) . '</td></tr>',
);
}
$form['filter-search']['filter-markup'][] = array(
'#markup' => '</table>',
);
$form['filter-search']['status']['actions'] = array(
'#type' => 'actions',
'#attributes' => array(
'class' => array(
'container-inline',
),
),
);
$form['filter-search']['status']['actions']['reset'] = array(
'#type' => 'submit',
'#value' => t('Reset'),
);
}
}
else {
$form['tpt_node_types']['no_type'] = array(
'#type' => 'markup',
'#markup' => t('<br/><b><i>No Content types enabled for translation.</i></b>'),
);
}
}
else {
$form['locale_mapping']['no_mapping'] = array(
'#type' => 'markup',
'#markup' => t('<br/><b><i>No GlobalLink locale mapping found.</i></b>'),
);
}
return $form;
}