Language_negotiation_set | drupal every day

functionlanguage_negotiation_set($type, $language_providers) {
  // Save only the necessary fields.
$provider_fields = array('callbacks', 'file', 'cache');

  $negotiation = array();
  $providers_weight = array();
  $defined_providers = language_negotiation_info();
  $default_types = language_types_configurable(FALSE);

  // Initialize the providers weight list.
foreach ($language_providersas$id => $provider) {
    $providers_weight[$id] = language_provider_weight($provider);
  }

  // Order providers list by weight.
asort($providers_weight);

  foreach ($providers_weightas$id => $weight) {
    if (isset($defined_providers[$id])) {
      $provider = $defined_providers[$id];
      // If the provider does not express any preference about types, make it
// available for any configurable type.
$types = array_flip(isset($provider['types']) ? $provider['types'] : $default_types);
      // Check if the provider is defined and has the right type.
if (isset($types[$type])) {
        $provider_data = array();
        foreach ($provider_fieldsas$field) {
          if (isset($provider[$field])) {
            $provider_data[$field] = $provider[$field];
          }
        }
        $negotiation[$id] = $provider_data;
      }
    }
  }

  variable_set("language_negotiation_$type", $negotiation);
}
?>

Leave a Reply

Your email address will not be published. Required fields are marked *