_locale_languages_configure_form_language_table
- Versions
- 7
_locale_languages_configure_form_language_table(&$form, $type)
Helper function to build a language provider table.
Related topics
Code
includes/locale.inc, line 526
<?php
function _locale_languages_configure_form_language_table(&$form, $type) {
$info = $form['#language_types_info'][$type];
$table_form = array(
'#title' => t('@type language', array('@type' => $info['name'])),
'#tree' => TRUE,
'#description' => $info['description'],
'#language_providers' => array(),
'#show_operations' => FALSE,
'weight' => array('#tree' => TRUE),
'enabled' => array('#tree' => TRUE),
);
$language_providers = $form['#language_providers'];
$enabled_providers = variable_get("locale_language_providers_enabled_$type", array());
$providers_weight = variable_get("locale_language_providers_weight_$type", array());
// Add missing data to the providers lists.
foreach ($language_providers as $id => $provider) {
if (!isset($providers_weight[$id])) {
$providers_weight[$id] = language_provider_weight($provider);
}
if (!isset($enabled_providers[$id])) {
$enabled_providers[$id] = FALSE;
}
}
// Order providers list by weight.
asort($providers_weight);
foreach ($providers_weight as $id => $weight) {
$enabled = $enabled_providers[$id];
$provider = $language_providers[$id];
// List the provider only if the current type is defined in its 'types' key.
// If it is not defined default to all the configurabe language types.
$types = array_flip(isset($provider['types']) ? $provider['types'] : $form['#language_types']);
if (isset($types[$type])) {
$table_form['#language_providers'][$id] = $provider;
$table_form['weight'][$id] = array(
'#type' => 'weight',
'#default_value' => $weight,
'#attributes' => array('class' => array("language-provider-weight-$type")),
);
$table_form['title'][$id] = array('#markup' => check_plain($provider['name']));
$table_form['enabled'][$id] = array('#type' => 'checkbox', '#default_value' => $enabled);
if ($id === LANGUAGE_NEGOTIATION_DEFAULT) {
$table_form['enabled'][$id]['#default_value'] = TRUE;
$table_form['enabled'][$id]['#attributes'] = array('disabled' => 'disabled');
}
$table_form['description'][$id] = array('#markup' => filter_xss_admin($provider['description']));
$config_op = array();
if (isset($provider['config'])) {
$config_op = array('#type' => 'link', '#title' => t('Configure'), '#href' => $provider['config']);
// If there is at least one operation enabled show the operation column.
$table_form['#show_operations'] = TRUE;
}
$table_form['operation'][$id] = $config_op;
}
}
$form[$type] = $table_form;
}
?>Login or register to post comments 