You are here

function language_selection_page_admin in Language Selection Page 6

Same name and namespace in other branches
  1. 7.2 language_selection_page.admin.inc \language_selection_page_admin()
  2. 7 language_selection_page.admin.inc \language_selection_page_admin()

The admin page form.

Return value

array

1 string reference to 'language_selection_page_admin'
language_selection_page_menu in ./language_selection_page.module
Implements hook_menu().

File

./language_selection_page.admin.inc, line 11
The admin page of the language selection page module.

Code

function language_selection_page_admin() {
  module_load_include('inc', 'language_selection_page', 'includes/language_selection_page.helpers');
  $form = array();
  $error = FALSE;
  $language_count = _language_selection_page_check_language_count();
  if ($language_count['db'] != $language_count['vars']) {
    drupal_set_message(_language_selection_page_get_error_messages('language_count', $language_count['db'], $language_count['vars']), 'error');
    return $form;
  }
  if (variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE) != 2) {
    drupal_set_message(_language_selection_page_get_error_messages('language_negotiation', t('Language negotiation'), t('Path prefix with language fallback.'), url('admin/settings/language/configure')), 'warning');
    $error = TRUE;
  }
  if ($language_count['db'] < 2) {
    drupal_set_message(_language_selection_page_get_error_messages('language_enabled', url('admin/settings/language')), 'warning');
    $error = TRUE;
  }
  if ($error) {
    return $form;
  }
  $lang_list = language_list('enabled');
  foreach ($lang_list[1] as $lang) {
    if (empty($lang->prefix)) {
      drupal_set_message(_language_selection_page_get_error_messages('language_prefix', url('admin/settings/language/edit/' . $lang->language), $lang->name), 'warning');
    }
  }
  $options = array(
    '1' => t('No but redirect if language is found from cookie.'),
    '2' => t('No'),
    '4' => t('Yes'),
  );
  $form['language_selection_page_enable'] = array(
    '#title' => t('Redirect to a language selection page if no language is detected from URL and/or Cookie ?'),
    '#type' => 'radios',
    '#default_value' => variable_get('language_selection_page_enable', 2),
    '#options' => $options,
    '#description' => t('Select yes if you want to enable the Language Selection Page when no language is detected from URL and/or Cookie.'),
  );
  $options = array(
    '8' => t('No'),
    '16' => t('Yes'),
  );
  $form['language_selection_page_use_language_cookie'] = array(
    '#title' => t('Use a cookie to remember your language ?'),
    '#type' => 'radios',
    '#default_value' => variable_get('language_selection_page_use_language_cookie', 8),
    '#options' => $options,
    '#description' => t('Select yes if you want to store the language in a cookie.<br/>The cookie is <i>%cookie</i>.', array(
      '%cookie' => LANGUAGE_SELECTION_PAGE_LANGUAGE_COOKIE_KEY,
    )),
  );
  $form['language_selection_page_language_url_argument'] = array(
    '#type' => 'textfield',
    '#title' => t('Language URL argument'),
    '#default_value' => variable_get('language_selection_page_language_url_argument', ''),
    '#size' => 15,
    '#description' => t('If this is set, the module will also check for a url argument.<br/>' . 'If that argument is found and validated, it will be used as language.<br/>' . 'Set this variable to empty to disable the behavior.'),
  );
  $options = array(
    '32' => t('Template in theme'),
    '64' => 'Template only',
  );
  $form['language_selection_page_redirect_type'] = array(
    '#title' => t('Select the way the Selection Page should work'),
    '#type' => 'select',
    '#multiple' => FALSE,
    '#default_value' => variable_get('language_selection_page_redirect_type', 64),
    '#options' => $options,
    '#description' => t('<b>Template in theme</b>: Insert the Language Selection Page body as <i>$content</i> in the current theme.
                         <br/><b>Template only</b>: Display the Language Selection Page template only.
                         <br/>Create a file named <i>language_selection_page.tpl.php</i> in your theme directory if you want to override the full page.
                         <br/>Create a file named <i>language_selection_page_body.tpl.php</i> in your theme directory if you want to override the body only.'),
  );
  $form['language_selection_page_blacklisted_paths'] = array(
    '#type' => 'textarea',
    '#title' => t('List of paths to blacklist'),
    '#default_value' => implode("\n", variable_get('language_selection_page_blacklisted_paths', array(
      'admin',
      'user',
      'admin/*',
      'admin*',
      'node/add/*',
      'node/*/edit',
    ))),
    '#size' => 10,
    '#description' => t('Write on each line a path to blacklist from Language Selection Page processor'),
  );
  $form['language_selection_page_cookie_lifetime'] = array(
    '#type' => 'textfield',
    '#field_suffix' => t('Seconds'),
    '#title' => t('Cookie lifetime'),
    '#default_value' => variable_get('language_selection_page_cookie_lifetime', 2592000),
    '#size' => 10,
    '#description' => t('Cookie lifetime, must be greater than zero. (2592000 = 1 month)'),
  );
  $form['#submit'][] = 'language_selection_page_admin_submit';
  return system_settings_form($form);
}