User interface for the language overview screen.
function language_admin_overview_form($form, &$form_state) {
drupal_static_reset('language_list');
$languages = language_list(LANGUAGE_ALL);
$default = language_default();
$form['languages'] = array(
'#languages' => $languages,
'#language_default' => $default,
'#tree' => TRUE,
'#header' => array(
t('Name'),
t('Default'),
t('Weight'),
t('Operations'),
),
'#theme' => 'language_admin_overview_form_table',
);
foreach ($languages as $langcode => $language) {
$form['languages'][$langcode]['#weight'] = $language->weight;
$title = check_plain($language->name);
$description = '';
switch ($langcode) {
case LANGUAGE_NOT_APPLICABLE:
$description = t('For language independent content.');
break;
case LANGUAGE_NOT_SPECIFIED:
$description = t('Use this when the language is not (yet) known.');
break;
case LANGUAGE_MULTIPLE:
$description = t('Use this when multiple languages can be assigned, such as a multilingual PDF.');
break;
}
if (!empty($description)) {
$title .= '<div class="description">' . $description . '</div>';
}
$form['languages'][$langcode]['name'] = array(
'#markup' => $title,
);
$form['languages'][$langcode]['default'] = array(
'#type' => 'radio',
'#parents' => array(
'site_default',
),
'#title' => t('Set @title as default', array(
'@title' => $language->name,
)),
'#title_display' => 'invisible',
'#return_value' => $langcode,
'#default_value' => $langcode == $default->langcode ? $langcode : NULL,
'#id' => 'edit-site-default-' . $langcode,
);
$form['languages'][$langcode]['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight for @title', array(
'@title' => $language->name,
)),
'#title_display' => 'invisible',
'#default_value' => $language->weight,
'#attributes' => array(
'class' => array(
'language-order-weight',
),
),
'#delta' => 30,
);
$links = array();
if (empty($language->locked)) {
$links['edit'] = array(
'title' => t('edit'),
'href' => 'admin/config/regional/language/edit/' . $langcode,
);
if ($langcode != $default->langcode) {
$links['delete'] = array(
'title' => t('delete'),
'href' => 'admin/config/regional/language/delete/' . $langcode,
);
}
}
else {
$form['languages'][$langcode]['default']['#attributes']['disabled'] = 'disabled';
}
$form['languages'][$langcode]['operations'] = array(
'#type' => 'operations',
'#links' => $links,
'#weight' => 100,
);
}
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
return $form;
}