You are here

function lingotek_admin_prefs_form in Lingotek Translation 7.3

Same name and namespace in other branches
  1. 7.7 lingotek.admin.inc \lingotek_admin_prefs_form()
  2. 7.4 lingotek.admin.inc \lingotek_admin_prefs_form()
  3. 7.5 lingotek.admin.inc \lingotek_admin_prefs_form()
  4. 7.6 lingotek.admin.inc \lingotek_admin_prefs_form()

Lingotek prefs Form

1 string reference to 'lingotek_admin_prefs_form'
lingotek_admin_configuration_view in ./lingotek.admin.inc

File

./lingotek.admin.inc, line 586

Code

function lingotek_admin_prefs_form($form, &$form_state, $show_fieldset = FALSE) {

  /*
   * Configuration
   */
  $form['prefs'] = array(
    '#type' => $show_fieldset ? 'fieldset' : 'item',
    '#title' => t('Preferences'),
    //'#description' => t('Module preferences.'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#group' => 'administrative_settings',
    'actions' => array(
      '#type' => 'actions',
      'submit' => array(
        '#type' => 'submit',
        '#value' => t('Save'),
      ),
    ),
    '#submit' => array(
      'lingotek_admin_prefs_form_submit',
    ),
  );
  $form['prefs']['lingotek_hide_tlmi'] = array(
    '#type' => 'checkbox',
    '#title' => t('Hide top-level menu item'),
    '#description' => t('When hidden, the module can still be accessed under <i>Configuration &gt; Regional and language</i>'),
    '#default_value' => variable_get('lingotek_hide_tlmi', 0),
  );
  $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);
  $ls_chkbox_enabled = array(
    '#type' => 'checkbox',
    '#title' => t('Enable the default language switcher'),
    '#default_value' => $block_enabled,
  );
  $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);
  $ls_select_region = array(
    '#type' => 'select',
    '#title' => t('The region where the switcher will be displayed.'),
    //'#description' => 'When enabled, the region to be displayed in.',
    '#options' => $block_regions,
    '#default_value' => $default_region_value,
    '#states' => array(
      'invisible' => array(
        ':input[name="enabled"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $fkey = 'prefs';

  // form key
  //  $form[$fkey] = array(
  //    '#type' => $show_fieldset ? 'fieldset' : 'item',
  //    '#title' => t('Default Language Switcher'),
  //    '#collapsible' => TRUE,
  //    '#collapsed' => TRUE,
  //    '#group' => 'administrative_settings',
  //    'actions' => array(
  //      '#type' => 'actions',
  //      'submit' => array(
  //        '#type' => 'submit',
  //        '#value' => t('Save configuration')
  //      ),
  //    /* 'note' => array(
  //      '#markup' => t('Note: The default language switcher block is only shown if at least two languages are enabled and language negotiation is set to <i>URL</i> or <i>Session</i>.')
  //      ) */
  //    )
  //  );
  //  $form[$fkey][] = array(
  //    '#type' => 'item',
  //    '#description' => t('Would you like to enable the default language switcher?')
  //  );
  $form[$fkey]['theme'] = array(
    '#type' => 'hidden',
    '#value' => $current_theme,
  );
  $form[$fkey]['enabled'] = $ls_chkbox_enabled;
  $form[$fkey]['region'] = $ls_select_region;
  $lang_negotiation_info = locale_language_negotiation_info();
  $general_detection_config_url = substr($lang_negotiation_info['locale-url']['config'], 0, strrpos($lang_negotiation_info['locale-url']['config'], "/"));
  $form[$fkey][] = array(
    '#type' => 'item',
    '#description' => t('Note: The default language switcher block is only shown if at least two languages are enabled and language negotiation is set to <i>URL</i> or <i>Session</i>.' . '<br>Go to ' . l(t('Language detection and selection'), $general_detection_config_url) . ' to change this.'),
    '#states' => array(
      'invisible' => array(
        ':input[name="enabled"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );

  /* $language_negotiation = variable_get('language_negotiation_language', array());
      $url_detection_enabled = array_key_exists('locale-url', $language_negotiation);
      $ls_chkbox_detection = array(
      '#type' => 'checkbox',
      '#title' => t('URL detection Enabled'),
      '#default_value' => $url_detection_enabled,
      '#disabled' => TRUE
      );
      $form[$form_key]['url_detection'] = $ls_chkbox_detection;

      $form[$form_key][] = array(
      '#type' => 'markup',
      '#markup' => json_encode($block),
      '#attributes' => array('class' => 'description')
      ); */
  return $form;
}