You are here

function lingotek_setup_language_switcher_form in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.3 lingotek.setup.inc \lingotek_setup_language_switcher_form()
  2. 7.4 lingotek.setup.inc \lingotek_setup_language_switcher_form()
  3. 7.5 lingotek.setup.inc \lingotek_setup_language_switcher_form()
  4. 7.6 lingotek.setup.inc \lingotek_setup_language_switcher_form()
1 string reference to 'lingotek_setup_language_switcher_form'
lingotek_menu in ./lingotek.module
Implements hook_menu().

File

./lingotek.setup.inc, line 680

Code

function lingotek_setup_language_switcher_form($form, $form_state) {
  drupal_add_js(drupal_get_path('module', 'lingotek') . '/js/lingotek.admin.js');
  $current_theme = variable_get('theme_default', 'none');

  //global $theme_key;
  $query = db_select('block', 'b');
  $query
    ->fields('b');
  $query
    ->condition('module', 'locale');
  $query
    ->condition('delta', 'language');
  $query
    ->condition('theme', $current_theme);
  $result = $query
    ->execute();
  $block = $result
    ->fetchAssoc();
  $block_enabled = $block['status'];
  $block_regions = system_region_list($current_theme, REGIONS_VISIBLE);
  $default_region = "sidebar_first";
  $default_region_value = array_key_exists($block['region'], $block_regions) ? $block['region'] : (array_key_exists($default_region, $block_regions) ? $default_region : NULL);
  $form = array(
    '#type' => 'item',
    '#title' => t('Default Language Switcher'),
    'actions' => array(
      '#type' => 'actions',
    ),
  );
  $form['theme'] = array(
    '#type' => 'hidden',
    '#value' => $current_theme,
  );
  $form['enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable the default language switcher'),
    '#default_value' => TRUE,
  );
  $form['region'] = array(
    '#type' => 'select',
    '#description' => t('The region where the switcher will be displayed.'),
    '#options' => $block_regions,
    '#default_value' => $default_region_value,
    '#states' => array(
      'invisible' => array(
        ':input[name="enabled"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  if (is_array($_SESSION['lingotek_setup_path'])) {
    if (end($_SESSION['lingotek_setup_path']) == LINGOTEK_MENU_LANG_BASE_URL . '/setup-language-switcher') {
      $null = array_pop($_SESSION['lingotek_setup_path']);
    }

    // if the user went back, remove the last element, which is this page.
    $form['lingotek_back_button'] = lingotek_setup_link(end($_SESSION['lingotek_setup_path']), t('Previous Step'));
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Next'),
  );
  $output = array(
    $form,
  );
  $output[] = lingotek_support_footer();
  return $output;
}