Saves a list of language negotiation methods for a language type.
$type: The language type.
$method_weights: An array of language negotiation method weights keyed by method ID.
function language_negotiation_set($type, $method_weights) {
// Save only the necessary fields.
$method_fields = array(
'callbacks',
'file',
'cache',
);
$negotiation = array();
$negotiation_info = language_negotiation_info();
$default_types = language_types_get_configurable(FALSE);
// Order the language negotiation method list by weight.
asort($method_weights);
foreach ($method_weights as $method_id => $weight) {
if (isset($negotiation_info[$method_id])) {
$method = $negotiation_info[$method_id];
// If the language negotiation method does not express any preference
// about types, make it available for any configurable type.
$types = array_flip(isset($method['types']) ? $method['types'] : $default_types);
// Check whether the method is defined and has the right type.
if (isset($types[$type])) {
$method_data = array();
foreach ($method_fields as $field) {
if (isset($method[$field])) {
$method_data[$field] = $method[$field];
}
}
$negotiation[$method_id] = $method_data;
}
}
}
variable_set("language_negotiation_{$type}", $negotiation);
}