You are here

function lingotek_admin_prefs_form in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.3 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 1369

Code

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

  /*
   * Configuration
   */
  $form['#action'] = url('admin/settings/lingotek/settings', array(
    'fragment' => 'ltk-prefs',
  ));
  $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',
    ),
  );
  $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' => 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,
        ),
      ),
    ),
  );
  $fkey = 'prefs';

  // form key
  $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>' . t('Go to') . ' ' . l(t('Language detection and selection'), $general_detection_config_url) . ' ' . t('to change this.'),
    '#states' => array(
      'invisible' => array(
        ':input[name="enabled"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['prefs']['lingotek_advanced_taxonomy_terms'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable advanced handling of taxonomy terms'),
    '#description' => t('This option is used to handle translation of custom fields assigned to taxonomy terms.'),
    '#default_value' => variable_get('lingotek_advanced_taxonomy_terms', FALSE),
  );
  $form['prefs']['lingotek_advanced_menu_links'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable advanced handling of menu links'),
    '#description' => t('This option is used to handle translation of menu links as entities. Requires <i>Entity Menu Links</i> module.'),
    '#default_value' => variable_get('lingotek_advanced_menu_links', FALSE),
  );
  if (module_exists('bean')) {
    $form[$fkey]['lingotek_translate_beans'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable bean translation'),
      '#default_value' => variable_get('lingotek_translate_beans', FALSE),
      '#description' => t('If checked, translatable bean fields will be managed by Lingotek.'),
    );
  }
  if (module_exists('commerce_product')) {
    $form[$fkey]['lingotek_translate_commerce_product'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable commerce product translation'),
      '#default_value' => variable_get('lingotek_translate_commerce_product', FALSE),
      '#description' => t('If checked, translatable commerce product fields will be managed by Lingotek.'),
    );
  }
  if (module_exists('group')) {
    $form[$fkey]['lingotek_translate_groups'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable group translation'),
      '#default_value' => variable_get('lingotek_translate_groups', FALSE),
      '#description' => t('If checked, translatable group fields will be managed by Lingotek.'),
    );
  }
  if (module_exists('paragraphs')) {
    $form[$fkey]['lingotek_translate_paragraphs'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable paragraphs translation'),
      '#default_value' => variable_get('lingotek_translate_paragraphs', FALSE),
      '#description' => t('If checked, paragraphs fields will be managed by Lingotek.'),
    );
  }
  if (module_exists('file_entity')) {
    $form[$fkey]['lingotek_translate_files'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable file entity translation'),
      '#default_value' => variable_get('lingotek_translate_files', FALSE),
      '#description' => t('If checked, file entity fields will be managed by Lingotek.'),
    );
  }
  $node_based_translation = variable_get('lingotek_nodes_translation_method') == 'node' ? TRUE : FALSE;
  $form['prefs']['lingotek_translate_original_node_titles'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable translation of node titles'),
    '#description' => t('This option is used to translate non-field node titles.
                          <b>This only affects nodes being translated using node-based translation.</b>'),
    '#default_value' => variable_get('lingotek_translate_original_node_titles', FALSE),
  );
  $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),
  );
  $form[$fkey]['lingotek_show_language_label'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show language label on node pages'),
    '#default_value' => variable_get('lingotek_show_language_label'),
    '#description' => t('If checked, language labels will be displayed for nodes that have the \'language selection\' field set to be visible.'),
  );
  $form[$fkey]['lingotek_always_show_translate_tabs'] = array(
    '#type' => 'checkbox',
    '#title' => t('Always show non-Lingotek translate tabs'),
    '#default_value' => variable_get('lingotek_always_show_translate_tabs'),
    '#description' => t('If checked, edit-form tabs for both Content Translation and Entity Translation will not be hidden, even if the entity is managed by Lingotek.'),
    '#attributes' => array(
      'name' => 'lingotek_always_show_translate_tabs',
    ),
  );
  $form[$fkey]['lingotek_allow_local_edits'] = array(
    '#prefix' => '<div style="margin-left: 20px;">',
    '#suffix' => '</div>',
    '#type' => 'checkbox',
    '#title' => t('Allow local editing of Lingotek translations'),
    '#default_value' => variable_get('lingotek_allow_local_edits'),
    '#description' => t('If checked, local editing of translations managed by Lingotek will be allowed. (Note: any changes made may be overwritten if the translation is downloaded from Lingotek again.)'),
    '#states' => array(
      'invisible' => array(
        ':input[name="lingotek_always_show_translate_tabs"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  if (module_exists('metatag')) {
    $form[$fkey]['lingotek_translate_metatags'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable metatag translation'),
      '#default_value' => variable_get('lingotek_translate_metatags') ? 1 : 0,
      '#description' => t('If checked, content from metatag fields will be included with other uploaded content for each entity that supports metatags.'),
    );
  }
  $lang_specific_profiles_enabled = variable_get('lingotek_enable_language_specific_profiles', 0);
  $form[$fkey]['lingotek_enable_language_specific_profiles'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable language-specific profiles'),
    '#default_value' => $lang_specific_profiles_enabled ? 1 : 0,
    '#description' => t('If checked, languages enabled for Lingotek translation will not automatically be queued for all content.  Instead, languages enabled for Lingotek will be added to the available languages for profiles but will be disabled by default on profiles that have existing content. (Note: this cannot be unchecked if language-specific settings are in use.)'),
    '#disabled' => $lang_specific_profiles_enabled && lingotek_using_language_specific_profiles() ? TRUE : FALSE,
  );
  $form[$fkey]['lingotek_remove_target_from_tms'] = array(
    '#prefix' => '<div style="margin-left: 20px;">',
    '#suffix' => '</div>',
    '#type' => 'checkbox',
    '#title' => t('Remove languages from TMS when changing profiles'),
    '#default_value' => variable_get('lingotek_remove_target_from_tms', FALSE),
    '#description' => t('If checked, changing the translation profile to a profile with fewer languages will cause the non-applicable languages to be removed from the TMS.'),
    '#states' => array(
      'invisible' => array(
        ':input[name="lingotek_enable_language_specific_profiles"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form[$fkey]['lingotek_account_plan_type'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable advanced features'),
    '#default_value' => variable_get('lingotek_account_plan_type') == 'advanced' ? 1 : 0,
    '#description' => t('Some features may not be available without an Enterprise license for the Lingotek TMS. Call 801.331.7777 for details.'),
  );
  if (module_exists('entity_translation')) {
    $states = array(
      'published' => t('Published'),
      'unpublished' => t('Unpublished'),
      'same-as-source' => t('Same as source content'),
    );
    $form[$fkey]['lingotek_target_download_status'] = array(
      '#type' => 'select',
      '#title' => t('Translations download publication status'),
      '#description' => t('Translations download publication status: specify which published status translation downloads are assigned. (Note: this feature requires the <i>Entity Translation</i> module and the <i>"Enabled, with field translation"</i> setting within <i>Content types</i>.)'),
      '#options' => $states,
      '#default_value' => variable_get('lingotek_target_download_status', FALSE) ? variable_get('lingotek_target_download_status') : 'published',
    );
  }
  return $form;
}