function language_negotiation_set
7.x language.inc | language_negotiation_set($type, $language_providers) |
Saves a list of language negotiation providers.
Parameters
$type: The language negotiation type.
$language_providers: An array of language negotiation provider weights keyed by provider ID. @see language_provider_weight()
Related topics
8 calls to language_negotiation_set()
- language_negotiation_purge in drupal-7.x/
includes/ language.inc - Removes any unused language negotiation providers from the configuration.
- language_types_set in drupal-7.x/
includes/ language.inc - Updates the language type configuration.
- LocaleMultilingualFieldsFunctionalTest::testMultilingualNodeForm in drupal-7.x/
modules/ locale/ locale.test - Test if field languages are correctly set through the node form.
- LocaleUILanguageNegotiationTest::runTest in drupal-7.x/
modules/ locale/ locale.test - LocaleUILanguageNegotiationTest::testLanguageDomain in drupal-7.x/
modules/ locale/ locale.test - Tests url() when separate domains are used for multiple languages.
File
- drupal-7.x/
includes/ language.inc, line 347 - Language Negotiation API.
Code
function language_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_providers as $id => $provider) {
$providers_weight[$id] = language_provider_weight($provider);
}
// Order providers list by weight.
asort($providers_weight);
foreach ($providers_weight as $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 whether the provider is defined and has the right type.
if (isset($types[$type])) {
$provider_data = array();
foreach ($provider_fields as $field) {
if (isset($provider[$field])) {
$provider_data[$field] = $provider[$field];
}
}
$negotiation[$id] = $provider_data;
}
}
}
variable_set("language_negotiation_$type", $negotiation);
}