function lingotek_admin_entity_bundle_profiles_form in Lingotek Translation 7.6
Same name and namespace in other branches
- 7.7 lingotek.admin.inc \lingotek_admin_entity_bundle_profiles_form()
- 7.5 lingotek.admin.inc \lingotek_admin_entity_bundle_profiles_form()
Content translation form
2 calls to lingotek_admin_entity_bundle_profiles_form()
- lingotek_setup_comment_translation_settings_form in ./
lingotek.setup.inc - lingotek_setup_node_translation_settings_form in ./
lingotek.setup.inc - Entity Translation Settings - Form Layout Select the Content Types and Fields to be Translated.
1 string reference to 'lingotek_admin_entity_bundle_profiles_form'
File
- ./
lingotek.admin.inc, line 81
Code
function lingotek_admin_entity_bundle_profiles_form($form, &$form_state, $entity_type, $show_fieldset = FALSE) {
$setup_complete = !lingotek_is_config_missing();
$entity_type_info = entity_get_info($entity_type);
$bundles = $entity_type_info['bundles'];
// sort alphabetically by label
uasort($bundles, 'lingotek_label_compare');
// Add the default bundle related to message types, if applicable.
if ($entity_type == 'message_type' && module_exists('message')) {
$bundles['message_type'] = array(
'label' => 'message_type',
'rdf_mapping' => array(),
);
}
$profiles_options = lingotek_get_profiles_by_name();
// these will come translated via the t-function
if (isset($profiles_options[LingotekSync::PROFILE_CONFIG])) {
unset($profiles_options[LingotekSync::PROFILE_CONFIG]);
}
if ($entity_type == 'field_collection_item') {
$profiles_options = array(
'ENABLED' => t('Enabled'),
LingotekSync::PROFILE_DISABLED => t('Disabled'),
);
$entity_type_info['label'] = 'Field Collection';
}
drupal_alter('lingotek_entity_profiles_options', $entity_type, $profiles_options);
$entity_profiles = variable_get('lingotek_entity_profiles');
$form['entity_type'] = array(
'#type' => 'hidden',
'#value' => $entity_type,
);
$selector = '.lingotek-content-settings-table.' . $entity_type;
$enable_all = l(t('(set all to automatic)'), '#', array(
'attributes' => array(
'onclick' => "lingotek_set_all('" . $selector . "', '0'); return false;",
),
));
$enable_all_manual = l(t('(set all to manual)'), '#', array(
'attributes' => array(
'onclick' => "lingotek_set_all('" . $selector . "', '1'); return false;",
),
));
$disable_all = l(t('(disable all)'), '#', array(
'attributes' => array(
'onclick' => "lingotek_set_all('" . $selector . "', 'DISABLED'); return false;",
),
));
$title_str = $setup_complete ? t('Translate @types', array(
'@type' => $entity_type_info['label'],
)) : t('Which content types do you want translated?');
$links_str = t('') . ' ' . $enable_all . ' ' . $enable_all_manual . ' ' . $disable_all;
$form['translation_' . $entity_type] = array(
'#type' => $show_fieldset ? 'fieldset' : 'item',
'#title' => check_plain($title_str),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'administrative_settings',
'actions' => array(
'#type' => 'actions',
),
'#submit' => array(
'lingotek_admin_entity_bundle_profiles_form_submit',
),
);
$form['translation_' . $entity_type][] = array(
'#type' => 'item',
'#description' => $links_str,
);
$translatable_field_types = lingotek_get_translatable_field_types();
$enabled_fields = variable_get('lingotek_enabled_fields', array());
$translate = isset($enabled_fields[$entity_type]) ? $enabled_fields[$entity_type] : array();
$rows = array();
foreach ($bundles as $bundle_name => $bundle) {
$original_fields = field_info_instances($entity_type, $bundle_name);
$fields = lingotek_node_settings_row_fields($entity_type, $bundle_name, $setup_complete, $translatable_field_types, $translate);
$oneoffs = $entity_type == 'node' ? lingotek_node_settings_row_oneoffs($bundle_name) : NULL;
$translation_mode = $entity_type == 'taxonomy_term' ? lingotek_get_translation_mode($bundle_name) : NULL;
$config_handled = $entity_type == 'taxonomy_term' && empty($original_fields) && $translation_mode['#markup'] !== 'Translate';
$translation_handling = $config_handled ? array(
'#markup' => 'Config',
) : array(
'#markup' => 'Bundle',
);
$profiles = lingotek_node_settings_row_profiles($bundle_name, $entity_profiles, $entity_type, $profiles_options, $setup_complete, $config_handled);
$entity_specifics = array(
'oneoffs' => $oneoffs,
'translation_mode' => $translation_mode,
'translation_handling' => $translation_handling,
);
if ($config_handled) {
$fields = array(
'config' => array(
'#markup' => t('These fields are translated from the config tab'),
),
);
}
if ($translation_mode['#markup'] == 'Fixed' || $translation_mode['#markup'] == 'No') {
continue;
}
$rows[$bundle_name] = lingotek_node_settings_row($entity_type, $bundle, $profiles, $fields, $entity_specifics);
}
$header = array(
t('Content Type'),
t('Translation Profile *'),
t('Fields'),
);
if ($entity_type == 'node') {
$header = array(
t('Content Type'),
t('Translation Profile *'),
t('Exceptions'),
t('Fields'),
);
}
elseif ($entity_type == 'taxonomy_term') {
$header = array(
t('Content Type'),
t('Translation Profile *'),
t('Translation Mode'),
t('Translation Handling'),
t('Fields'),
);
}
elseif ($entity_type == 'field_collection_item') {
$header = array(
t('Collection Name'),
t('Status *'),
t('Fields'),
);
}
$variables = array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'class' => array(
'lingotek-content-settings-table',
$entity_type,
),
),
);
$form['translation_' . $entity_type]['types'] = array(
'#type' => 'markup',
'#markup' => theme('table', $variables),
);
if ($setup_complete) {
$form['translation_' . $entity_type]['types']['#suffix'] = t('Note: changing the profile will update all settings for existing @entity_types except for the project, workflow, vault, and storage method (e.g. node/field)', array(
'@entity_type' => strtolower($entity_type_info['label']),
));
$form['#action'] = url('admin/settings/lingotek/settings', array(
'fragment' => lingotek_get_tab_id($entity_type),
));
}
lingotek_admin_add_entity_specific_changes($form, $form_state, $entity_type);
$form['translation_' . $entity_type]['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}