You are here

function lingotek_grid_build_column_checkboxes in Lingotek Translation 7.7

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

Builds the checkbox elements for customizing The Grid's columns Uses predefined defaults specified in 'lingotek_grid_define_columns'

1 call to lingotek_grid_build_column_checkboxes()
lingotek_grid_customize_form in ./lingotek.bulk_grid.inc

File

./lingotek.bulk_grid.inc, line 941

Code

function lingotek_grid_build_column_checkboxes($form_state) {
  $prefix = '';
  $suffix = '__custom';

  // Suffix specified because the filter submit function differentiates based on this tag and puts the keys into the session variable as such
  $entity_type = $form_state['entity_type'];
  $columns = lingotek_grid_define_columns($entity_type);

  // Allowed columns and defaults for source and target grids are defined here
  $e_grid_custom = isset($_SESSION['grid_custom'][$entity_type]) ? $_SESSION['grid_custom'][$entity_type] : array();
  $column_elements = array(
    'marked' => array(
      '#type' => 'checkbox',
      '#title' => t('Marked'),
      '#default_value' => isset($e_grid_custom[$prefix . 'marked' . $suffix]) ? $e_grid_custom[$prefix . 'marked' . $suffix] : in_array('marked', $columns['defaults']),
    ),
    'nid' => array(
      '#type' => 'checkbox',
      '#title' => t('ID'),
      '#default_value' => isset($e_grid_custom[$prefix . 'nid' . $suffix]) ? $e_grid_custom[$prefix . 'nid' . $suffix] : in_array('nid', $columns['defaults']),
    ),
    'content_type' => array(
      '#type' => 'checkbox',
      '#title' => t('Content Type'),
      '#default_value' => isset($e_grid_custom[$prefix . 'content_type' . $suffix]) ? $e_grid_custom[$prefix . 'content_type' . $suffix] : in_array('content_type', $columns['defaults']),
    ),
    'title' => array(
      '#type' => 'checkbox',
      '#title' => t('Title'),
      '#default_value' => isset($e_grid_custom[$prefix . 'title' . $suffix]) ? $e_grid_custom[$prefix . 'title' . $suffix] : in_array('title', $columns['defaults']),
    ),
    'label' => array(
      '#type' => 'checkbox',
      '#title' => t('Label'),
      '#default_value' => isset($e_grid_custom[$prefix . 'label' . $suffix]) ? $e_grid_custom[$prefix . 'label' . $suffix] : in_array('label', $columns['defaults']),
    ),
    'description' => array(
      '#type' => 'checkbox',
      '#disabled' => 'true',
      '#title' => t('Description'),
      '#default_value' => isset($e_grid_custom[$prefix . 'nid' . $suffix]) ? $e_grid_custom[$prefix . 'description' . $suffix] : in_array('description', $columns['defaults']),
    ),
    'language' => array(
      '#type' => 'checkbox',
      '#title' => t('Source'),
      '#default_value' => isset($e_grid_custom[$prefix . 'language' . $suffix]) ? $e_grid_custom[$prefix . 'language' . $suffix] : in_array('language', $columns['defaults']),
    ),
    'translations' => array(
      '#type' => 'checkbox',
      '#title' => t('Translations'),
      '#default_value' => isset($e_grid_custom[$prefix . 'translations' . $suffix]) ? $e_grid_custom[$prefix . 'translations' . $suffix] : in_array('translations', $columns['defaults']),
    ),
    'configuration' => array(
      '#type' => 'checkbox',
      '#title' => t('Profile'),
      '#default_value' => isset($e_grid_custom[$prefix . 'configuration' . $suffix]) ? $e_grid_custom[$prefix . 'configuration' . $suffix] : in_array('configuration', $columns['defaults']),
    ),
    'document_id' => array(
      '#type' => 'checkbox',
      '#title' => t('Doc ID'),
      '#default_value' => isset($e_grid_custom[$prefix . 'document_id' . $suffix]) ? $e_grid_custom[$prefix . 'document_id' . $suffix] : in_array('document_id', $columns['defaults']),
    ),
    'workflow_id' => array(
      '#type' => 'checkbox',
      '#title' => t('Workflow ID'),
      '#default_value' => isset($e_grid_custom[$prefix . 'workflow_id' . $suffix]) ? $e_grid_custom[$prefix . 'workflow_id' . $suffix] : in_array('workflow_id', $columns['defaults']),
    ),
    'workflow_name' => array(
      '#type' => 'checkbox',
      '#title' => t('Workflow Name'),
      '#default_value' => isset($e_grid_custom[$prefix . 'workflow_name' . $suffix]) ? $e_grid_custom[$prefix . 'workflow_name' . $suffix] : in_array('workflow_name', $columns['defaults']),
    ),
    'changed' => array(
      '#type' => 'checkbox',
      '#title' => t('Last Modified'),
      '#default_value' => isset($e_grid_custom[$prefix . 'changed' . $suffix]) ? $e_grid_custom[$prefix . 'changed' . $suffix] : in_array('changed', $columns['defaults']),
    ),
    'last_uploaded' => array(
      '#type' => 'checkbox',
      '#title' => t('Last Uploaded'),
      '#default_value' => isset($e_grid_custom[$prefix . 'last_uploaded' . $suffix]) ? $e_grid_custom[$prefix . 'last_uploaded' . $suffix] : in_array('last_uploaded', $columns['defaults']),
    ),
    'locale_progress_percent' => array(
      '#type' => 'checkbox',
      '#title' => t('Target Progress Percentage'),
      '#default_value' => isset($e_grid_custom[$prefix . 'locale_progress_percent' . $suffix]) ? $e_grid_custom[$prefix . 'locale_progress_percent' . $suffix] : in_array('locale_progress_percent', $columns['defaults']),
    ),
    'progress_updated' => array(
      '#type' => 'checkbox',
      '#title' => t('Progress Last Updated'),
      '#default_value' => isset($e_grid_custom[$prefix . 'progress_updated' . $suffix]) ? $e_grid_custom[$prefix . 'progress_updated' . $suffix] : in_array('progress_updated', $columns['defaults']),
    ),
    'last_downloaded' => array(
      '#type' => 'checkbox',
      '#title' => t('Time Last Downloaded'),
      '#default_value' => isset($e_grid_custom[$prefix . 'last_downloaded' . $suffix]) ? $e_grid_custom[$prefix . 'last_downloaded' . $suffix] : in_array('last_downloaded', $columns['defaults']),
    ),
    'actions' => array(
      '#type' => 'checkbox',
      '#title' => t('Actions'),
      '#default_value' => isset($e_grid_custom[$prefix . 'actions' . $suffix]) ? $e_grid_custom[$prefix . 'actions' . $suffix] : in_array('actions', $columns['defaults']),
    ),
  );
  if ($form_state['entity_type'] == 'taxonomy_term') {
    $column_elements['description']['#disabled'] = 'true';
    $column_elements['title']['#disabled'] = 'true';
  }
  if ($entity_type == 'paragraphs_item') {
    unset($column_elements['changed']);
    $column_elements['title'] = array(
      '#type' => 'checkbox',
      '#title' => t('Parent Node Title'),
      '#default_value' => isset($e_grid_custom[$prefix . 'title' . $suffix]) ? $e_grid_custom[$prefix . 'title' . $suffix] : in_array('title', $columns['defaults']),
    );
    $column_elements['parent_node_id'] = array(
      '#type' => 'checkbox',
      '#title' => t('Parent Node ID'),
      '#default_value' => isset($e_grid_custom[$prefix . 'parent_node_id' . $suffix]) ? $e_grid_custom[$prefix . 'parent_node_id' . $suffix] : in_array('parent_node_id', $columns['defaults']),
    );
    $column_elements['paragraph_snippet'] = array(
      '#type' => 'checkbox',
      '#title' => t('Paragraph Snippet'),
      '#default_value' => isset($e_grid_custom[$prefix . 'paragraph_snippet' . $suffix]) ? $e_grid_custom[$prefix . 'paragraph_snippet' . $suffix] : in_array('paragraph_snippet', $columns['defaults']),
    );
  }
  $column_elements = array_intersect_key($column_elements, $columns['columns']);

  // Reduces the output columns to the defaults specified in 'lingotek_grid_define_columns'
  return lingotek_grid_process_elements($column_elements, $prefix, $suffix);

  // adds prefixes and suffixes to the elements
}