function taxonomy_manager_doube_tree_edit_translate in Taxonomy Manager 6.2
1 call to taxonomy_manager_doube_tree_edit_translate()
- taxonomy_manager_double_tree_edit in ./
taxonomy_manager.admin.inc - AJAX Callback for Double Tree operations
File
- ./
taxonomy_manager.admin.inc, line 1898 - Taxonomy Manager Admin
Code
function taxonomy_manager_doube_tree_edit_translate($params, &$msg, &$is_error_msg) {
$term1 = taxonomy_get_term(array_pop($params['selected_terms']));
$term2 = taxonomy_get_term(array_pop($params['selected_parents']));
$vid = $term1->vid;
if (module_exists('i18ntaxonomy')) {
if (i18ntaxonomy_vocabulary($vid) == I18N_TAXONOMY_TRANSLATE) {
if ($term1->language == $term2->language) {
$msg = t("Selected terms are of the same language.");
$is_error_msg = TRUE;
}
else {
$translations = i18ntaxonomy_term_get_translations(array(
'tid' => $term1->tid,
), FALSE);
foreach ($translations as $translation) {
if ($translation->language == $term2->language) {
$msg = t('Translation for this language already exists.');
$is_error_msg = TRUE;
break;
}
}
$translations = i18ntaxonomy_term_get_translations(array(
'tid' => $term2->tid,
), FALSE);
foreach ($translations as $translation) {
if ($translation->language == $term1->language) {
$msg = t('Translation for this language already exists.');
$is_error_msg = TRUE;
break;
}
}
}
}
else {
$msg = t("This is not a multilingual vocabulary.");
$is_error_msg = TRUE;
}
}
else {
$msg = t("Module i18ntaxonomy not enabled.");
$is_error_msg = TRUE;
}
if (!$is_error_msg) {
taxonomy_manager_add_translation($term1->tid, $term2->tid);
$msg = t("Translation for %term2 - %term1 added.", array(
'%term2' => $term2->name,
'%term1' => $term1->name,
));
}
}