function language_negotiation_configure_form_table

Builds a language negotiation method configuration table.

1 call to language_negotiation_configure_form_table()
language_negotiation_configure_form in drupal/core/modules/language/language.admin.inc
Builds the configuration form for language negotiation.

File

drupal/core/modules/language/language.admin.inc, line 449
Administration functions for language.module.

Code

function language_negotiation_configure_form_table(&$form, $type) {
  $info = $form['#language_types_info'][$type];
  $table_form = array(
    '#title' => t('@type language detection', array(
      '@type' => $info['name'],
    )),
    '#tree' => TRUE,
    '#description' => $info['description'],
    '#language_negotiation_info' => array(),
    '#show_operations' => FALSE,
    'weight' => array(
      '#tree' => TRUE,
    ),
  );
  $negotiation_info = $form['#language_negotiation_info'];
  $enabled_methods = variable_get("language_negotiation_{$type}", array());
  $methods_weight = variable_get("language_negotiation_methods_weight_{$type}", array());

  // Add missing data to the methods lists.
  foreach ($negotiation_info as $method_id => $method) {
    if (!isset($methods_weight[$method_id])) {
      $methods_weight[$method_id] = isset($method['weight']) ? $method['weight'] : 0;
    }
  }

  // Order methods list by weight.
  asort($methods_weight);
  foreach ($methods_weight as $method_id => $weight) {

    // A language method might be no more available if the defining module has
    // been disabled after the last configuration saving.
    if (!isset($negotiation_info[$method_id])) {
      continue;
    }
    $enabled = isset($enabled_methods[$method_id]);
    $method = $negotiation_info[$method_id];

    // List the method only if the current type is defined in its 'types' key.
    // If it is not defined default to all the configurable language types.
    $types = array_flip(isset($method['types']) ? $method['types'] : $form['#language_types']);
    if (isset($types[$type])) {
      $table_form['#language_negotiation_info'][$method_id] = $method;
      $method_name = check_plain($method['name']);
      $table_form['weight'][$method_id] = array(
        '#type' => 'weight',
        '#title' => t('Weight for !title language detection method', array(
          '!title' => drupal_strtolower($method_name),
        )),
        '#title_display' => 'invisible',
        '#default_value' => $weight,
        '#attributes' => array(
          'class' => array(
            "language-method-weight-{$type}",
          ),
        ),
        '#delta' => 20,
      );
      $table_form['title'][$method_id] = array(
        '#markup' => $method_name,
      );
      $table_form['enabled'][$method_id] = array(
        '#type' => 'checkbox',
        '#title' => t('Enable !title language detection method', array(
          '!title' => drupal_strtolower($method_name),
        )),
        '#title_display' => 'invisible',
        '#default_value' => $enabled,
      );
      if ($method_id === LANGUAGE_NEGOTIATION_SELECTED) {
        $table_form['enabled'][$method_id]['#default_value'] = TRUE;
        $table_form['enabled'][$method_id]['#attributes'] = array(
          'disabled' => 'disabled',
        );
      }
      $table_form['description'][$method_id] = array(
        '#markup' => filter_xss_admin($method['description']),
      );
      $config_op = array();
      if (isset($method['config'])) {
        $config_op['configure'] = array(
          'title' => t('Configure'),
          'href' => $method['config'],
        );

        // If there is at least one operation enabled show the operation column.
        $table_form['#show_operations'] = TRUE;
      }
      $table_form['operation'][$method_id] = array(
        '#type' => 'operations',
        '#links' => $config_op,
      );
    }
  }
  $form[$type] = $table_form;
}