function _language_hierarchy_normalize_weight in Language Hierarchy 7
Normalizes weight of the languages so 'flat' functions like language_list still return the languages in correct order.
2 calls to _language_hierarchy_normalize_weight()
- language_hierarchy_form_submit in ./
language_hierarchy_form.inc - Submit callback for the language_hierarchy_form form.
- language_hierarchy_language_add_form_submit_callback in ./
language_hierarchy.module - An additional submission callback for the add predefined language form.
File
- ./
language_hierarchy.module, line 523
Code
function _language_hierarchy_normalize_weight() {
$languages = language_hierarchy_language_list();
$normalized_weight = -10;
foreach ($languages as $langcode => $language) {
db_update('languages')
->fields(array(
'weight' => $normalized_weight,
))
->condition('language', $langcode, '=')
->execute();
$normalized_weight++;
}
}